String.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006-2011, SRI International (R)
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as published by
00006  * the Free Software Foundation, either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #pragma once
00019 
00020 #ifndef __OpenKarto_String_h__
00021 #define __OpenKarto_String_h__
00022 
00023 #include <stdio.h>
00024 #include <ostream>
00025 #include <sstream>
00026 
00027 #include <OpenKarto/Macros.h>
00028 #include <OpenKarto/Types.h>
00029 
00030 namespace karto
00031 {
00032 
00034 
00035 
00039 
00040 #ifdef _DEBUG
00041   struct StringPrivate
00042   {
00043     std::string m_String;
00044   };
00045 #else
00046   struct StringPrivate;
00047 #endif
00048 
00052   class KARTO_EXPORT String
00053   {
00054   public:
00058     String();
00059 
00064     String(char c);
00065 
00070     String(const char* pString);
00071 
00077     String(const char* pString, kt_int32u size);
00078 
00082     String(const String& rOther);
00083 
00087     virtual ~String();
00088 
00089   public:
00094     void Append(const String& rString);
00095 
00100     const char* ToCString() const;
00101 
00106     kt_size_t Size() const;
00107 
00111     void Clear();
00112 
00118     String SubString(kt_size_t index) const;
00119 
00126     String SubString(kt_size_t index, kt_size_t length) const;
00127     
00133     kt_size_t Find(const String& rValue) const;
00134 
00140     kt_size_t FindFirstOf(const String& rValue) const;
00141 
00147     kt_size_t FindLastOf(const String& rValue) const;
00148 
00153     static String NewLine();
00154 
00160     void Erase(kt_size_t index, kt_size_t length);
00161 
00162   public:
00168     int operator[](kt_int32u index) const;
00169 
00173     String& operator=(const String& rOther);
00174 
00178     kt_bool operator==(const String& rOther) const;
00179 
00183     kt_bool operator!=(const String& rOther) const;
00184 
00188     kt_bool operator<(const String& rOther) const;
00189 
00193     kt_bool operator>(const String& rOther) const;
00194 
00198     String operator+(const String& rOther);
00199 
00203     String operator+(const char* pChar);
00204 
00211     friend String operator+(const char* pChar, const String& rOther)
00212     {
00213       String string(pChar);
00214       string.Append(rOther);
00215       return string;
00216     }
00217 
00224     friend String operator+(const String& rOther1, const String& rOther2)
00225     {
00226       String string;
00227       string.Append(rOther1);
00228       string.Append(rOther2);
00229       return string;
00230     }
00231 
00235     friend KARTO_FORCEINLINE std::ostream& operator << (std::ostream& rStream, const String& rString)
00236     {
00237       rStream << rString.ToCString();
00238       return rStream;
00239     }
00240 
00241   private:
00242     StringPrivate* m_pStringPrivate;
00243   }; // class String
00244 
00246 
00247 }
00248 
00249 #endif // __OpenKarto_String_h__


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Sun Apr 2 2017 04:05:24