RVNGString.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* librevenge
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2004 William Lachance (wrlach@gmail.com)
00011  * Copyright (C) 2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00012  *
00013  * For minor contributions see the git repository.
00014  *
00015  * Alternatively, the contents of this file may be used under the terms
00016  * of the GNU Lesser General Public License Version 2.1 or later
00017  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00018  * applicable instead of those above.
00019  */
00020 
00021 #ifndef RVNGSTRING_H
00022 #define RVNGSTRING_H
00023 
00024 #include "librevenge-api.h"
00025 
00026 namespace librevenge
00027 {
00028 
00029 class RVNGStringImpl;
00030 
00033 class REVENGE_API RVNGString
00034 {
00035 public:
00036         RVNGString();
00037         RVNGString(const RVNGString &other);
00038         RVNGString(const char *str);
00039         ~RVNGString();
00040 
00048         static RVNGString escapeXML(const RVNGString &s);
00049 
00057         static RVNGString escapeXML(const char *s);
00058 
00059         const char *cstr() const;
00060 
00065         int len() const;
00072         unsigned long size() const;
00073 
00074         bool empty() const;
00075 
00076         void sprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
00077         void append(const RVNGString &s);
00078         void append(const char *s);
00079         void append(const char c);
00080 
00085         void appendEscapedXML(const RVNGString &s);
00086 
00091         void appendEscapedXML(const char *s);
00092 
00093         void clear();
00094         RVNGString &operator=(const RVNGString &str);
00095         RVNGString &operator=(const char *s);
00096 
00097         // Comparison
00098         bool operator==(const char *s) const;
00099         bool operator==(const RVNGString &str) const;
00100         inline bool operator!=(const char *s) const
00101         {
00102                 return !operator==(s);
00103         }
00104         inline bool operator!=(const RVNGString &str) const
00105         {
00106                 return !operator==(str);
00107         }
00108         bool operator<(const char *s) const;
00109         bool operator<(const RVNGString &str) const;
00110         inline bool operator<=(const char *s) const
00111         {
00112                 return operator==(s) || operator<(s);
00113         }
00114         inline bool operator<=(const RVNGString &str) const
00115         {
00116                 return operator==(str) || operator<(str);
00117         }
00118         inline bool operator>=(const char *s) const
00119         {
00120                 return !operator<(s);
00121         }
00122         inline bool operator>=(const RVNGString &str) const
00123         {
00124                 return !operator<(str);
00125         }
00126         inline bool operator>(const char *s) const
00127         {
00128                 return !operator<=(s);
00129         }
00130         inline bool operator>(const RVNGString &str) const
00131         {
00132                 return !operator<=(str);
00133         }
00134 
00135         class REVENGE_API Iter
00136         {
00137         public:
00138                 Iter(const RVNGString &str);
00139                 virtual ~Iter();
00140                 void rewind();
00141                 bool next();
00142                 bool last();
00143                 const char *operator()() const;
00144         private:
00145                 Iter(const Iter &);
00146                 Iter &operator=(const Iter &);
00147                 RVNGStringImpl *m_stringImpl;
00148                 int m_pos;
00149                 mutable char *m_curChar;
00150         };
00151 
00152 private:
00153         RVNGStringImpl *m_stringImpl;
00154 };
00155 
00156 }
00157 
00158 #endif
00159 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */