StringPimpl Class Reference

A string Private Implementation. More...

#include <StringPimpl.h>

List of all members.

Public Member Functions

char at (const unsigned int i) const
 Returns a specific char at a location within the string.
const char * c_str () const throw (Exception &)
 Just like the Standard String's c_str, this returns the internal string in the form of a const char.
void clear ()
 Clears the contents of this string.
bool empty () const throw (Exception &)
 Predicate which returns true if the internal string is empty and false if it is not empty.
bool existsAsADirectory () const throw ()
 Returns true if this string represents a directory on the file system.
bool existsAsAFile () const throw ()
 Returns true if this string represents a file on the file system.
int getInteger () const throw (NumberFormatException &)
 Returns the integer representation of this string.
unsigned int length () const
 Returns the length of this string.
void operator delete (void *p)
 All delete's will be handled through this dll.
void * operator new (size_t size)
 All new's will be handled through this dll.
bool operator!= (const StringPimpl &s) const
 Stanard != operator.
bool operator!= (const char *s) const
 Stanard != operator.
StringPimpl operator+ (const StringPimpl &s) const
 Stanard + operator.
StringPimpl operator+ (const char *s) const
 Stanard + operator.
StringPimploperator+= (const char *s)
 Stanard += operator.
StringPimploperator+= (const StringPimpl &s)
 Stanard += operator.
bool operator< (const StringPimpl &s) const
 Stanard < operator.
StringPimploperator= (const char c)
 Stanard = operator.
StringPimploperator= (const char *c)
 Stanard = operator.
StringPimploperator= (const StringPimpl &stringPimpl)
 Standard assignment operator.
bool operator== (const char *s) const
 Stanard == operator.
bool operator== (const StringPimpl &s) const
 Stanard == operator.
void push_back (char c)
 Push back a character to the end of this string.
void removePunctuation (const StringPimpl &sentenceSplitters) throw ()
 Removes all punctuation from the string given a list of puncutation.
unsigned int size () const
 Returns the size of this string.
bool startsWith (const StringPimpl &right) const
 Returns true if this string starts with the string given as an argument.
 StringPimpl (const StringPimpl &stringPimpl)
 Standard copy construtor.
 StringPimpl (const char *const stringPimpl) throw (Exception &)
 Constructor that takes in a const char.
 StringPimpl () throw (Exception &)
 Constructor that takes no arguments.
StringPimpltransformByTrimmingExcessSpaces () throw ()
 Transforms the contents of this string by trimming off any white space to the left or right of this string as well as newline characters and carriage returns.
StringPimpltransformByTrimmingLeft () throw ()
 Transforms the contents of this string by trimming off any white space to the left of this string.
StringPimpltransformByTrimmingRight () throw ()
 Transforms the contents of this string by trimming off any white space to the right of this string.
StringPimpltransformByTrimmingWhiteSpace () throw ()
 Transforms the contents of this string by trimming off any white space to the left or right of this string.
StringPimpltransformFirstCharacterUpperCase () throw ()
 Transforms the contents of this string's first character to upper case.
void transformIntoAbsoluteFilePath () const throw ()
 Transform the string to an absolute file path to a directory or file on the system.
StringPimpltransformToLowerCase () throw ()
 Transforms the contents of this string to lower case.
StringPimpltransformToUpperCase () throw ()
 Transforms the contents of this string to upper case.
virtual ~StringPimpl ()
 Standard virtual destructor.

Static Public Member Functions

static StringPimpl getString (int number) throw (NumberFormatException &)
 Given a number this will return a new string representation of that number.

Private Member Functions

void init (const char *const stringPimpl)
 Private method to avoid duplicate code between the constructor and the copy constructor.

Private Attributes

StringPrivate * m_pimpl
 The private String which I do not expose.


Detailed Description

A string Private Implementation.

This Private implementation's purpose (also commonly known on the internet as pimpl) is to not tie the user of RebeccaAIML to a particular Standard Library by using a Standard Library string.

Also, this private implementation handles the memory management of strings inside the RebeccaAIML dll which is a requirement for Dll memory boundary safety. Standard Libraries could and sometimes do break Dll memory boundary safeties, hence another reason this class is needed.

Only a few needed methods are provided. Once you get this string object back, you should copy it into your own standard string container.

Example: StringPimpl s = someFoo(); std::string myString(s.c_str);


Constructor & Destructor Documentation

