XmlCharData.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright 2007, 2008, 2009, 2010, 2011 Instituto de Sistemas e Robotica, Instituto Superior Tecnico
00003 
00004 This file is part of MeRMaID.
00005 
00006 MeRMaID is free software: you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation, either version 3 of the License, or
00009 (at your option) any later version.
00010 
00011 MeRMaID is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU Lesser General Public License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with MeRMaID.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 
00022 /**
00023  * @Filename XmlCharData.cpp
00024  * @Description XmlCharData implementation file.
00025  * @Status Implementing
00026  * @Version $Id: XmlCharData.cpp 1 2011-03-04 18:13:18Z jreis $
00027  * @Maintainer Nelson Ramos (nmsra@mega.ist.utl.pt)
00028  */
00029 
00030 #include "config.h"
00031 
00032 #include "XmlCharData.hpp"
00033 
00034 using namespace mermaid::support::xml;
00035 
00036 
00037 /// String containing blank characters.
00038 #define BLANK_STRING (string(" \t\n\r"))
00039 
00040 
00041 
00042 XmlCharData::XmlCharData()
00043 {
00044   string_ = "";
00045 }
00046 
00047 
00048 
00049 XmlCharData::XmlCharData (const char* c)
00050 {
00051   string_ = string (c);
00052   // this->removeEndBlanks();
00053 }
00054 
00055 
00056 
00057 XmlCharData * XmlCharData::clone()
00058 {
00059   return new XmlCharData (*this);
00060 }
00061 
00062 
00063 
00064 XmlCharData::XmlCharData (string s)
00065 {
00066   string_ = s;
00067 }
00068 
00069 
00070 
00071 XmlCharData::XmlCharData (const XmlCharData &c)
00072 {
00073   string_ = c.string_;
00074 }
00075 
00076 
00077 
00078 const bool XmlCharData::isBlank() const
00079 {
00080   size_t pos = string_.find_first_not_of (BLANK_STRING);
00081   
00082   if ( (pos >= 0) && (pos < string_.size())) {
00083     return false;
00084   }
00085   else {
00086     return true;
00087   }
00088 }
00089 
00090 
00091 
00092 void XmlCharData::removeEndBlanks()
00093 {
00094   int frontPos = string_.find_first_not_of (BLANK_STRING);
00095   string_.erase (0, frontPos);
00096   
00097   int backPos = string_.find_last_not_of (BLANK_STRING);
00098   
00099   string_.erase (backPos + 1, string_.size() - backPos - 1);
00100 }
00101 
00102 
00103 
00104 XmlCharData::operator string() const
00105 {
00106   return string_;
00107 }
00108 
00109 
00110 
00111 const bool XmlCharData::isXmlCharData() const
00112 {
00113   return true;
00114 }
Generated on Fri Mar 4 22:14:58 2011 for MeRMaID::support by  doxygen 1.6.3