Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __ADSTRING_HPP__
00042 #define __ADSTRING_HPP__
00043
00044 #include "clist.h"
00045 #include <string.h>
00046
00047 #include <ostream>
00048
00049 #include <stdio.h>
00050
00051 class adstring_shape
00052 {
00053 size_t sz;
00054
00055 protected:
00056 adstring_shape(const size_t size)
00057 {
00058 sz = size;
00059 }
00060 size_t& size()
00061 {
00062 return sz;
00063 }
00064
00065 friend class adstring;
00066 };
00067
00068 class adstring_array;
00069
00070 class adstring : public clist
00071 {
00072 adstring_shape * shape;
00073 #if (defined __ZTC__) || (defined __NDPX__)
00074 char * s;
00075 #else
00076 unsigned char * s;
00077 #endif
00078 void allocate(const size_t sz);
00079 void deallocate(void);
00080 friend class adstring_array;
00081 public :
00082 adstring();
00083 adstring(const adstring &v);
00084 adstring(const char v);
00085 adstring(const char* t);
00086 adstring(const unsigned char v);
00087 adstring(const unsigned char* t);
00088 adstring(const size_t lb, const size_t ub);
00089 adstring(const int size);
00090 ~adstring();
00091
00092 void allocate(const char* t);
00093 void realloc(const char* t);
00094
00095
00096 size_t size() const;
00097 size_t buff_size() const;
00098 unsigned char &operator()(const size_t i);
00099 unsigned char &operator[](const size_t i);
00100 const unsigned char& operator()(const size_t i) const;
00101 const unsigned char& operator[](const size_t i) const;
00102
00103 adstring& operator+=(const adstring &u);
00104 inline adstring& operator+=(const char u)
00105 { return(*this += adstring(u)); }
00106
00107 int operator==(const adstring &u);
00108
00109 inline int operator == (const char* u)
00110 { return *this == adstring(u); }
00111
00112 inline int operator!=(const adstring &u)
00113 { return(!(*this==u)); }
00114
00115 adstring operator()(const size_t i, const size_t j);
00116 adstring operator()(const size_t i, const size_t j) const;
00117
00118 int operator==(const char* u) const;
00119 int operator==(const adstring &u) const;
00120
00121 adstring& operator=(const adstring &t);
00122 adstring& operator=(const char t);
00123
00124
00125 operator unsigned char * ();
00126 operator char * ();
00127 operator const unsigned char*() const;
00128 operator const char*() const;
00129
00130
00131
00132
00133 size_t pos(const adstring& substr) const;
00134
00135
00136 friend adstring str(double x, int minwidth, int decplaces);
00137 friend adstring str(const int x);
00138 friend void val(const adstring& s, int& v, int& code);
00139 friend int val(const adstring& s);
00140
00141 void to_upper(void);
00142 void to_lower(void);
00143 adstring to_upper(adstring& s);
00144 adstring to_lower(adstring& s);
00145
00146 friend std::ostream& operator<<(std::ostream& c, const adstring& t);
00147 friend std::istream& operator>>(std::istream& c, adstring& t);
00148 friend adstring operator+(const adstring &u, const adstring &v);
00149 friend adstring operator+(const adstring &u, const unsigned char v);
00150 friend adstring operator+(const adstring &u, const char v);
00151 friend adstring operator+(const adstring &u, const unsigned char *v);
00152 friend adstring operator+(const adstring & u, const char *v);
00153 friend adstring operator+(const unsigned char *v, const adstring& u);
00154 friend adstring operator+(const char *v, const adstring &u);
00155 friend adstring operator+(const unsigned char u, const adstring &v);
00156 };
00157 adstring to_lower(adstring& s);
00158 adstring to_upper(adstring& s);
00159 adstring str(double x, int minwidth=17, int decplaces=-1);
00160 adstring str(const int x);
00161 void val(const adstring& s, int& v, int& code);
00162 int val(const adstring& s);
00163
00164 class cifstream;
00165
00166 class line_adstring : public adstring
00167 {
00168 public:
00169 line_adstring(void) : adstring() {}
00170 line_adstring(const adstring& s) : adstring(s) {}
00171 line_adstring& operator=(const adstring& s);
00172 line_adstring& operator=(const char *s);
00173 friend std::istream & operator >> (std::istream & c, line_adstring & t);
00174 };
00175
00176 adstring itoa(int n,int d);
00177
00178 void str(const int, adstring&);
00179 adstring chr(int c);
00180 size_t length(const adstring& t);
00181 size_t pos(const adstring& substr, const adstring& s);
00182
00183
00184
00185 #if defined(__BORLANDC__)
00186 # if (__BORLANDC__ <= 0x0520)
00187 class ifstream;
00188 class ofstream;
00189 class cifstream;
00190 # endif
00191 #endif
00192
00193 class vector_shape;
00194
00195 class adstring_array : public clist
00196 {
00197 vector_shape* shape;
00198 adstring** ptr;
00199 public:
00200 int size() const;
00201 int indexmin(void) const;
00202 int indexmax(void) const;
00203 adstring_array(const adstring_array& sa);
00204 ~adstring_array();
00205 adstring_array(int min,int max);
00206 void allocate(int min,int max);
00207 adstring_array(void);
00208 const adstring& operator[](int i) const;
00209 const adstring& operator()(int i) const;
00210 adstring& operator [] (int i);
00211 adstring& operator () (int i);
00212 adstring_array& operator += (const adstring& s);
00213 adstring_array& append_distinct(const adstring& s);
00214 friend std::ifstream& operator >> (std::ifstream& ifs,adstring_array& sa);
00215 friend std::ostream& operator<<(const std::ostream& ifs,
00216 const adstring_array& sa);
00217 friend cifstream& operator >> (cifstream& ifs,adstring_array& sa);
00218
00219 void to_upper(void);
00220 void to_lower(void);
00221 adstring_array to_upper(adstring_array& s);
00222 adstring_array to_lower(adstring_array& s);
00223 adstring_array& operator=(const adstring_array&);
00224 };
00225 adstring_array to_lower(adstring_array& s);
00226 adstring_array to_upper(adstring_array& s);
00227
00228 std::ostream& operator<<(const std::ostream& ifs, const adstring_array& sa);
00229
00230 int atoi(adstring& s);
00231 #endif //#ifndef __STRING_HPP__