StringPimpl (  )  throw (Exception &)

Constructor that takes no arguments.

The private string's empty constructor is called.

Exceptions:
This will not explicitly throw an exception, but an underlying method might. More than likely only a (bad_alloc) will be thrown for a out of memory exception. If so, the bad_alloc's message will be wrapped in the Exception class.

StringPimpl ( const char *const   stringPimpl  )  throw (Exception &)

Constructor that takes in a const char.

The char is copied to the private String.

Parameters:
stringPimpl The const char which is copied to the private String.
Exceptions:
This will not explicitly throw an exception, but an underlying method might. More than likely only a (bad_alloc) will be thrown for a out of memory exception. If so, the bad_alloc's message will be wrapped in the Exception class.

StringPimpl ( const StringPimpl stringPimpl  ) 

Standard copy construtor.

Parameters:
stringPimpl Standard secondary const StringPimpl reference needed for a copy constructor.
Exceptions:
This can throw anything but will not explicitly throw an exception.

virtual ~StringPimpl (  )  [virtual]

Standard virtual destructor.

This destorys the internal memory of the internal string private implementation. The deallocation of the memory occurs inside of the dll, therefore this satisfies the requirement to be dll memory boundary safe.


Member Function Documentation

char at ( const unsigned int  i  )  const

Returns a specific char at a location within the string.

Parameters:
i The position in the string to get the char at.
Returns:
Returns the char at the specified spot

const char* c_str (  )  const throw (Exception &)

Just like the Standard String's c_str, this returns the internal string in the form of a const char.

Use this to copy the string into whichever type of String you deem suitable.

Exceptions:
It will not explicitly throw an exception, but an underlying method might. More than likely this will never throw an exception.

void clear (  ) 

Clears the contents of this string.

bool empty (  )  const throw (Exception &)

Predicate which returns true if the internal string is empty and false if it is not empty.

Returns:
True if the internal string is empty, false if the internal string is not empty.
Exceptions:
It will not explicitly throw an exception, but an underlying method might. More than likely this will never throw an exception.

bool existsAsADirectory (  )  const throw ()

Returns true if this string represents a directory on the file system.

If you create a string that is a path to a directory on the file system and call this method you will get a true.

Returns:
True if this string represents a directory on the file system otherwise false
Exceptions:
This will not throw any exceptions

bool existsAsAFile (  )  const throw ()

Returns true if this string represents a file on the file system.

If you create a string that is a path to a file on the file system and call this method you will get a true.

Returns:
True if this string represents a file on the file system otherwise false
Exceptions:
This will not throw any exceptions

int getInteger (  )  const throw (NumberFormatException &)

Returns the integer representation of this string.

Exceptions:
NumberFormatException If this string does not represent a number this will throw a NumberFormatException

static StringPimpl getString ( int  number  )  throw (NumberFormatException &) [static]

Given a number this will return a new string representation of that number.

Parameters:
number The number to get back the string representation of
Exceptions:
NumberFormatException If the number can't be converted this will throw a NumberFormatException

void init ( const char *const   stringPimpl  )  [private]

Private method to avoid duplicate code between the constructor and the copy constructor.

Parameters:
stringPimpl The const char which is copied to the private String.
Exceptions:
This can throw anything.

unsigned int length (  )  const

Returns the length of this string.

Returns:
Returns the length of this string

void operator delete ( void *  p  ) 

All delete's will be handled through this dll.

This is required for dll boundary safety. Instead of allowing the compiler to choose if it wants to inline this we have made it so that it cannot. If we let the compiler choose to inline or not inline this and the "new operator" we can run into dll boundary issues. The issue would be that the compiler would inline one and not the other. Thus, your executable with its own heap would allocate/delete and this dll would do the other. That's a dll boundary safety violation.

Parameters:
p The pointer to an instance of this object.

void* operator new ( size_t  size  ) 

All new's will be handled through this dll.

This is required for dll boundary safety. Instead of allowing the compiler to choose if it wants to inline this we have made it so that it cannot. If we let the compiler choose to inline or not inline this and the "delete operator" we can run into dll boundary issues. The issue would be that the compiler would inline one and not the other. Thus, your executable with its own heap would allocate/delete and this dll would do the other. That's a dll boundary safety violation.

Parameters:
size The size to allocate an instance of this object with.
Returns:
An instance of this object

bool operator!= ( const StringPimpl s  )  const

Stanard != operator.

