#include <String_Base.h>
Public Member Functions | |
ACE_String_Base (ACE_Allocator *the_allocator=0) | |
ACE_String_Base (const CHAR *s, ACE_Allocator *the_allocator=0, bool release=true) | |
ACE_String_Base (const CHAR *s, size_type len, ACE_Allocator *the_allocator=0, bool release=true) | |
ACE_String_Base (const ACE_String_Base< CHAR > &s) | |
ACE_String_Base (CHAR c, ACE_Allocator *the_allocator=0) | |
ACE_String_Base (size_type len, CHAR c=0, ACE_Allocator *the_allocator=0) | |
~ACE_String_Base (void) | |
const CHAR & | operator[] (size_type slot) const |
CHAR & | operator[] (size_type slot) |
ACE_String_Base< CHAR > & | operator= (const CHAR *s) |
ACE_String_Base< CHAR > & | operator= (const ACE_String_Base< CHAR > &s) |
ACE_String_Base< CHAR > & | assign_nocopy (const ACE_String_Base< CHAR > &s) |
void | set (const CHAR *s, bool release=true) |
void | set (const CHAR *s, size_type len, bool release) |
void | clear (bool release=false) |
void | fast_clear (void) |
ACE_String_Base< CHAR > | substring (size_type offset, size_type length=npos) const |
ACE_String_Base< CHAR > | substr (size_type offset, size_type length=npos) const |
ACE_String_Base< CHAR > & | operator+= (const ACE_String_Base< CHAR > &s) |
ACE_String_Base< CHAR > & | operator+= (const CHAR *s) |
ACE_String_Base< CHAR > & | operator+= (const CHAR c) |
ACE_String_Base< CHAR > & | append (const CHAR *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 |
CHAR * | rep (void) const |
const CHAR * | fast_rep (void) const |
const CHAR * | c_str (void) const |
size_type | strstr (const ACE_String_Base< CHAR > &s) const |
size_type | find (const ACE_String_Base< CHAR > &str, size_type pos=0) const |
size_type | find (const CHAR *s, size_type pos=0) const |
size_type | find (CHAR c, size_type pos=0) const |
size_type | rfind (CHAR c, size_type pos=npos) const |
bool | operator== (const ACE_String_Base< CHAR > &s) const |
bool | operator== (const CHAR *s) const |
bool | operator< (const ACE_String_Base< CHAR > &s) const |
bool | operator> (const ACE_String_Base< CHAR > &s) const |
bool | operator!= (const ACE_String_Base< CHAR > &s) const |
bool | operator!= (const CHAR *s) const |
int | compare (const ACE_String_Base< CHAR > &s) const |
void | dump (void) const |
void | resize (size_type len, CHAR c=0) |
void | fast_resize (size_t len) |
void | swap (ACE_String_Base< CHAR > &str) |
Swap the contents of this ACE_String_Base with str. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Protected Attributes | |
ACE_Allocator * | allocator_ |
size_type | len_ |
size_type | buf_len_ |
CHAR * | rep_ |
bool | release_ |
Static Protected Attributes | |
static CHAR | NULL_String_ = 0 |
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. ACE_String_Base< CHAR >::ACE_String_Base | ( | ACE_Allocator * | the_allocator = 0 |
) | [inline] |
Default constructor.
the_allocator | ACE_Allocator associated with string |
ACE_String_Base< CHAR >::ACE_String_Base | ( | const CHAR * | s, | |
ACE_Allocator * | the_allocator = 0 , |
|||
bool | release = true | |||
) | [inline] |
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. |
ACE_String_Base< CHAR >::ACE_String_Base | ( | const CHAR * | 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< CHAR >::ACE_String_Base | ( | const ACE_String_Base< CHAR > & | s | ) | [inline] |
ACE_String_Base< CHAR >::ACE_String_Base | ( | CHAR | c, | |
ACE_Allocator * | the_allocator = 0 | |||
) | [inline] |
Constructor that copies c into dynamically allocated memory.
c | Single input character. | |
the_allocator | ACE_Allocator associated with string |
ACE_String_Base< CHAR >::ACE_String_Base | ( | size_type | len, | |
CHAR | 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< CHAR >::~ACE_String_Base | ( | void | ) | [inline] |
Deletes the memory...
const CHAR& ACE_String_Base< CHAR >::operator[] | ( | size_type | slot | ) | const |
Return the <slot'th> character in the string (doesn't perform bounds checking).
slot | Index of the desired character |
CHAR& ACE_String_Base< CHAR >::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_String_Base< CHAR > & ACE_String_Base< CHAR >::operator= | ( | const CHAR * | s | ) | [inline] |
Assignment operator (does copy memory).
s | Input null-terminated CHAR string to assign to this object. |
ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::operator= | ( | const ACE_String_Base< CHAR > & | s | ) | [inline] |
Assignment operator (does copy memory).
s | Input ACE_String_Base string to assign to this object. |
ACE_INLINE ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::assign_nocopy | ( | const ACE_String_Base< CHAR > & | s | ) | [inline] |
Assignment alternative method (does not copy memory).
s | Input ACE_String_Base string to assign to this object. |
void ACE_String_Base< CHAR >::set | ( | const CHAR * | s, | |
bool | release = true | |||
) | [inline] |
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. |
void ACE_String_Base< CHAR >::set | ( | const CHAR * | 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. |
void ACE_String_Base< CHAR >::clear | ( | bool | release = false |
) | [inline] |
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. |
void ACE_String_Base< CHAR >::fast_clear | ( | void | ) | [inline] |
A more specialized version of clear(): "fast clear". fast_clear() resets the string to 0 length. If the string owns the buffer (
ACE_String_Base< CHAR > ACE_String_Base< CHAR >::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. |
ACE_String_Base< CHAR > ACE_String_Base< CHAR >::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< CHAR > & ACE_String_Base< CHAR >::operator+= | ( | const ACE_String_Base< CHAR > & | s | ) | [inline] |
Concat operator (copies memory).
s | Input ACE_String_Base string to concatenate to this string. |
ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::operator+= | ( | const CHAR * | s | ) | [inline] |
Concat operator (copies memory).
s | Input C string to concatenate to this string. |
ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::operator+= | ( | const CHAR | c | ) | [inline] |
Concat operator (copies memory).
c | Input CHAR to concatenate to this string. |
ACE_String_Base< CHAR >& ACE_String_Base< CHAR >::append | ( | const CHAR * | s, | |
size_type | slen | |||
) |
Append function (copies memory).
s | Input CHAR array to concatenate to this string. | |
slen | The length of the array. |
u_long ACE_String_Base< CHAR >::hash | ( | void | ) | const [inline] |
Returns a hash value for this string.
ACE_INLINE ACE_String_Base< CHAR >::size_type ACE_String_Base< CHAR >::length | ( | void | ) | const [inline] |
Return the length of the string.
ACE_INLINE size_t ACE_String_Base< CHAR >::capacity | ( | void | ) | const [inline] |
Return the number of allocated CHARs in the string object. This may be greater than the current length of the string.
ACE_INLINE bool ACE_String_Base< CHAR >::is_empty | ( | void | ) | const [inline] |
Return true
if the length of the string is zero, else false
.
ACE_INLINE bool ACE_String_Base< CHAR >::empty | ( | void | ) | const [inline] |
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.
CHAR * ACE_String_Base< CHAR >::rep | ( | void | ) | const [inline] |
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 []
ACE_INLINE const CHAR * ACE_String_Base< CHAR >::fast_rep | ( | void | ) | const [inline] |
Get at the underlying representation directly! _Don't_ even think about casting the result to (char *) and modifying it, if it has length 0!
ACE_INLINE const CHAR * ACE_String_Base< CHAR >::c_str | ( | void | ) | const [inline] |
Same as STL String's <c_str> and <fast_rep>.
ACE_INLINE ACE_String_Base< CHAR >::size_type ACE_String_Base< CHAR >::strstr | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
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). size_type ACE_String_Base< CHAR >::find | ( | const ACE_String_Base< CHAR > & | 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< CHAR >::find | ( | const CHAR * | 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< CHAR >::find | ( | CHAR | 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
. size_type ACE_String_Base< CHAR >::rfind | ( | CHAR | 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
. bool ACE_String_Base< CHAR >::operator== | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
Equality comparison operator (must match entire string).
s | Input ACE_String_Base string to compare against stored string. |
true
if equal, false
otherwise. bool ACE_String_Base< CHAR >::operator== | ( | const CHAR * | s | ) | const [inline] |
Equality comparison operator (must match entire string).
s | Null terminated string to compare against stored string. |
true
if equal, false
otherwise. ACE_INLINE bool ACE_String_Base< CHAR >::operator< | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
Less than comparison operator.
s | Input ACE_String_Base string to compare against stored string. |
true
if less than, false
otherwise. ACE_INLINE bool ACE_String_Base< CHAR >::operator> | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
Greater than comparison operator.
s | Input ACE_String_Base string to compare against stored string. |
true
if greater than, false
otherwise. ACE_INLINE bool ACE_String_Base< CHAR >::operator!= | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
Inequality comparison operator.
s | String to compare against stored string. |
true
if not equal, false
otherwise. ACE_INLINE bool ACE_String_Base< CHAR >::operator!= | ( | const CHAR * | s | ) | const [inline] |
Inequality comparison operator.
s | Null terminated string to compare against stored string. |
true
if not equal, false
otherwise. int ACE_String_Base< CHAR >::compare | ( | const ACE_String_Base< CHAR > & | s | ) | const [inline] |
Performs a strncmp comparison.
s | Input ACE_String_Base string to compare against stored string. |
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void ACE_String_Base< CHAR >::dump | ( | void | ) | const [inline] |
Dump the state of an object.
void ACE_String_Base< CHAR >::resize | ( | size_type | len, | |
CHAR | 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 CHAR to use when filling the string. |
void ACE_String_Base< CHAR >::fast_resize | ( | size_t | len | ) | [inline] |
void ACE_String_Base< CHAR >::swap | ( | ACE_String_Base< CHAR > & | str | ) | [inline] |
ACE_String_Base< CHAR >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
ACE_Allocator* ACE_String_Base< CHAR >::allocator_ [protected] |
Pointer to a memory allocator.
size_type ACE_String_Base< CHAR >::len_ [protected] |
Length of the ACE_String_Base data (not counting the trailing '').
size_type ACE_String_Base< CHAR >::buf_len_ [protected] |
Length of the ACE_String_Base data buffer. Keeping track of the length allows to avoid unnecessary dynamic allocations.
CHAR* ACE_String_Base< CHAR >::rep_ [protected] |
Pointer to data.
bool ACE_String_Base< CHAR >::release_ [protected] |
Flag that indicates if we own the memory
ACE_BEGIN_VERSIONED_NAMESPACE_DECL CHAR ACE_String_Base< CHAR >::NULL_String_ = 0 [inline, static, protected] |
Represents the "NULL" string to simplify the internal logic.