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
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include "clist.h"
00057 #include <string.h>
00058
00059 #include <ostream>
00060
00061 #include <stdio.h>
00062
00063 #ifdef HERE
00064 #undef HERE
00065 #endif
00066
00067 #define HERE
00068
00069 #define USE_CONST
00070 #ifdef USE_CONST
00071 #define _CONST const
00072 #else
00073 #define _CONST
00074 #endif
00075 class adstring_shape
00076 {
00077 unsigned int sz;
00078 protected :
00079 friend class adstring;
00080 adstring_shape(unsigned int n)
00081 {
00082 sz = n;
00083 }
00084 unsigned int & size()
00085 {
00086 return (sz);
00087 }
00088 };
00089
00090 class adstring_array;
00091
00092 class adstring : public clist
00093 {
00094 adstring_shape * shape;
00095 #if (defined __ZTC__) || (defined __NDPX__)
00096 char * s;
00097 #else
00098 unsigned char * s;
00099 #endif
00100 void allocate(int sz);
00101 void deallocate(void);
00102 friend class adstring_array;
00103 public :
00104 friend std::ostream & operator<<(std::ostream & c, const adstring & t);
00105 friend std::istream & operator >> (std::istream & c, adstring & t);
00106
00107 adstring(const char *t);
00108 void allocate(const char *t);
00109 adstring(int lb, int ub);
00110 adstring(const adstring &v);
00111 void realloc(const char * t);
00112
00113 adstring(const char v);
00114 adstring(void);
00115 ~adstring();
00116 unsigned int size(void) const;
00117 unsigned int buff_size(void);
00118 unsigned char &operator()(const int i);
00119 unsigned char &operator[](const int i);
00120 #ifdef USE_CONST
00121 const unsigned char& operator()(const int i) const;
00122 const unsigned char& operator[](const int i) const;
00123 #endif
00124
00125 #ifdef __INTEL_COMPILER
00126 friend adstring operator+(const adstring &u, const char* v)
00127 {
00128 adstring a(v);
00129 return u + a;
00130 }
00131 #endif
00132
00133 friend adstring operator+(const adstring &u, const adstring &v);
00134
00135 friend adstring operator+(const adstring &u, const unsigned char v);
00136
00137 friend adstring operator+(const adstring &u, const signed char v);
00138
00139 friend adstring operator+(const adstring &u, const unsigned char *v);
00140
00141 friend adstring operator+(const adstring & u, const signed char *v);
00142
00143 friend adstring operator+(const unsigned char *v, const adstring& u);
00144
00145 friend adstring operator+(const char *v, const adstring &u);
00146
00147 friend adstring operator+(const unsigned char u, const adstring &v);
00148
00149 adstring& operator+=(const adstring &u);
00150 inline adstring& operator+=(const char u)
00151 { return(*this += adstring(u)); }
00152
00153 int operator==(const adstring &u);
00154
00155 inline int operator == (const char* u)
00156 { return *this == adstring(u); }
00157
00158 inline int operator!=(const adstring &u)
00159 { return(!(*this==u)); }
00160
00161 adstring operator()(int i, int j);
00162 #if defined(USE_CONST)
00163 int operator==(const char* u) const;
00164
00165 int operator==(const adstring &u) const;
00166 adstring operator()(int i, int j) const;
00167 #endif
00168
00169 adstring& operator=(const adstring &t);
00170 adstring& operator=(const char t);
00171
00172
00173 operator unsigned char * ();
00174 operator char * ();
00175 #ifdef USE_CONST
00176 operator const unsigned char*() const;
00177 operator const char*() const;
00178 #endif
00179
00180
00181
00182 int pos(const adstring& substr) const;
00183
00184
00185 friend adstring str(double x, int minwidth, int decplaces);
00186 friend adstring str(const int x);
00187 friend void val(const adstring& s, int& v, int& code);
00188 friend int val(const adstring& s);
00189
00190 void to_upper(void);
00191 void to_lower(void);
00192 adstring to_upper(adstring& s);
00193 adstring to_lower(adstring& s);
00194 };
00195 adstring to_lower(adstring& s);
00196 adstring to_upper(adstring& s);
00197 adstring str(double x, int minwidth=17, int decplaces=-1);
00198 adstring str(const int x);
00199 void val(const adstring& s, int& v, int& code);
00200 int val(const adstring& s);
00201
00202 class cifstream;
00203
00204 class line_adstring : public adstring
00205 {
00206 public:
00207 line_adstring(void) : adstring() {}
00208 line_adstring(const adstring& s) : adstring(s) {}
00209 line_adstring& operator=(const adstring& s);
00210 line_adstring& operator=(const char *s);
00211 friend std::istream & operator >> (std::istream & c, line_adstring & t);
00212 };
00213
00214 adstring itoa(int n,int d);
00215
00216 void str(const int, adstring&);
00217 adstring chr(int c);
00218 int length(const adstring& t);
00219 int pos(const adstring& substr, const adstring& s);
00220
00221
00222
00223 #if defined(__BORLANDC__)
00224 # if (__BORLANDC__ <= 0x0520)
00225 class ifstream;
00226 class ofstream;
00227 class cifstream;
00228 # endif
00229 #endif
00230
00231 class vector_shape;
00232
00233 class adstring_array : public clist
00234 {
00235 vector_shape * shape;
00236 adstring ** ptr;
00237 public:
00238 int size() const;
00239 int indexmin(void) const;
00240 int indexmax(void) const;
00241 adstring_array(const adstring_array& sa);
00242 ~adstring_array();
00243 adstring_array(int min,int max);
00244 void allocate(int min,int max);
00245 adstring_array(void);
00246 #ifdef USE_CONST
00247 const adstring& operator[](int i) const;
00248 const adstring& operator()(int i) const;
00249 #endif
00250 adstring& operator [] (int i);
00251 adstring& operator () (int i);
00252 adstring_array& operator += (const adstring& s);
00253 adstring_array& append_distinct(const adstring& s);
00254 friend std::ifstream& operator >> (std::ifstream& ifs,adstring_array& sa);
00255 friend std::ostream& operator<<(const std::ostream& ifs, const adstring_array& sa);
00256 friend cifstream& operator >> (cifstream& ifs,adstring_array& sa);
00257
00258 void to_upper(void);
00259 void to_lower(void);
00260 adstring_array to_upper(adstring_array& s);
00261 adstring_array to_lower(adstring_array& s);
00262 adstring_array& operator=(const adstring_array&);
00263 };
00264 adstring_array to_lower(adstring_array& s);
00265 adstring_array to_upper(adstring_array& s);
00266
00267 std::ostream& operator<<(const std::ostream& ifs, const adstring_array& sa);
00268
00269 int atoi(adstring& s);
00270 #endif //#ifndef __STRING_HPP__