NAME
ACE_CString -
A simple "C String" (ACE_CString) class.
SYNOPSIS
#include <ace/SString.h>
class ACE_CString
{
public:
ACE_CString (ACE_Allocator *allocator = 0);
ACE_CString (const char *s, ACE_Allocator *allocator = 0);
ACE_CString (const ACE_CString &);
~ACE_CString (void);
ACE_CString (
const char *s,
size_t len,
ACE_Allocator *allocator = 0
);
void operator= (const ACE_CString &);
size_t length (void) const;
char *rep (void) const;
void operator += (const ACE_CString &);
int strstr (const ACE_CString &s) const;
char operator[] (size_t index) const;
int operator== (const ACE_CString &s) const;
int operator!= (const ACE_CString &s) const;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
ACE_Allocator *allocator_;
size_t len_;
char *rep_;
};
DESCRIPTION
This is a place holder until all compilers implement the
ANSI/ISO C++ standard String class. Note that we need to use
this class since the ACE 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
PUBLIC MEMBERS
ACE_CString (ACE_Allocator *allocator = 0);
ACE_CString (const char *s, ACE_Allocator *allocator = 0);
Constructor that copies s into dynamically allocated memory.
ACE_CString (const ACE_CString &);
~ACE_CString (void);
ACE_CString (const char *s, size_t len, ACE_Allocator *allocator = 0);
Constructor that copies len chars of s into dynamically
allocated memory (will NUL terminate the result).
void operator= (const ACE_CString &);
Assignment operator (does copy memory).
size_t length (void) const;
Return the length of the string.
char *rep (void) const;
Get a copy of the underlying pointer.
void operator += (const ACE_CString &);
Concat operator (copies memory).
int strstr (const ACE_CString &s) const;
Comparison operator that will match substrings. Returns the
index of the first location that matches, else -1.
char operator[] (size_t index) const;
Return the index'th character in the string (doesn't perform
bounds checking).
int operator== (const ACE_CString &s) const;
Comparison operator (must match entire string).
int operator!= (const ACE_CString &s) const;
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
PRIVATE MEMBERS
ACE_Allocator *allocator_;
Pointer to a memory allocator.
size_t len_;
Length of the ACE_CString (not counting the trailing '\ ').
char *rep_;
AUTHOR
Douglas C. Schmidt (schmidt@cs.wustl.edu)
LIBRARY
ace