#include <SString.h>
Collaboration diagram for ACE_SString:

| Public Member Functions | |
| ACE_SString (ACE_Allocator *alloc=0) | |
| Default constructor. | |
| ACE_SString (const char *s, ACE_Allocator *alloc=0) | |
| Constructor that copies s into dynamically allocated memory. | |
| ACE_SString (const char *s, size_t len, ACE_Allocator *alloc=0) | |
| ACE_SString (const ACE_SString &) | |
| Copy constructor. | |
| ACE_SString (char c, ACE_Allocator *alloc=0) | |
| Constructor that copies c into dynamically allocated memory. | |
| ~ACE_SString (void) | |
| Default destructor. | |
| char | operator[] (size_t slot) const | 
| char & | operator[] (size_t slot) | 
| ACE_SString & | operator= (const ACE_SString &) | 
| Assignment operator (does copy memory). | |
| ACE_SString | substring (size_t offset, ssize_t length=-1) const | 
| ACE_SString | substr (size_t offset, ssize_t length=-1) const | 
| Same as substring. | |
| u_long | hash (void) const | 
| Returns a hash value for this string. | |
| size_t | length (void) const | 
| Return the length of the string. | |
| void | rep (char *s) | 
| const char * | rep (void) const | 
| Get the underlying pointer. | |
| const char * | fast_rep (void) const | 
| Get the underlying pointer. | |
| const char * | c_str (void) const | 
| Same as STL String's  and . | |
| int | strstr (const ACE_SString &s) const | 
| int | find (const ACE_SString &str, int pos=0) const | 
| int | find (const char *s, int pos=0) const | 
| int | find (char c, int pos=0) const | 
| int | rfind (char c, int pos=npos) const | 
| bool | operator== (const ACE_SString &s) const | 
| Equality comparison operator (must match entire string). | |
| bool | operator< (const ACE_SString &s) const | 
| Less than comparison operator. | |
| bool | operator> (const ACE_SString &s) const | 
| Greater than comparison operator. | |
| bool | operator!= (const ACE_SString &s) const | 
| Inequality comparison operator. | |
| int | compare (const ACE_SString &s) const | 
| Performs a -style comparison. | |
| void | dump (void) const | 
| Dump the state of an object. | |
| Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
| Static Public Attributes | |
| const int | npos = -1 | 
| No position constant. | |
| Private Attributes | |
| ACE_Allocator * | allocator_ | 
| Pointer to a memory allocator. | |
| size_t | len_ | 
| Length of the ACE_SString (not counting the trailing ''). | |
| char * | rep_ | 
| Pointer to data. | |
This class is optimized for efficiency, so it doesn't provide any internal locking. CAUTION: This class is only intended for use with applications that understand how it works. In particular, its destructor does not deallocate its memory when it is destroyed... We need this class since the ACE_Map_Manager requires an object that supports the operator == and operator !=. This class uses an ACE_Allocator to allocate memory. The user can make this a persistant class by providing an ACE_Allocator with a persistable memory pool.
Definition at line 124 of file SString.h.
| 
 | 
| Default constructor. 
 Definition at line 191 of file SString.cpp. References ACE_TRACE, ACE_Allocator::instance(), and ACE_Allocator::malloc(). Referenced by substring(). 
 00192 : allocator_ (alloc), 00193 len_ (0), 00194 rep_ (0) 00195 00196 { 00197 ACE_TRACE ("ACE_SString::ACE_SString"); 00198 00199 if (this->allocator_ == 0) 00200 this->allocator_ = ACE_Allocator::instance (); 00201 00202 this->len_ = 0; 00203 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00204 this->rep_[this->len_] = '\0'; 00205 } | 
| 
 | ||||||||||||
| Constructor that copies s into dynamically allocated memory. 
 Definition at line 224 of file SString.cpp. References ACE_TRACE, ACE_Allocator::instance(), ACE_Allocator::malloc(), ACE_OS::strcpy(), and ACE_OS::strlen(). 
 00226 : allocator_ (alloc) 00227 { 00228 ACE_TRACE ("ACE_SString::ACE_SString"); 00229 00230 if (this->allocator_ == 0) 00231 this->allocator_ = ACE_Allocator::instance (); 00232 00233 if (s == 0) 00234 { 00235 this->len_ = 0; 00236 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00237 this->rep_[this->len_] = '\0'; 00238 } 00239 else 00240 { 00241 this->len_ = ACE_OS::strlen (s); 00242 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00243 ACE_OS::strcpy (this->rep_, s); 00244 } 00245 } | 
| 
 | ||||||||||||||||
