NAME
ACE_SString -
A very "Simple String" (ACE_SString) class.
SYNOPSIS
#include <ace/SString.h>
class ACE_SString
{
public:
ACE_SString (ACE_Allocator *allocator = 0);
ACE_SString (const char *s, ACE_Allocator *allocator = 0);
ACE_SString (
const char *s,
size_t len,
ACE_Allocator *allocator = 0
);
ACE_SString (const ACE_SString &);
void operator= (const ACE_SString &);
size_t length (void) const;
void rep (char *s);
char *rep (void) const;
void operator += (const ACE_SString &);
int strstr (const ACE_SString &s) const;
char operator[] (size_t index) const;
int operator== (const ACE_SString &s) const;
int operator!= (const ACE_SString &s) const;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
ACE_Allocator *allocator_;
size_t len_;
char *rep_;
};
DESCRIPTION
This is *not* a general-purpose string class. It is only
intended for use with applications that understand how it
works. In particular, it has no destructor... 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_SString (ACE_Allocator *allocator = 0);
ACE_SString (const char *s, ACE_Allocator *allocator = 0);
Constructor that copies s into dynamically allocated memory.
ACE_SString (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).
ACE_SString (const ACE_SString &);
void operator= (const ACE_SString &);
Assignment operator (does copy memory).
size_t length (void) const;
Return the length of the string.
void rep (char *s);
Set the underlying pointer. Since this does not copy memory or
delete existing memory use with extreme caution!!!
char *rep (void) const;
Get the underlying pointer.
void operator += (const ACE_SString &);
Concat operator (does copy memory).
int strstr (const ACE_SString &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_SString &s) const;
Comparison operator (must match entire string).
int operator!= (const ACE_SString &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_SString (not counting the trailing '\ ').
char *rep_;
AUTHOR
Douglas C. Schmidt (schmidt@cs.wustl.edu)
LIBRARY
ace