Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ystring.h

Go to the documentation of this file.
00001 /************************************************************************
00002  * $Id: ystring.h,v 1.2 2007-04-13 16:15:57 mbickel Exp $
00003  *
00004  * ------------
00005  * Description:
00006  * ------------
00007  * ystring.h
00008  *
00009  * A unicode string class
00010  *
00011  * (C) Copyright 2004 Arabeyes, Mohammed Yousif
00012  *
00013  * -----------------
00014  * Revision Details:    (Updated by Revision Control System)
00015  * -----------------
00016  *  $Date: 2007-04-13 16:15:57 $
00017  *  $Author: mbickel $
00018  *  $Revision: 1.2 $
00019  *  $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/ystring.h,v $
00020  *
00021  *  (www.arabeyes.org - under GPL License)
00022  *
00023  ************************************************************************/
00024 
00025 #ifndef YSTRING_H
00026 #define YSTRING_H
00027 
00028 #include <stdexcept>
00029 #include <string>
00030 #include <vector>
00031 
00032 #include "ychar.h"
00033 
00034 class DECLSPEC YString {
00035 public:
00036 
00037         typedef YChar value_type;
00038         typedef std::vector<YChar>::pointer pointer;
00039         typedef YChar & reference;
00040         typedef const YChar & const_reference;
00041         typedef std::vector<YChar>::size_type size_type;
00042         typedef std::vector<YChar>::difference_type difference_type;
00043         static const size_type npos = std::string::npos;
00044         typedef std::vector<YChar>::iterator iterator;
00045         typedef std::vector<YChar>::const_iterator const_iterator;
00046         typedef std::vector<YChar>::reverse_iterator reverse_iterator;
00047         typedef std::vector<YChar>::const_reverse_iterator const_reverse_iterator;
00048 
00049         YString();
00050         YString(const std::string &, size_type = 0, size_type = npos);
00051         YString(const char *);
00052         YString(const char *, size_type) ;
00053         YString(size_type, char);
00054         template <class InputIterator>
00055         YString(InputIterator, InputIterator);
00056 
00057         YString(const YString &, size_type = 0, size_type = npos) throw(std::out_of_range);
00058         YString(const std::vector<YChar>);
00059         YString(const std::vector<YChar>, size_type);
00060         YString(size_type, YChar);
00061         YString(const YChar);
00062 
00063         iterator begin();
00064         iterator end();
00065         const_iterator begin() const;
00066         const_iterator end() const;
00067         reverse_iterator rbegin();
00068         reverse_iterator rend();
00069         const_reverse_iterator rbegin() const;
00070         const_reverse_iterator rend() const;
00071         size_type size() const;
00072         size_type max_size() const;
00073         size_type capacity() const;
00074         bool empty() const;
00075 
00076         reference operator[](size_type n);
00077         const_reference operator[](size_type n) const;
00078         const char * c_str() const;
00079         const char * data() const;
00080 
00081         YString & operator=(const YString &);
00082         YString & operator=(const std::string &);
00083         YString & operator=(const char *);
00084         YString & operator=(char);
00085         YString & operator=(YChar);
00086         YString & operator=(uint32);
00087 
00088         void reserve(size_type);
00089         void swap(YString &);
00090 
00091         iterator insert(iterator, const YChar &);
00092         template <class InputIterator>
00093         void insert(iterator, InputIterator, InputIterator);
00094         void insert(iterator, size_type, const YChar &);
00095         YString & insert(size_type, const YString &);
00096         YString & insert(size_type, const YString &, size_type, size_type);
00097         YString & insert(size_type, const char *);
00098         YString & insert(size_type, const char *, size_type);
00099         YString & insert(size_type, size_type, YChar);
00100         YString & insert(size_type, size_type, char);
00101 
00102         iterator erase(iterator) ;
00103         iterator erase(iterator, iterator);
00104         YString & erase(size_type = 0, size_type = npos)  throw(std::out_of_range);
00105 
00106         size_type find(YChar, size_type = 0) throw(std::out_of_range);
00107 
00108         void push_back(const YChar &);
00109         void pop_back();
00110 
00111         void clear();
00112 
00113 
00114 
00115         size_type length() const;
00116         size_type bytes() const;
00117         YString reverse() const;
00118 
00119         YChar at(YString::size_type) const throw(std::out_of_range);
00120         void setAt(YString::size_type, YChar) throw(std::out_of_range);
00121 
00122         int compareTo(const YString &) const;
00123         YString substr(YString::size_type, YString::size_type = std::string::npos) const throw(std::out_of_range);
00124 
00125         const std::string utf8() const;
00126 
00127 
00128         operator std::string() const;
00129         /*
00130         operator const char *() const;
00131         */
00132 
00133 
00134 
00135         YString & operator+=(const YString &);
00136         YString & operator+=(const std::string &);
00137         YString & operator+=(const char *);
00138         YString & operator+=(const YChar);
00139         YString & operator+=(const char);
00140         YString & operator+=(const uint32);
00141 
00142         friend YString operator+(const YString &, const YString &);
00143         friend YString operator+(const YString &, const char *);
00144         friend YString operator+(const char *, const YString &);
00145         friend YString operator+(const YString &, const YChar);
00146         friend YString operator+(const YChar, const YString &);
00147         friend YString operator+(const YString &, const char);
00148         friend YString operator+(const char, const YString &);
00149         friend YString operator+(const YString &, const uint32);
00150         friend YString operator+(const uint32, const YString &);
00151 
00152         static YString fromUtf8(const char *) throw(std::domain_error);
00153         static YString fromUtf8(const std::string&) throw(std::domain_error);
00154 
00155 private:
00156         std::vector<YChar> unicode;
00157 };
00158 
00159 bool operator==(const YString &, const YString &);
00160 bool operator==(const YString &, const char *);
00161 bool operator==(const char *, const YString &);
00162 
00163 bool operator!=(const YString &, const YString &);
00164 bool operator!=(const YString &, const char *);
00165 bool operator!=(const char *, const YString &);
00166 
00167 bool operator<(const YString &, const YString &);
00168 bool operator<(const YString &, const char *);
00169 bool operator<(const char *, const YString &);
00170 
00171 bool operator<=(const YString &, const YString &);
00172 bool operator<=(const YString &, const char *);
00173 bool operator<=(const char *, const YString &);
00174 
00175 bool operator>(const YString &, const YString &);
00176 bool operator>(const YString &, const char *);
00177 bool operator>(const char *, const YString &);
00178 
00179 bool operator>=(const YString &, const YString &);
00180 bool operator>=(const YString &, const char *);
00181 bool operator>=(const char *, const YString &);
00182 
00183 YString operator+(const YString &, const YString &);
00184 YString operator+(const YString &, const char *);
00185 YString operator+(const char *, const YString &);
00186 YString operator+(const YString &, const YChar);
00187 YString operator+(const YChar, const YString &);
00188 YString operator+(const YString &, const char);
00189 YString operator+(const char, const YString &);
00190 YString operator+(const YString &, const uint32);
00191 YString operator+(const uint32, const YString &);
00192 YString operator+(const YChar, const YChar);
00193 YString operator+(const char *, const YChar);
00194 YString operator+(const YChar, const char *);
00195 
00196 std::ostream & operator<<( std::ostream &, YString &);
00197 std::istream & operator>>( std::istream &, YString &);
00198 
00199 #endif

Generated on Tue Jun 24 01:27:56 2008 for Advanced Strategic Command by  doxygen 1.4.2