| Constructor that copies len chars of into dynamically allocated memory (will NUL terminate the result). Definition at line 264 of file SString.cpp. References ACE_TRACE, ACE_Allocator::instance(), ACE_Allocator::malloc(), and ACE_OS::memcpy(). 
 00267 : allocator_ (alloc) 00268 { 00269 ACE_TRACE ("ACE_SString::ACE_SString"); 00270 00271 if (this->allocator_ == 0) 00272 this->allocator_ = ACE_Allocator::instance (); 00273 00274 if (s == 0) 00275 { 00276 this->len_ = 0; 00277 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00278 this->rep_[this->len_] = '\0'; 00279 } 00280 else 00281 { 00282 this->len_ = len; 00283 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00284 ACE_OS::memcpy (this->rep_, s, len); 00285 this->rep_[len] = '\0'; // Make sure to NUL terminate this! 00286 } 00287 } | 
| 
 | 
| Copy constructor. 
 Definition at line 173 of file SString.cpp. References ACE_TRACE, ACE_Allocator::instance(), len_, ACE_Allocator::malloc(), ACE_OS::memcpy(), and rep_. 
 00174 : allocator_ (s.allocator_), 00175 len_ (s.len_) 00176 { 00177 ACE_TRACE ("ACE_SString::ACE_SString"); 00178 00179 if (this->allocator_ == 0) 00180 this->allocator_ = ACE_Allocator::instance (); 00181 00182 this->rep_ = (char *) this->allocator_->malloc (s.len_ + 1); 00183 ACE_OS::memcpy ((void *) this->rep_, 00184 (const void *) s.rep_, 00185 this->len_); 00186 this->rep_[this->len_] = '\0'; 00187 } | 
| 
 | ||||||||||||
| Constructor that copies c into dynamically allocated memory. 
 Definition at line 247 of file SString.cpp. References ACE_TRACE, ACE_Allocator::instance(), and ACE_Allocator::malloc(). 
 00249 : allocator_ (alloc) 00250 { 00251 ACE_TRACE ("ACE_SString::ACE_SString"); 00252 00253 if (this->allocator_ == 0) 00254 this->allocator_ = ACE_Allocator::instance (); 00255 00256 this->len_ = 1; 00257 this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1); 00258 this->rep_[0] = c; 00259 this->rep_[this->len_] = '\0'; 00260 } | 
| 
 | 
| Default destructor. 
 Definition at line 66 of file SString.inl. 
 00067 {
00068 }
 | 
| 
 | 
| Same as STL String's and . 
 Definition at line 116 of file SString.inl. References ACE_TRACE. 
 | 
| 
 | 
| Performs a -style comparison. 
 Definition at line 166 of file SString.inl. References ACE_TRACE, rep_, and ACE_OS::strcmp(). 
 00167 {
00168   ACE_TRACE ("ACE_SString::compare");
00169   return ACE_OS::strcmp (this->rep_, s.rep_);
00170 }
 | 
| 
 | 
| Dump the state of an object. 
 Definition at line 164 of file SString.cpp. References ACE_TRACE. 
 00165 {
00166 #if defined (ACE_HAS_DUMP)
00167   ACE_TRACE ("ACE_SString::dump");
00168 #endif /* ACE_HAS_DUMP */
00169 }
 | 
| 
 | 
| Get the underlying pointer. 
 Definition at line 107 of file SString.inl. References ACE_TRACE. Referenced by operator<<(). 
 | 
| 
 | ||||||||||||
| Find starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. Definition at line 184 of file SString.inl. References npos, ACE_OS::strchr(), and substr(). 
 00185 {
00186   char *substr = this->rep_ + pos;
00187   char *pointer = ACE_OS::strchr (substr, c);
00188   if (pointer == 0)
00189     return ACE_SString::npos;
00190   else
00191     return pointer - this->rep_;
00192 }
 | 
| 
 | ||||||||||||
| Find starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. Definition at line 173 of file SString.inl. References npos, ACE_OS::strstr(), and substr(). 
 00174 {
00175   char *substr = this->rep_ + pos;
00176   char *pointer = ACE_OS::strstr (substr, s);
00177   if (pointer == 0)
00178     return ACE_SString::npos;
00179   else
00180     return pointer - this->rep_;
00181 }
 | 
| 
 | ||||||||||||
| Find starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. Definition at line 203 of file SString.inl. References rep_. Referenced by strstr(). 
 | 
| 
 | 
| Returns a hash value for this string. 
 Definition at line 222 of file SString.inl. References ACE::hash_pjw(). 
 00223 {
00224   return ACE::hash_pjw (this->rep_);
00225 }
 | 
| 
 | 
| Return the length of the string. 
 Definition at line 228 of file SString.inl. References ACE_TRACE. 
 | 
| 
 | 
| Inequality comparison operator. 
 Definition at line 159 of file SString.inl. References ACE_TRACE. 
 00160 {
00161   ACE_TRACE ("ACE_SString::operator!=");
00162   return !(*this == s);
00163 }
 | 
| 
 | 
| Less than comparison operator. 
 Definition at line 135 of file SString.inl. References ACE_TRACE, rep_, and ACE_OS::strcmp(). 
 | 
| 
 | 
| Assignment operator (does copy memory). 
 Definition at line 292 of file SString.cpp. References ACE_TRACE, ACE_Allocator::free(), len_, ACE_Allocator::malloc(), rep_, and ACE_OS::strcpy(). 
 00293 {
00294   ACE_TRACE ("ACE_SString::operator=");
00295   // Check for identify.
00296 
00297   if (this != &s)
00298     {
00299       // Only reallocate if we don't have enough space...
00300       if (this->len_ < s.len_)
00301         {
00302           this->allocator_->free (this->rep_);
00303           this->rep_ = (char *) this->allocator_->malloc (s.len_ + 1);
00304         }
00305       this->len_ = s.len_;
00306       ACE_OS::strcpy (this->rep_, s.rep_);
00307     }
00308 
00309   return *this;
00310 }
 | 
| 
 | 
| Equality comparison operator (must match entire string). 
 Definition at line 125 of file SString.inl. References ACE_TRACE, len_, rep_, and ACE_OS::strcmp(). 
 00126 {
00127   ACE_TRACE ("ACE_SString::operator==");
00128   return this->len_ == s.len_
00129     && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
00130 }
 | 
| 
 | 
| Greater than comparison operator. 
 Definition at line 147 of file SString.inl. References ACE_TRACE, rep_, and ACE_OS::strcmp(). 
 | 
| 
 | 
| Return the <slot'th> character by reference in the string (doesn't perform bounds checking). Definition at line 89 of file SString.inl. References ACE_TRACE. 
 | 
