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

ACE_String_Base Class Template Reference

This class provides a wrapper facade for C strings. More...

#include <String_Base.h>

Inheritance diagram for ACE_String_Base:

Inheritance graph
[legend]
Collaboration diagram for ACE_String_Base:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_String_Base (ACE_Allocator *alloc=0)
 Default constructor. More...

 ACE_String_Base (const CHAR *s, ACE_Allocator *alloc=0, int release=1)
 ACE_String_Base (const CHAR *s, size_t len, ACE_Allocator *alloc=0, int release=1)
 ACE_String_Base (const ACE_String_Base< CHAR > &)
 Copy constructor. More...

 ACE_String_Base (CHAR c, ACE_Allocator *alloc=0)
 Constructor that copies c into dynamically allocated memory. More...

 ACE_String_Base (size_t len, CHAR c=0, ACE_Allocator *alloc=0)
 Constructor that dynamically allocate len long of char array and initialize it to c using alloc to allocate the memory. More...

 ~ACE_String_Base (void)
 Deletes the memory... More...

const CHAR & operator[] (size_t slot) const
 Return the <slot'th> character in the string (doesn't perform bounds checking). More...

CHAR & operator[] (size_t slot)
 Return the <slot'th> character by reference in the string (doesn't perform bounds checking). More...

ACE_String_Base< CHAR > & operator= (const ACE_String_Base< CHAR > &)
 Assignment operator (does copy memory). More...

void set (const CHAR *s, int release=1)
 Copy s into this ACE_String_Base. Memory is _not_ allocated/freed if release is 0. More...

void set (const CHAR *s, size_t len, int release)
 Copy len bytes of s (will NUL terminate the result). Memory is _not_ allocated/freed if release is 0. More...

void clear (int release=0)
 Clear this string. Memory is _not_ freed is <release> is 0. More...

ACE_String_Base< CHAR > substring (size_t offset, ssize_t length=-1) const
ACE_String_Base< CHAR > substr (size_t offset, ssize_t length=-1) const
 Same as <substring>. More...

ACE_String_Base< CHAR > & operator+= (const ACE_String_Base< CHAR > &)
 Concat operator (copies memory). More...

u_long hash (void) const
 Returns a hash value for this string. More...

size_t length (void) const
 Return the length of the string. More...

CHAR * rep (void) const
 Get a copy of the underlying representation. More...

const CHAR * fast_rep (void) const
const CHAR * c_str (void) const
 Same as STL String's <c_str> and <fast_rep>. More...

int strstr (const ACE_String_Base< CHAR > &s) const
 Comparison operator that will match substrings. Returns the slot of the first location that matches, else -1. More...

int find (const ACE_String_Base< CHAR > &str, int pos=0) const
 Find <str> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. More...

int find (const CHAR *s, int pos=0) const
 Find <s> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. More...

int find (CHAR c, int pos=0) const
 Find <c> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos. More...

int rfind (CHAR c, int pos=npos) const
 Find <c> starting at pos (counting from the end). Returns the slot of the first location that matches, else npos. More...

int operator== (const ACE_String_Base< CHAR > &s) const
 Equality comparison operator (must match entire string). More...

int operator< (const ACE_String_Base< CHAR > &s) const
 Less than comparison operator. More...

int operator> (const ACE_String_Base< CHAR > &s) const
 Greater than comparison operator. More...

int operator!= (const ACE_String_Base< CHAR > &s) const
 Inequality comparison operator. More...

int compare (const ACE_String_Base< CHAR > &s) const
 Performs a <strcmp>-style comparison. More...

void dump (void) const
 Dump the state of an object. More...

void resize (size_t len, CHAR c=0)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Attributes

ACE_Allocatorallocator_
 Pointer to a memory allocator. More...

size_t len_
 Length of the ACE_String_Base data (not counting the trailing '\0'). More...

size_t buf_len_
 Length of the ACE_String_Base data buffer. Keeping track of the length allows to avoid unnecessary dynamic allocations. More...

CHAR * rep_
 Pointer to data. More...

int release_
 Flag that indicates if we own the memory. More...


Static Protected Attributes

CHAR NULL_String_ = '\0'
 Represents the "NULL" string to simplify the internal logic. More...


Detailed Description

template<class CHAR>
class ACE_String_Base< CHAR >

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. NOTE: if an instance of this class is constructed from or assigned an empty string (with first element of '\0'), then it is _not_ allocated new space. Instead, its internal representation is set equal to a global empty string. CAUTION: in cases when ACE_String_Base is constructed from a provided buffer with the release parameter set to 0, ACE_String_Base is not guaranteed to be '\0' terminated.


Constructor & Destructor Documentation

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base ACE_Allocator   alloc = 0
 

Default constructor.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base const CHAR *    s,
ACE_Allocator   alloc = 0,
int    release = 1
 

Constructor that copies s into dynamically allocated memory. If release is non-0 then the ACE_allocator is responsible for freeing this memory. Memory is _not_ allocated/freed if release is 0.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base const CHAR *    s,
size_t    len,
ACE_Allocator   alloc = 0,
int    release = 1
 

Constructor that copies <len> CHARs of <s> into dynamically allocated memory (will NUL terminate the result). If <release> is non-0 then the <ACE_allocator> is responsible for freeing this memory. Memory is _not_ allocated/freed if <release> is 0.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base const ACE_String_Base< CHAR > &    s
 

