#include <StringPimpl.h>
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. | |
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. | |
StringPimpl & | StringPimpl::operator= (const StringPimpl &stringPimpl) |
Standard assignment operator. | |
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. |
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 that takes no arguments. The private string's empty constructor is called.
|
|
Constructor that takes in a const char. The char is copied to the private String.
|
|
Standard copy construtor.
|
|
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. |
|
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.
|
|
Predicate which returns true if the internal string is empty and false if it is not empty.
|
|
Private method to avoid duplicate code between the constructor and the copy constructor.
|
|
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.
|
|
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.
|
|
Standard assignment operator. Performs a deep copy of the internal string.
|
|
The private String which I do not expose. The memory for this is handled automatically inside of the constructor and destructor of this class. |