Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBstring.icc

Go to the documentation of this file.
00001 
00006 /*----------------------------------------------------------------------------*/
00007 /* C Tool Box: Designed and implemented by:                                   */
00008 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00009 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00010 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00011 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00012 /*----------------------------------------------------------------------------*/
00013 
00014 //------------------------------------------+-----------------------------------
00016 
00017 inline CTBstring::CTBstring()
00018   : m_sbuf(),
00019     mi_offset(0),
00020     mi_length(0)
00021 {}
00022 
00023 //------------------------------------------+-----------------------------------
00025 
00028 inline CTBstring::CTBstring(CTBstring& rhs, bool b_grab)
00029   : m_sbuf(rhs.m_sbuf,true),
00030     mi_offset(rhs.mi_offset),
00031     mi_length(rhs.mi_length)
00032 {
00033   rhs.mi_offset = 0;
00034   rhs.mi_length = 0;
00035 }
00036 
00037 //------------------------------------------+-----------------------------------
00039 
00040 inline CTBstring::~CTBstring()
00041 {}
00042 
00043 //------------------------------------------+-----------------------------------
00045 
00046 inline const char* CTBstring::Data() const
00047 {
00048   return &m_sbuf[mi_offset];
00049 }
00050 
00051 //------------------------------------------+-----------------------------------
00053 
00054 inline CTBint CTBstring::Length() const
00055 {
00056   return mi_length;
00057 }
00058 
00059 //------------------------------------------+-----------------------------------
00061 
00062 inline bool CTBstring::IsNull() const
00063 {
00064   return m_sbuf.IsNull();
00065 }
00066 
00067 //------------------------------------------+-----------------------------------
00069 
00070 inline bool CTBstring::IsEmpty() const
00071 {
00072   return !m_sbuf.IsNull() && mi_length == 0;
00073 }
00074 
00075 //------------------------------------------+-----------------------------------
00077 
00078 inline void CTBstring::Clear()
00079 {
00080   if (m_sbuf.IsShared()) m_sbuf.Release();  // if shared drop reference
00081   mi_length = 0;                            // in all cases zero length
00082   mi_offset = 0;
00083   return;
00084 }
00085 
00086 //------------------------------------------+-----------------------------------
00088 
00096 inline CTBint CTBstring::FindCharacter(char c, CTBint i_offset) const
00097 {
00098   return FindCharacter(&c,1,i_offset);
00099 }
00100 
00101 //------------------------------------------+-----------------------------------
00103 
00111 inline CTBint CTBstring::FindCharacter(const CTBstring& set, 
00112                                        CTBint i_offset) const
00113 {
00114   return FindCharacter(set.Data(),set.Length(),i_offset);
00115 }
00116 
00117 //------------------------------------------+-----------------------------------
00119 
00128 inline void CTBstring::Grab(CTBstring& rhs)
00129 {
00130   m_sbuf.Grab(rhs.m_sbuf);
00131   mi_offset = rhs.mi_offset;
00132   mi_length = rhs.mi_length;
00133   rhs.mi_offset = 0;
00134   rhs.mi_length = 0;
00135   return;
00136 }
00137 
00138 //------------------------------------------+-----------------------------------
00139 //
00140 // Forward assignment operator to Copy function:
00141 //
00142 
00144 
00145 inline CTBstring& CTBstring::operator=(const CTBstring& rhs)
00146 {
00147   Copy(rhs);
00148   return *this;
00149 }
00150 
00152 
00153 inline CTBstring& CTBstring::operator=(const char* c_rhs)
00154 {
00155   Copy(c_rhs);
00156   return *this;
00157 }
00158 
00160 
00161 inline CTBstring& CTBstring::operator=(char c_rhs)
00162 {
00163   Copy(c_rhs);
00164   return *this;
00165 }
00166 
00167 //------------------------------------------+-----------------------------------
00168 //
00169 // Forward operator+= to Append function:
00170 //
00171 
00173 
00174 inline CTBstring& CTBstring::operator+=(const CTBstring& rhs)
00175 {
00176   Append(rhs);
00177   return *this;
00178 }
00179 
00181 
00182 inline CTBstring& CTBstring::operator+=(const char* c_rhs)
00183 {
00184   Append(c_rhs);
00185   return *this;
00186 }
00187 
00189 
00190 inline CTBstring& CTBstring::operator+=(char c_rhs)
00191 {
00192   Append(c_rhs);
00193   return *this;
00194 }
00195 
00196 //------------------------------------------+-----------------------------------
00197 //
00198 // Forward insertion operator<< to Append function:
00199 //
00200 
00202 
00203 inline CTBstring& CTBstring::operator<<(const CTBstring& rhs)
00204 {
00205   Append(rhs);
00206   return *this;
00207 }
00208 
00210 
00211 inline CTBstring& CTBstring::operator<<(const char* c_rhs)
00212 {
00213   Append(c_rhs);
00214   return *this;
00215 }
00216 
00218 
00219 inline CTBstring& CTBstring::operator<<(char c_rhs)
00220 {
00221   Append(c_rhs);
00222   return *this;
00223 }
00224 
00225 //------------------------------------------+-----------------------------------
00226 //
00227 // Forward operator() to substring constructors:
00228 //
00229 
00231 
00232 inline CTBstring CTBstring::operator()(CTBint i_length) const
00233 {
00234   return CTBstring(*this,i_length);
00235 }
00236 
00238 
00239 inline CTBstring CTBstring::operator()(CTBint i_offset, CTBint i_length) const
00240 {
00241   return CTBstring(*this,i_offset,i_length);
00242 }
00243 
00244 //------------------------------------------+-----------------------------------
00245 //
00246 // Map basic comparison operators == and to Compare function.
00247 // The other 4 comparison operators are mapped via general templates.
00248 //
00249 
00255 inline bool operator==(const CTBstring& lhs, const CTBstring& rhs)
00256 {
00257   return lhs.Compare(rhs) == 0;
00258 }
00259 
00265 inline bool operator<(const CTBstring& lhs, const CTBstring& rhs)
00266 {
00267   return lhs.Compare(rhs) < 0;
00268 }
00269 
00275 inline bool operator==(const CTBstring& lhs, const char* c_rhs)
00276 {
00277   return lhs.Compare(c_rhs) == 0;
00278 }
00279 
00285 inline bool operator<(const CTBstring& lhs, const char* c_rhs)
00286 {
00287   return lhs.Compare(c_rhs) < 0;
00288 }
00289 
00295 inline bool operator==(const char* c_lhs, const CTBstring& rhs)
00296 {
00297   return -rhs.Compare(c_lhs) == 0;
00298 }
00299 
00305 inline bool operator<(const char* c_lhs, const CTBstring& rhs)
00306 {
00307   return -rhs.Compare(c_lhs) < 0;
00308 }

Generated at Fri Oct 24 18:11:30 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001