Copy constructor.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base CHAR    c,
ACE_Allocator   alloc = 0
 

Constructor that copies c into dynamically allocated memory.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::ACE_String_Base size_t    len,
CHAR    c = 0,
ACE_Allocator   alloc = 0
 

Constructor that dynamically allocate len long of char array and initialize it to c using alloc to allocate the memory.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR >::~ACE_String_Base void   
 

Deletes the memory...


Member Function Documentation

template<class CHAR>
ACE_INLINE const CHAR * ACE_String_Base< CHAR >::c_str void    const
 

Same as STL String's <c_str> and <fast_rep>.

template<class CHAR>
ACE_INLINE void ACE_String_Base< CHAR >::clear int    release = 0
 

Clear this string. Memory is _not_ freed is <release> is 0.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::compare const ACE_String_Base< CHAR > &    s const
 

Performs a <strcmp>-style comparison.

template<class CHAR>
ACE_INLINE void ACE_String_Base< CHAR >::dump void    const
 

Dump the state of an object.

template<class CHAR>
ACE_INLINE const CHAR * ACE_String_Base< CHAR >::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!

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::find CHAR    c,
int    pos = 0
const
 

Find <c> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::find const CHAR *    s,
int    pos = 0
const
 

Find <s> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::find const ACE_String_Base< CHAR > &    str,
int    pos = 0
const
 

Find <str> starting at pos. Returns the slot of the first location that matches (will be >= pos), else npos.

template<class CHAR>
ACE_INLINE u_long ACE_String_Base< CHAR >::hash void    const
 

Returns a hash value for this string.

template<class CHAR>
ACE_INLINE size_t ACE_String_Base< CHAR >::length void    const
 

Return the length of the string.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::operator!= const ACE_String_Base< CHAR > &    s const
 

Inequality comparison operator.

template<class CHAR>
ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::operator+= const ACE_String_Base< CHAR > &    s
 

Concat operator (copies memory).

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::operator< const ACE_String_Base< CHAR > &    s const
 

Less than comparison operator.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR > & ACE_String_Base< CHAR >::operator= const ACE_String_Base< CHAR > &    s
 

Assignment operator (does copy memory).

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::operator== const ACE_String_Base< CHAR > &    s const
 

Equality comparison operator (must match entire string).

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::operator> const ACE_String_Base< CHAR > &    s const
 

Greater than comparison operator.

template<class CHAR>
ACE_INLINE CHAR & ACE_String_Base< CHAR >::operator[] size_t    slot
 

Return the <slot'th> character by reference in the string (doesn't perform bounds checking).

template<class CHAR>
ACE_INLINE const CHAR & ACE_String_Base< CHAR >::operator[] size_t    slot const
 

Return the <slot'th> character in the string (doesn't perform bounds checking).

template<class CHAR>
ACE_INLINE CHAR * ACE_String_Base< CHAR >::rep void    const
 

Get a copy of the underlying representation.

template<class CHAR>
void ACE_String_Base< CHAR >::resize size_t    len,
CHAR    c = 0
 

This method is designed for high-performance. Please use with care ;-) If the current size of the string is less than <len>, the string is resized to the new length. The data is zero'd out after this operation.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::rfind CHAR    c,
int    pos = npos
const
 

Find <c> starting at pos (counting from the end). Returns the slot of the first location that matches, else npos.

template<class CHAR>
void ACE_String_Base< CHAR >::set const CHAR *    s,
size_t    len,
int    release
 

Copy len bytes of s (will NUL terminate the result). Memory is _not_ allocated/freed if release is 0.

template<class CHAR>
ACE_INLINE void ACE_String_Base< CHAR >::set const CHAR *    s,
int    release = 1
 

Copy s into this ACE_String_Base. Memory is _not_ allocated/freed if release is 0.

template<class CHAR>
ACE_INLINE int ACE_String_Base< CHAR >::strstr const ACE_String_Base< CHAR > &    s const
 

Comparison operator that will match substrings. Returns the slot of the first location that matches, else -1.

template<class CHAR>
ACE_INLINE ACE_String_Base< CHAR > ACE_String_Base< CHAR >::substr size_t    offset,
ssize_t    length = -1
const
 

Same as <substring>.

template<class CHAR>
ACE_String_Base< CHAR > ACE_String_Base< CHAR >::substring size_t    offset,
ssize_t    length = -1
const
 

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.


Member Data Documentation

template<class CHAR>
ACE_String_Base::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

template<class CHAR>
ACE_Allocator* ACE_String_Base::allocator_ [protected]
 

Pointer to a memory allocator.

template<class CHAR>
size_t ACE_String_Base::buf_len_ [protected]
 

Length of the ACE_String_Base data buffer. Keeping track of the length allows to avoid unnecessary dynamic allocations.

template<class CHAR>
size_t ACE_String_Base::len_ [protected]
 

Length of the ACE_String_Base data (not counting the trailing '\0').

template<class CHAR>
CHAR ACE_String_Base< CHAR >::NULL_String_ = '\0' [static, protected]
 

Represents the "NULL" string to simplify the internal logic.

template<class CHAR>
int ACE_String_Base::release_ [protected]
 

Flag that indicates if we own the memory.

template<class CHAR>
CHAR* ACE_String_Base::rep_ [protected]
 

Pointer to data.


The documentation for this class was generated from the following files:
Generated on Sun Feb 17 17:43:39 2002 for ACE by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001