| 
 | 
| Return the <slot'th> character in the string (doesn't perform bounds checking). Definition at line 80 of file SString.inl. References ACE_TRACE. 
 | 
| 
 | 
| Get the underlying pointer. 
 Definition at line 98 of file SString.inl. References ACE_TRACE. 
 | 
| 
 | 
| Set the underlying pointer. Since this does not copy memory or delete existing memory use with extreme caution!!! Definition at line 210 of file SString.cpp. References ACE_TRACE, and ACE_OS::strlen(). 
 00211 {
00212   ACE_TRACE ("ACE_SString::rep");
00213 
00214   this->rep_ = s;
00215 
00216   if (s == 0)
00217     this->len_ = 0;
00218   else
00219     this->len_ = ACE_OS::strlen (s);
00220 }
 | 
| 
 | ||||||||||||
| Find starting at pos (counting from the end). Returns the slot of the first location that matches, else npos. Definition at line 209 of file SString.inl. References npos. 
 00210 {
00211   if (pos == ACE_SString::npos)
00212     pos = static_cast<int> (this->len_);
00213 
00214   for (int i = pos - 1; i >= 0; i--)
00215     if (this->rep_[i] == c)
00216       return i;
00217 
00218   return ACE_SString::npos;
00219 }
 | 
| 
 | 
| Comparison operator that will match substrings. Returns the slot of the first location that matches, else -1. Definition at line 195 of file SString.inl. References ACE_TRACE, find(), and rep_. 
 | 
| 
 | ||||||||||||
| Same as substring. 
 Definition at line 71 of file SString.inl. References ssize_t, and substring(). Referenced by find(). 
 00073 {
00074   return this->substring (offset, length);
00075 }
 | 
| 
 | ||||||||||||
| Return a substring given an offset and length, if length == -1 use rest of str return empty substring if offset or offset/length are invalid Definition at line 314 of file SString.cpp. References ACE_SString(), and ssize_t. Referenced by substr(). 
 00316 {
00317   ACE_SString nill;
00318   size_t count = length;
00319 
00320   // case 1. empty string
00321   if (len_ == 0)
00322     return nill;
00323 
00324   // case 2. start pos l
00325   if (offset >= len_)
00326     return nill;
00327 
00328   // get all remaining bytes
00329   if (length == -1 || count > (this->len_ - offset))
00330     count = len_ - offset;
00331 
00332   return ACE_SString (&rep_[offset], count, this->allocator_);
00333 }
 | 
| 
 | 
| Declare the dynamic allocation hooks. 
 | 
| 
 | 
| Pointer to a memory allocator. 
 | 
| 
 | 
| Length of the ACE_SString (not counting the trailing ''). 
 Definition at line 235 of file SString.h. Referenced by ACE_SString(), operator=(), and operator==(). | 
| 
 | 
| No position constant. 
 Definition at line 159 of file SString.cpp. | 
| 
 | 
| Pointer to data. 
 Definition at line 238 of file SString.h. Referenced by ACE_SString(), compare(), find(), operator<(), operator=(), operator==(), operator>(), and strstr(). | 
 1.3.6
 
1.3.6