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

SString.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: SString.i,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00003 
00004 #include "ace/Malloc_Base.h"
00005 
00006 ACE_INLINE
00007 ACE_NS_WString::ACE_NS_WString (ACE_Allocator *alloc)
00008   : ACE_WString (alloc)
00009 {
00010 }
00011 
00012 ACE_INLINE
00013 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
00014                                 size_t len,
00015                                 ACE_Allocator *alloc)
00016   : ACE_WString (s, len, alloc)
00017 {
00018 }
00019 
00020 ACE_INLINE
00021 ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s,
00022                                 ACE_Allocator *alloc)
00023   : ACE_WString (s, alloc)
00024 {
00025 }
00026 
00027 ACE_INLINE
00028 ACE_NS_WString::ACE_NS_WString (size_t len, ACE_Allocator *alloc)
00029   : ACE_WString (len, 0, alloc)
00030 {
00031 }
00032 
00033 ACE_INLINE
00034 ACE_NS_WString::ACE_NS_WString (const ACE_NS_WString &s)
00035   : ACE_WString (s)
00036 {
00037 }
00038 
00039 ACE_INLINE
00040 ACE_NS_WString::ACE_NS_WString (ACE_WSTRING_TYPE c, ACE_Allocator *alloc)
00041   : ACE_WString (c, alloc)
00042 {
00043 }
00044 
00045 ACE_INLINE ACE_NS_WString
00046 operator+ (const ACE_NS_WString &s, const ACE_NS_WString &t)
00047 {
00048   ACE_NS_WString temp (s);
00049   temp += t;
00050   return temp;
00051 }
00052 
00053 ACE_INLINE
00054 ACE_SString::~ACE_SString (void)
00055 {
00056 }
00057 
00058 ACE_INLINE ACE_SString
00059 ACE_SString::substr (size_t offset,
00060                      ssize_t length) const
00061 {
00062   return this->substring (offset, length);
00063 }
00064 
00065 // Return the <slot'th> character in the string.
00066 
00067 ACE_INLINE char
00068 ACE_SString::operator[] (size_t slot) const
00069 {
00070   ACE_TRACE ("ACE_SString::operator[]");
00071   return this->rep_[slot];
00072 }
00073 
00074 // Return the <slot'th> character in the string by reference.
00075 
00076 ACE_INLINE char &
00077 ACE_SString::operator[] (size_t slot)
00078 {
00079   ACE_TRACE ("ACE_SString::operator[]");
00080   return this->rep_[slot];
00081 }
00082 
00083 // Get the underlying pointer (does not make a copy, so beware!).
00084 
00085 ACE_INLINE const char *
00086 ACE_SString::rep (void) const
00087 {
00088   ACE_TRACE ("ACE_SString::rep");
00089   return this->rep_;
00090 }
00091 
00092 // Get the underlying pointer (does not make a copy, so beware!).
00093 
00094 ACE_INLINE const char *
00095 ACE_SString::fast_rep (void) const
00096 {
00097   ACE_TRACE ("ACE_SString::fast_rep");
00098   return this->rep_;
00099 }
00100 
00101 // Get the underlying pointer (does not make a copy, so beware!).
00102 
00103 ACE_INLINE const char *
00104 ACE_SString::c_str (void) const
00105 {
00106   ACE_TRACE ("ACE_SString::c_str");
00107   return this->rep_;
00108 }
00109 
00110 // Comparison operator.
00111 
00112 ACE_INLINE int
00113 ACE_SString::operator== (const ACE_SString &s) const
00114 {
00115   ACE_TRACE ("ACE_SString::operator==");
00116   return this->len_ == s.len_
00117     && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
00118 }
00119 
00120 // Less than comparison operator.
00121 
00122 ACE_INLINE int
00123 ACE_SString::operator < (const ACE_SString &s) const
00124 {
00125   ACE_TRACE ("ACE_SString::operator <");
00126 
00127   return (this->rep_ && s.rep_)
00128     ? ACE_OS::strcmp (this->rep_, s.rep_) < 0
00129     : ((s.rep_) ? 1 : 0 );
00130 }
00131 
00132 // Greater than comparison operator.
00133 
00134 ACE_INLINE int
00135 ACE_SString::operator > (const ACE_SString &s) const
00136 {
00137   ACE_TRACE ("ACE_SString::operator >");
00138 
00139   return (this->rep_ && s.rep_)
00140     ? ACE_OS::strcmp (this->rep_, s.rep_) > 0
00141     : ((this->rep_) ? 1 : 0 );
00142 }
00143 
00144 // Comparison operator.
00145 
00146 ACE_INLINE int
00147 ACE_SString::operator!= (const ACE_SString &s) const
00148 {
00149   ACE_TRACE ("ACE_SString::operator!=");
00150   return !(*this == s);
00151 }
00152 
00153 ACE_INLINE int
00154 ACE_SString::compare (const ACE_SString &s) const
00155 {
00156   ACE_TRACE ("ACE_SString::compare");
00157   return ACE_OS::strcmp (this->rep_, s.rep_);
00158 }
00159 
00160 ACE_INLINE int
00161 ACE_SString::find (const char *s, int pos) const
00162 {
00163   char *substr = this->rep_ + pos;
00164   char *pointer = ACE_OS::strstr (substr, s);
00165   if (pointer == 0)
00166     return ACE_SString::npos;
00167   else
00168     return pointer - this->rep_;
00169 }
00170 
00171 ACE_INLINE int
00172 ACE_SString::find (char c, int pos) const
00173 {
00174   char *substr = this->rep_ + pos;
00175   char *pointer = ACE_OS::strchr (substr, c);
00176   if (pointer == 0)
00177     return ACE_SString::npos;
00178   else
00179     return pointer - this->rep_;
00180 }
00181 
00182 ACE_INLINE int
00183 ACE_SString::strstr (const ACE_SString &s) const
00184 {
00185   ACE_TRACE ("ACE_SString::strstr");
00186 
00187   return this->find (s.rep_);
00188 }
00189 
00190 ACE_INLINE int
00191 ACE_SString::find (const ACE_SString &str, int pos) const
00192 {
00193   return this->find (str.rep_, pos);
00194 }
00195 
00196 ACE_INLINE int
00197 ACE_SString::rfind (char c, int pos) const
00198 {
00199   if (pos == ACE_SString::npos)
00200     pos = ACE_static_cast (int, this->len_);
00201 
00202   for (int i = pos - 1; i >= 0; i--)
00203     if (this->rep_[i] == c)
00204       return i;
00205 
00206   return ACE_SString::npos;
00207 }
00208 
00209 ACE_INLINE u_long
00210 ACE_SString::hash (void) const
00211 {
00212   return ACE::hash_pjw (this->rep_);
00213 }
00214 
00215 ACE_INLINE size_t
00216 ACE_SString::length (void) const
00217 {
00218   ACE_TRACE ("ACE_SString::length");
00219   return this->len_;
00220 }
00221 
00222 ACE_INLINE
00223 ACE_Auto_String_Free::ACE_Auto_String_Free (char* p)
00224   :  p_ (p)
00225 {
00226 }
00227 
00228 ACE_INLINE
00229 ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs)
00230   :  p_ (rhs.p_)
00231 {
00232   rhs.p_ = 0;
00233 }
00234 
00235 ACE_INLINE void
00236 ACE_Auto_String_Free::reset (char* p)
00237 {
00238   if (this->p_ != 0)
00239     ACE_OS::free (this->p_);
00240   this->p_ = p;
00241 }
00242 
00243 ACE_INLINE ACE_Auto_String_Free&
00244 ACE_Auto_String_Free::operator= (ACE_Auto_String_Free& rhs)
00245 {
00246   if (this != &rhs)
00247     {
00248       this->reset (rhs.p_);
00249       rhs.p_ = 0;
00250     }
00251   return *this;
00252 }
00253 
00254 ACE_INLINE
00255 ACE_Auto_String_Free::~ACE_Auto_String_Free (void)
00256 {
00257   this->reset (0);
00258 }
00259 
00260 ACE_INLINE char*
00261 ACE_Auto_String_Free::operator* (void) const
00262 {
00263   return this->p_;
00264 }
00265 
00266 ACE_INLINE char
00267 ACE_Auto_String_Free::operator[] (int i) const
00268 {
00269   return this->p_[i];
00270 }
00271 
00272 ACE_INLINE char*
00273 ACE_Auto_String_Free::get (void) const
00274 {
00275   return this->p_;
00276 }
00277 
00278 ACE_INLINE char*
00279 ACE_Auto_String_Free::release (void)
00280 {
00281   char* p = this->p_;
00282   this->p_ = 0;
00283   return p;
00284 }

Generated on Mon Jun 16 11:21:24 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002