This class provides a wrapper facade for C strings. More...
#include <String_Base.h>
Public Types | |
typedef ACE_String_Base_Iterator < ACE_CHAR_T > | ITERATOR |
typedef ACE_String_Base_Const_Iterator < ACE_CHAR_T > | CONST_ITERATOR |
typedef ACE_String_Base_Iterator < ACE_CHAR_T > | iterator |
typedef ACE_String_Base_Const_Iterator < ACE_CHAR_T > | const_iterator |
typedef ACE_Allocator::size_type | size_type |
Public Member Functions | |
ACE_String_Base (ACE_Allocator *the_allocator=0) | |
ACE_String_Base (const ACE_CHAR_T *s, ACE_Allocator *the_allocator=0, bool release=true) | |
ACE_String_Base (const ACE_CHAR_T *s, size_type len, ACE_Allocator *the_allocator=0, bool release=true) | |
ACE_String_Base (const ACE_String_Base< ACE_CHAR_T > &s) | |
ACE_String_Base (ACE_CHAR_T c, ACE_Allocator *the_allocator=0) | |
ACE_String_Base (size_type len, ACE_CHAR_T c=0, ACE_Allocator *the_allocator=0) | |
~ACE_String_Base (void) | |
const ACE_CHAR_T & | operator[] (size_type slot) const |
ACE_CHAR_T & | operator[] (size_type slot) |
ACE_String_Base< ACE_CHAR_T > & | operator= (const ACE_CHAR_T *s) |
ACE_String_Base< ACE_CHAR_T > & | operator= (const ACE_String_Base< ACE_CHAR_T > &s) |
ACE_String_Base< ACE_CHAR_T > & | assign_nocopy (const ACE_String_Base< ACE_CHAR_T > &s) |
void | set (const ACE_CHAR_T *s, bool release=true) |
void | set (const ACE_CHAR_T *s, size_type len, bool release) |
void | clear (bool release=false) |
void | fast_clear (void) |
ACE_String_Base< ACE_CHAR_T > | substring (size_type offset, size_type length=npos) const |
ACE_String_Base< ACE_CHAR_T > | substr (size_type offset, size_type length=npos) const |
ACE_String_Base< ACE_CHAR_T > & | operator+= (const ACE_String_Base< ACE_CHAR_T > &s) |
ACE_String_Base< ACE_CHAR_T > & | operator+= (const ACE_CHAR_T *s) |
ACE_String_Base< ACE_CHAR_T > & | operator+= (const ACE_CHAR_T c) |
ACE_String_Base< ACE_CHAR_T > & | append (const ACE_CHAR_T *s, size_type slen) |
u_long | hash (void) const |
size_type | length (void) const |
size_t | capacity (void) const |
bool | is_empty (void) const |
bool | empty (void) const |
ACE_CHAR_T * | rep (void) const |
const ACE_CHAR_T * | fast_rep (void) const |
const ACE_CHAR_T * | c_str (void) const |
size_type | strstr (const ACE_String_Base< ACE_CHAR_T > &s) const |
size_type | find (const ACE_String_Base< ACE_CHAR_T > &str, size_type pos=0) const |
size_type | find (const ACE_CHAR_T *s, size_type pos=0) const |
size_type | find (ACE_CHAR_T c, size_type pos=0) const |
size_type | rfind (ACE_CHAR_T c, size_type pos=npos) const |
bool | operator== (const ACE_String_Base< ACE_CHAR_T > &s) const |
bool | operator== (const ACE_CHAR_T *s) const |
bool | operator< (const ACE_String_Base< ACE_CHAR_T > &s) const |
bool | operator> (const ACE_String_Base< ACE_CHAR_T > &s) const |
bool | operator!= (const ACE_String_Base< ACE_CHAR_T > &s) const |
bool | operator!= (const ACE_CHAR_T *s) const |
int | compare (const ACE_String_Base< ACE_CHAR_T > &s) const |
void | dump (void) const |
void | resize (size_type len, ACE_CHAR_T c=0) |
void | fast_resize (size_t len) |
void | swap (ACE_String_Base< ACE_CHAR_T > &str) |
Swap the contents of this ACE_String_Base with str. | |
iterator | begin (void) |
const_iterator | begin (void) const |
iterator | end (void) |
const_iterator | end (void) const |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Protected Attributes | |
ACE_Allocator * | allocator_ |
size_type | len_ |
size_type | buf_len_ |
ACE_CHAR_T * | rep_ |
bool | release_ |
Static Protected Attributes | |
static ACE_CHAR_T | NULL_String_ = 0 |
Friends | |
class | ACE_String_Base_Iterator< ACE_CHAR_T > |
class | ACE_String_Base_Const_Iterator< ACE_CHAR_T > |
This class provides a wrapper facade for C strings.
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. This class is optimized for efficiency, so it doesn't provide any internal locking.
typedef
found in all ACE string classes. This typedef is analogous to the "@c size_type" typedef
found in the standard C++ string class as well as many STL class templates. If you find yourself casting you're probably doing something wrong. Definition at line 67 of file String_Base.h.
typedef ACE_String_Base_Const_Iterator<ACE_CHAR_T> ACE_String_Base< ACE_CHAR_T >::CONST_ITERATOR |
Definition at line 77 of file String_Base.h.
typedef ACE_String_Base_Const_Iterator<ACE_CHAR_T> ACE_String_Base< ACE_CHAR_T >::const_iterator |
Definition at line 81 of file String_Base.h.
typedef ACE_String_Base_Iterator<ACE_CHAR_T> ACE_String_Base< ACE_CHAR_T >::ITERATOR |
Definition at line 76 of file String_Base.h.
typedef ACE_String_Base_Iterator<ACE_CHAR_T> ACE_String_Base< ACE_CHAR_T >::iterator |
Definition at line 80 of file String_Base.h.
typedef ACE_Allocator::size_type ACE_String_Base_Const::size_type |
Definition at line 41 of file String_Base_Const.h.
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | ACE_Allocator * | the_allocator = 0 |
) |
Default constructor.
the_allocator | ACE_Allocator associated with string |
Definition at line 28 of file String_Base.cpp.
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()), len_ (0), buf_len_ (0), rep_ (&ACE_String_Base<ACE_CHAR_T>::NULL_String_), release_ (false) { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::ACE_String_Base"); }
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | const ACE_CHAR_T * | s, | |
ACE_Allocator * | the_allocator = 0 , |
|||
bool | release = true | |||
) |
Constructor that copies s into dynamically allocated memory.
if release == true then a new buffer is allocated internally, and s is copied to the internal buffer. if release == false then the s buffer is used directly. If s == 0 then it will _not_ be used, and instead the internal buffer is set to NULL_String_.
s | Zero terminated input string | |
the_allocator | ACE_Allocator associated with string | |
release | Allocator responsible(true)/not reponsible(false) for freeing memory. |
Definition at line 41 of file String_Base.cpp.
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()), len_ (0), buf_len_ (0), rep_ (0), release_ (false) { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::ACE_String_Base"); this->set (s, release); }
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | const ACE_CHAR_T * | s, | |
size_type | len, | |||
ACE_Allocator * | the_allocator = 0 , |
|||
bool | release = true | |||
) |
Constructor that copies len CHARs of s into dynamically allocated memory (will zero terminate the result).
if release == true then a new buffer is allocated internally. s is copied to the internal buffer. if release == false then the s buffer is used directly. If s == 0 then it will _not_ be used, and instead the internal buffer is set to NULL_String_.
s | Non-zero terminated input string | |
len | Length of non-zero terminated input string | |
the_allocator | ACE_Allocator associated with string | |
release | Allocator responsible(true)/not reponsible(false) for freeing memory. |
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) |
Copy constructor.
s | Input ACE_String_Base string to copy |
Definition at line 90 of file String_Base.cpp.
: allocator_ (s.allocator_ ? s.allocator_ : ACE_Allocator::instance ()), len_ (0), buf_len_ (0), rep_ (0), release_ (false) { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::ACE_String_Base"); this->set (s.rep_, s.len_, true); }
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | ACE_CHAR_T | c, | |
ACE_Allocator * | the_allocator = 0 | |||
) |
Constructor that copies c into dynamically allocated memory.
c | Single input character. | |
the_allocator | ACE_Allocator associated with string |
Definition at line 55 of file String_Base.cpp.
: allocator_ (the_allocator ? the_allocator : ACE_Allocator::instance ()), len_ (0), buf_len_ (0), rep_ (0), release_ (false) { ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::ACE_String_Base"); this->set (&c, 1, true); }
ACE_String_Base< ACE_CHAR_T >::ACE_String_Base | ( | size_type | len, | |
ACE_CHAR_T | c = 0 , |
|||
ACE_Allocator * | the_allocator = 0 | |||
) |
Constructor that allocates a len long string.
Warning : This constructor was incorrectly documented in the past. It simply calls resize(len, c). It is probably not advisable to use the second parameter. See resize() for more information.
len | Amount of space to reserve for the string. | |
c | The array is filled with c's | |
the_allocator | ACE_Allocator associated with string |
ACE_String_Base< ACE_CHAR_T >::~ACE_String_Base | ( | void | ) |
Deletes the memory...
Definition at line 119 of file String_Base.cpp.
ACE_String_Base< ACE_CHAR_T >& ACE_String_Base< ACE_CHAR_T >::append | ( | const ACE_CHAR_T * | s, | |
size_type | slen | |||
) |
Append function (copies memory).
s | Input ACE_CHAR_T array to concatenate to this string. | |
slen | The length of the array. |
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::assign_nocopy | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) |
Assignment alternative method (does not copy memory).
s | Input ACE_String_Base string to assign to this object. |
Definition at line 22 of file String_Base.inl.
ACE_String_Base< ACE_CHAR_T >::iterator ACE_String_Base< ACE_CHAR_T >::begin | ( | void | ) |
Definition at line 146 of file String_Base.inl.
ACE_String_Base< ACE_CHAR_T >::const_iterator ACE_String_Base< ACE_CHAR_T >::begin | ( | void | ) | const |
Definition at line 153 of file String_Base.inl.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::begin"); return const_iterator (*this); }
const ACE_CHAR_T * ACE_String_Base< ACE_CHAR_T >::c_str | ( | void | ) | const |
Same as STL String's <c_str> and <fast_rep>.
Definition at line 91 of file String_Base.inl.
{ return this->rep_; }
size_t ACE_String_Base< ACE_CHAR_T >::capacity | ( | void | ) | const |
Return the number of allocated CHARs in the string object. This may be greater than the current length of the string.
Definition at line 37 of file String_Base.inl.
void ACE_String_Base< ACE_CHAR_T >::clear | ( | bool | release = false |
) |
Clear this string. Memory is _not_ freed if release is false.
Warning: This method was incorrectly documented in the past, but the current implementation has been changed to match the documented behavior.
Warning: clear(false) behaves like fast_clear() below.
release | Memory is freed if true, and not freed if false. |
Definition at line 296 of file String_Base.cpp.
{ // This can't use set(), because that would free memory if release=false if (release) { if (this->buf_len_ != 0 && this->release_) this->allocator_->free (this->rep_); this->rep_ = &ACE_String_Base<ACE_CHAR_T>::NULL_String_; this->len_ = 0; this->buf_len_ = 0; this->release_ = false; } else { this->fast_clear (); } }
int ACE_String_Base< ACE_CHAR_T >::compare | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Performs a strncmp comparison.
s | Input ACE_String_Base string to compare against stored string. |
Definition at line 383 of file String_Base.cpp.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::compare"); if (this->rep_ == s.rep_) return 0; // Pick smaller of the two lengths and perform the comparison. size_type smaller_length = ace_min (this->len_, s.len_); int result = ACE_OS::memcmp (this->rep_, s.rep_, smaller_length * sizeof (ACE_CHAR_T)); if (result == 0 && this->len_ != s.len_) result = this->len_ > s.len_ ? 1 : -1; return result; }
void ACE_String_Base< ACE_CHAR_T >::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 13 of file String_Base.inl.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::dump"); #endif /* ACE_HAS_DUMP */ }
bool ACE_String_Base< ACE_CHAR_T >::empty | ( | void | ) | const |
Return true
if the length of the string is zero, else false
. We recommend using is_empty()
instead since it's more consistent with the ACE container naming conventions.
Definition at line 50 of file String_Base.inl.
{ return this->is_empty (); }
ACE_String_Base< ACE_CHAR_T >::iterator ACE_String_Base< ACE_CHAR_T >::end | ( | void | ) |
Definition at line 160 of file String_Base.inl.
ACE_String_Base< ACE_CHAR_T >::const_iterator ACE_String_Base< ACE_CHAR_T >::end | ( | void | ) | const |
Definition at line 167 of file String_Base.inl.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::end"); return const_iterator (*this, 1); }
void ACE_String_Base< ACE_CHAR_T >::fast_clear | ( | void | ) |
A more specialized version of clear(): "fast clear". fast_clear() resets the string to 0 length. If the string owns the buffer (
If
Warning : Calling clear(false) or fast_clear() can have unintended side-effects if the string was constructed (or set()) with an external buffer. The string will be disassociated with the buffer and the next append() or +=() will cause a new buffer to be allocated internally.
Definition at line 351 of file String_Base.cpp.
{ this->len_ = 0; if (this->release_) { // String retains the original buffer. if (this->rep_ != &ACE_String_Base<ACE_CHAR_T>::NULL_String_) this->rep_[0] = 0; } else { // External buffer: string relinquishes control of it. this->buf_len_ = 0; this->rep_ = &ACE_String_Base<ACE_CHAR_T>::NULL_String_; } }
const ACE_CHAR_T * ACE_String_Base< ACE_CHAR_T >::fast_rep | ( | void | ) | const |
Get at the underlying representation directly! _Don't_ even think about casting the result to (char *) and modifying it, if it has length 0!
Definition at line 85 of file String_Base.inl.
{ return this->rep_; }
void ACE_String_Base< ACE_CHAR_T >::fast_resize | ( | size_t | len | ) |
Definition at line 275 of file String_Base.cpp.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::fast_resize"); // Only reallocate if we don't have enough space... if (this->buf_len_ <= len) { if (this->buf_len_ != 0 && this->release_) this->allocator_->free (this->rep_); this->rep_ = static_cast<ACE_CHAR_T*> (this->allocator_->malloc ((len + 1) * sizeof (ACE_CHAR_T))); this->buf_len_ = len + 1; this->release_ = true; } this->len_ = 0; if (len > 0) this->rep_[0] = 0; }
size_type ACE_String_Base< ACE_CHAR_T >::find | ( | const ACE_String_Base< ACE_CHAR_T > & | str, | |
size_type | pos = 0 | |||
) | const |
Find <str> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos
.
str | Input ACE_String_Base string to search for in stored string. | |
pos | Starting index position to start searching for string str. |
npos
. size_type ACE_String_Base< ACE_CHAR_T >::find | ( | const ACE_CHAR_T * | s, | |
size_type | pos = 0 | |||
) | const |
Find s starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos
.
s | non-zero input string to search for in stored string. | |
pos | Starting index position to start searching for string str. |
npos
. size_type ACE_String_Base< ACE_CHAR_T >::find | ( | ACE_CHAR_T | c, | |
size_type | pos = 0 | |||
) | const |
Find c starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos
.
c | Input character to search for in stored string. | |
pos | Starting index position to start searching for string str. |
npos
. u_long ACE_String_Base< ACE_CHAR_T >::hash | ( | void | ) | const |
Returns a hash value for this string.
Definition at line 256 of file String_Base.cpp.
{ return ACE::hash_pjw (reinterpret_cast<char *> ( const_cast<ACE_CHAR_T *> (this->rep_)), this->len_ * sizeof (ACE_CHAR_T)); }
bool ACE_String_Base< ACE_CHAR_T >::is_empty | ( | void | ) | const |
Return true
if the length of the string is zero, else false
.
Definition at line 44 of file String_Base.inl.
{ return this->len_ == 0; }
ACE_String_Base< ACE_CHAR_T >::size_type ACE_String_Base< ACE_CHAR_T >::length | ( | void | ) | const |
Return the length of the string.
Definition at line 30 of file String_Base.inl.
bool ACE_String_Base< ACE_CHAR_T >::operator!= | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Inequality comparison operator.
s | String to compare against stored string. |
true
if not equal, false
otherwise. Definition at line 118 of file String_Base.inl.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator!="); return !(*this == s); }
bool ACE_String_Base< ACE_CHAR_T >::operator!= | ( | const ACE_CHAR_T * | s | ) | const |
Inequality comparison operator.
s | Null terminated string to compare against stored string. |
true
if not equal, false
otherwise. Definition at line 125 of file String_Base.inl.
{ return !(*this == s); }
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::operator+= | ( | const ACE_CHAR_T * | s | ) |
Concat operator (copies memory).
s | Input C string to concatenate to this string. |
Definition at line 636 of file String_Base.cpp.
{ size_t slen = 0; if (s != 0) slen = ACE_OS::strlen (s); return this->append (s, slen); }
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::operator+= | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) |
Concat operator (copies memory).
s | Input ACE_String_Base string to concatenate to this string. |
Definition at line 646 of file String_Base.cpp.
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::operator+= | ( | const ACE_CHAR_T | c | ) |
Concat operator (copies memory).
c | Input ACE_CHAR_T to concatenate to this string. |
Definition at line 654 of file String_Base.cpp.
bool ACE_String_Base< ACE_CHAR_T >::operator< | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Less than comparison operator.
s | Input ACE_String_Base string to compare against stored string. |
true
if less than, false
otherwise. Definition at line 99 of file String_Base.inl.
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::operator= | ( | const ACE_CHAR_T * | s | ) |
Assignment operator (does copy memory).
s | Input null-terminated ACE_CHAR_T string to assign to this object. |
Definition at line 317 of file String_Base.cpp.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::operator="); if (s != 0) this->set (s, true); return *this; }
ACE_String_Base< ACE_CHAR_T > & ACE_String_Base< ACE_CHAR_T >::operator= | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) |
Assignment operator (does copy memory).
s | Input ACE_String_Base string to assign to this object. |
Definition at line 327 of file String_Base.cpp.
bool ACE_String_Base< ACE_CHAR_T >::operator== | ( | const ACE_CHAR_T * | s | ) | const |
Equality comparison operator (must match entire string).
s | Null terminated string to compare against stored string. |
true
if equal, false
otherwise. Definition at line 414 of file String_Base.cpp.
{ size_t len = ACE_OS::strlen (s); return this->len_ == len && ACE_OS::memcmp (this->rep_, s, len * sizeof (ACE_CHAR_T)) == 0; }
bool ACE_String_Base< ACE_CHAR_T >::operator== | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Equality comparison operator (must match entire string).
s | Input ACE_String_Base string to compare against stored string. |
true
if equal, false
otherwise. Definition at line 405 of file String_Base.cpp.
{ return this->len_ == s.len_ && ACE_OS::memcmp (this->rep_, s.rep_, this->len_ * sizeof (ACE_CHAR_T)) == 0; }
bool ACE_String_Base< ACE_CHAR_T >::operator> | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Greater than comparison operator.
s | Input ACE_String_Base string to compare against stored string. |
true
if greater than, false
otherwise. Definition at line 108 of file String_Base.inl.
const ACE_CHAR_T& ACE_String_Base< ACE_CHAR_T >::operator[] | ( | size_type | slot | ) | const |
Return the <slot'th> character in the string (doesn't perform bounds checking).
slot | Index of the desired character |
ACE_CHAR_T& ACE_String_Base< ACE_CHAR_T >::operator[] | ( | size_type | slot | ) |
Return the <slot'th> character by reference in the string (doesn't perform bounds checking).
slot | Index of the desired character |
ACE_CHAR_T * ACE_String_Base< ACE_CHAR_T >::rep | ( | void | ) | const |
Get a copy of the underlying representation.
This method allocates memory for a copy of the string and returns a pointer to the new area. The caller is responsible for freeing the memory when finished; use delete []
Definition at line 371 of file String_Base.cpp.
{ ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::rep"); ACE_CHAR_T *new_string; ACE_NEW_RETURN (new_string, ACE_CHAR_T[this->len_ + 1], 0); ACE_OS::strsncpy (new_string, this->rep_, this->len_+1); return new_string; }
void ACE_String_Base< ACE_CHAR_T >::resize | ( | size_type | len, | |
ACE_CHAR_T | c = 0 | |||
) |
This method is designed for high-performance. Please use with care ;-)
Warning : This method was documented incorrectly in the past. The original intention was to change the length of the string to len, and to fill the whole thing with c CHARs. However, what was actually done was to set the length of the string to zero, and fill the buffer with c's. The buffer was also not null-terminated unless c happened to be zero. Rather than fix the method to work as documented, the code is left as is, but the second parameter should probably not be used.
fast_resize just adjusts the buffer if needed and sets the length, it doesn't fill the buffer, so is much faster.
len | The number of CHARs to reserve | |
c | The ACE_CHAR_T to use when filling the string. |
size_type ACE_String_Base< ACE_CHAR_T >::rfind | ( | ACE_CHAR_T | c, | |
size_type | pos = npos | |||
) | const |
Find c starting at pos (counting from the end). Returns the slot of the first location that matches, else npos
.
c | Input character to search for in stored string. | |
pos | Starting index position to start searching for string str. |
npos
. void ACE_String_Base< ACE_CHAR_T >::set | ( | const ACE_CHAR_T * | s, | |
bool | release = true | |||
) |
Copy s into this ACE_String_Base.
If release == true then a new buffer is allocated internally if the existing one is not big enough to hold s. If the existing buffer is big enough, then it will be used. This means that set(*, 1) can be illegal when the string is constructed with a const char*. (e.g. ACE_String_Base("test", 0, false)).
if release == false then the s buffer is used directly, and any existing buffer is destroyed. If s == 0 then it will _not_ be used, and instead the internal buffer is set to NULL_String_.
s | Null terminated input string | |
release | Allocator responsible(true)/not reponsible(false) for freeing memory. |
Definition at line 341 of file String_Base.cpp.
{ size_t length = 0; if (s != 0) length = ACE_OS::strlen (s); this->set (s, length, release); }
void ACE_String_Base< ACE_CHAR_T >::set | ( | const ACE_CHAR_T * | s, | |
size_type | len, | |||
bool | release | |||
) |
Copy len bytes of s (will zero terminate the result).
If release == true then a new buffer is allocated internally if the existing one is not big enough to hold s. If the existing buffer is big enough, then it will be used. This means that set(*, *, 1) is illegal when the string is constructed with a non-owned const char*. (e.g. ACE_String_Base("test", 0, 0))
If release == false then the s buffer is used directly, and any existing buffer is destroyed. If s == 0 then it will _not_ be used, and instead the internal buffer is set to NULL_String_.
s | Non-zero terminated input string | |
len | Length of input string 's' | |
release | Allocator responsible(true)/not reponsible(false) for freeing memory. |
ACE_String_Base< ACE_CHAR_T >::size_type ACE_String_Base< ACE_CHAR_T >::strstr | ( | const ACE_String_Base< ACE_CHAR_T > & | s | ) | const |
Comparison operator that will match substrings. Returns the slot of the first location that matches, else npos
.
s | Input ACE_String_Base string |
npos
(not found). Definition at line 139 of file String_Base.inl.
ACE_String_Base< ACE_CHAR_T > ACE_String_Base< ACE_CHAR_T >::substr | ( | size_type | offset, | |
size_type | length = npos | |||
) | const |
Same as <substring>.
offset | Index of first desired character of the substring. | |
length | How many characters to return starting at the offset. |
ACE_String_Base< ACE_CHAR_T > ACE_String_Base< ACE_CHAR_T >::substring | ( | size_type | offset, | |
size_type | length = npos | |||
) | const |
Return a substring given an offset and length. If length == npos
use rest of str. Return empty substring if offset or offset/length are invalid.
offset | Index of first desired character of the substring. | |
length | How many characters to return starting at the offset. |
void ACE_String_Base< ACE_CHAR_T >::swap | ( | ACE_String_Base< ACE_CHAR_T > & | str | ) |
Swap the contents of this ACE_String_Base
with str.
Definition at line 468 of file String_Base.cpp.
friend class ACE_String_Base_Const_Iterator< ACE_CHAR_T > [friend] |
Definition at line 73 of file String_Base.h.
friend class ACE_String_Base_Iterator< ACE_CHAR_T > [friend] |
Definition at line 72 of file String_Base.h.
ACE_String_Base< ACE_CHAR_T >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Definition at line 560 of file String_Base.h.
ACE_Allocator* ACE_String_Base< ACE_CHAR_T >::allocator_ [protected] |
Pointer to a memory allocator.
Definition at line 566 of file String_Base.h.
size_type ACE_String_Base< ACE_CHAR_T >::buf_len_ [protected] |
Length of the ACE_String_Base data buffer. Keeping track of the length allows to avoid unnecessary dynamic allocations.
Definition at line 577 of file String_Base.h.
size_type ACE_String_Base< ACE_CHAR_T >::len_ [protected] |
Length of the ACE_String_Base data (not counting the trailing '').
Definition at line 571 of file String_Base.h.
ACE_CHAR_T ACE_String_Base< ACE_CHAR_T >::NULL_String_ = 0 [static, protected] |
Represents the "NULL" string to simplify the internal logic.
Definition at line 592 of file String_Base.h.
bool ACE_String_Base< ACE_CHAR_T >::release_ [protected] |
Flag that indicates if we own the memory
Definition at line 587 of file String_Base.h.
ACE_CHAR_T* ACE_String_Base< ACE_CHAR_T >::rep_ [protected] |
Pointer to data.
Definition at line 582 of file String_Base.h.