Parameters:
s The right hand string to compare to
Returns:
Returns true if the right hand string is not equal to this string

bool operator!= ( const char *  s  )  const

Stanard != operator.

Parameters:
s The right hand string to compare to
Returns:
true if they aren't equal otherwise false

StringPimpl operator+ ( const StringPimpl s  )  const

Stanard + operator.

Parameters:
s The right hand string to compare to
Returns:
Returns the result string

StringPimpl operator+ ( const char *  s  )  const

Stanard + operator.

Parameters:
s The right hand string to add to
Returns:
The string result of the addition

StringPimpl& operator+= ( const char *  s  ) 

Stanard += operator.

Parameters:
s The right hand string to add to

StringPimpl& operator+= ( const StringPimpl s  ) 

Stanard += operator.

Todo:
document all this
Parameters:
s The right hand string to add to

bool operator< ( const StringPimpl s  )  const

Stanard < operator.

Parameters:
s The right hand string to compare to
Returns:
Returns true if the right hand string is less than this string

StringPimpl& operator= ( const char  c  ) 

Stanard = operator.

Parameters:
c The right hand char to compare to
Returns:
Returns the result string

StringPimpl& operator= ( const char *  c  ) 

Stanard = operator.

Parameters:
c The right hand string to compare to
Returns:
Returns the result string

StringPimpl& operator= ( const StringPimpl stringPimpl  ) 

Standard assignment operator.

Performs a deep copy of the internal string.

Parameters:
stringPimpl Standard secondary reference
Exceptions:
This can throw anything but will not explicitly throw an exception.

bool operator== ( const char *  s  )  const

Stanard == operator.

Parameters:
s The right hand string to compare to
Returns:
True if they're equal otherwise false

bool operator== ( const StringPimpl s  )  const

Stanard == operator.

Parameters:
s The right hand string to compare to
Returns:
True if they're equal otherwise false

void push_back ( char  c  ) 

Push back a character to the end of this string.

Parameters:
c The character to push back to the end of this string.

void removePunctuation ( const StringPimpl sentenceSplitters  )  throw ()

Removes all punctuation from the string given a list of puncutation.

Parameters:
sentenceSplitters The list of punctuation to remove from this string.

unsigned int size (  )  const

Returns the size of this string.

Returns:
Returns the size of this string

bool startsWith ( const StringPimpl right  )  const

Returns true if this string starts with the string given as an argument.

Parameters:
right The string to check if this string starts with it.
Returns:
True if this string starts with the argument otherwise false.

StringPimpl& transformByTrimmingExcessSpaces (  )  throw ()

Transforms the contents of this string by trimming off any white space to the left or right of this string as well as newline characters and carriage returns.

Returns:
Return the string with excess white space, newline characters, and carriage returns trimmed off the left and right side.

StringPimpl& transformByTrimmingLeft (  )  throw ()

Transforms the contents of this string by trimming off any white space to the left of this string.

Returns:
Return the string with excess white space trimmed off the left side.

StringPimpl& transformByTrimmingRight (  )  throw ()

Transforms the contents of this string by trimming off any white space to the right of this string.

Returns:
Return the string with excess white space trimmed off the right side.

StringPimpl& transformByTrimmingWhiteSpace (  )  throw ()

Transforms the contents of this string by trimming off any white space to the left or right of this string.

Returns:
Return the string with excess white space trimmed off the left and right side.

StringPimpl& transformFirstCharacterUpperCase (  )  throw ()

Transforms the contents of this string's first character to upper case.

Returns:
Return the string with the frist character an upper case.

void transformIntoAbsoluteFilePath (  )  const throw ()

Transform the string to an absolute file path to a directory or file on the system.

If this string represents a file or directory on the file system you can call this method to transform the string into an absolute path on the file system.

Exceptions:
This will not throw any exceptions

StringPimpl& transformToLowerCase (  )  throw ()

Transforms the contents of this string to lower case.

Returns:
Return the string transformed to lower case

StringPimpl& transformToUpperCase (  )  throw ()

Transforms the contents of this string to upper case.

Returns:
Return the string transformed to upper case


Member Data Documentation

StringPrivate* m_pimpl [private]

The private String which I do not expose.

The memory for this is handled automatically inside of the constructor and destructor of this class.


The documentation for this class was generated from the following file:
Generated on Mon Aug 27 12:27:00 2007 for RebeccaAIML by  doxygen 1.5.3