StringPimpl Class Reference

A String Private Implementation. More...

#include <StringPimpl.h>

List of all members.

Public Member Functions

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.
bool empty () const throw (Exception &)
 Predicate which returns true if the internal string is empty and false if it is not empty.
void operator delete (void *p)
 All delete's will be handled through this dll.
void * operator new (unsigned int size)
 All new's will be handled through this dll.
StringPimploperator= (const StringPimpl &stringPimpl)
 Standard assignment operator.
 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.
virtual ~StringPimpl ()
 Standard virtual destructor.

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

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.

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.

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.

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 unsigned int  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

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.


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 Wed Jul 26 21:39:09 2006 for RebeccaAIML by  doxygen 1.4.5