#include <StringPimpl.h>
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. | |
StringPimpl & | operator+= (const char *s) |
Stanard += operator. | |
StringPimpl & | operator+= (const StringPimpl &s) |
Stanard += operator. | |
bool | operator< (const StringPimpl &s) const |
Stanard < operator. | |
StringPimpl & | operator= (const char c) |
Stanard = operator. | |
StringPimpl & | operator= (const char *c) |
Stanard = operator. | |
StringPimpl & | operator= (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. | |
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. | |
StringPimpl & | transformByTrimmingLeft () throw () |
Transforms the contents of this string by trimming off any white space to the left of this string. | |
StringPimpl & | transformByTrimmingRight () throw () |
Transforms the contents of this string by trimming off any white space to the right of this string. | |
StringPimpl & | transformByTrimmingWhiteSpace () throw () |
Transforms the contents of this string by trimming off any white space to the left or right of this string. | |
StringPimpl & | transformFirstCharacterUpperCase () 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. | |
StringPimpl & | transformToLowerCase () throw () |
Transforms the contents of this string to lower case. | |
StringPimpl & | transformToUpperCase () 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. |
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);
StringPimpl | ( | ) | throw (Exception &) |
Constructor that takes no arguments.
The private string's empty constructor is called.
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.
stringPimpl | The const char which is copied to the private String. |
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.
stringPimpl | Standard secondary const StringPimpl reference needed for a copy constructor. |
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.
char at | ( | const unsigned int | i | ) | const |
Returns a specific char at a location within the string.
i | The position in the string to get the char at. |
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.
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.
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.
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.
This | will not throw any exceptions |
int getInteger | ( | ) | const throw (NumberFormatException &) |
Returns the integer representation of this string.
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.
number | The number to get back the string representation of |
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.
stringPimpl | The const char which is copied to the private String. |
This | can throw anything. |
unsigned int length | ( | ) | const |
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.
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.
size | The size to allocate an instance of this object with. |
bool operator!= | ( | const StringPimpl & | s | ) | const |
Stanard != operator.
s | The right hand string to compare to |
bool operator!= | ( | const char * | s | ) | const |
Stanard != operator.
s | The right hand string to compare to |
StringPimpl operator+ | ( | const StringPimpl & | s | ) | const |
Stanard + operator.
s | The right hand string to compare to |
StringPimpl operator+ | ( | const char * | s | ) | const |
Stanard + operator.
s | The right hand string to add to |
StringPimpl& operator+= | ( | const char * | s | ) |
Stanard += operator.
s | The right hand string to add to |
StringPimpl& operator+= | ( | const StringPimpl & | s | ) |
bool operator< | ( | const StringPimpl & | s | ) | const |
Stanard < operator.
s | The right hand string to compare to |
StringPimpl& operator= | ( | const char | c | ) |
Stanard = operator.
c | The right hand char to compare to |
StringPimpl& operator= | ( | const char * | c | ) |
Stanard = operator.
c | The right hand string to compare to |
StringPimpl& operator= | ( | const StringPimpl & | stringPimpl | ) |
Standard assignment operator.
Performs a deep copy of the internal string.
stringPimpl | Standard secondary reference |
This | can throw anything but will not explicitly throw an exception. |
bool operator== | ( | const char * | s | ) | const |
Stanard == operator.
s | The right hand string to compare to |
bool operator== | ( | const StringPimpl & | s | ) | const |
Stanard == operator.
s | The right hand string to compare to |
void push_back | ( | char | c | ) |
Push back a character to the end of this string.
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.
sentenceSplitters | The list of punctuation to remove from this string. |
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.
right | The string to check if this string starts with it. |
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.
StringPimpl& transformByTrimmingLeft | ( | ) | throw () |
Transforms the contents of this string by trimming off any white space to the left of this string.
StringPimpl& transformByTrimmingRight | ( | ) | throw () |
Transforms the contents of this string by trimming off any white space to the right of this string.
StringPimpl& transformByTrimmingWhiteSpace | ( | ) | throw () |
Transforms the contents of this string by trimming off any white space to the left or right of this string.
StringPimpl& transformFirstCharacterUpperCase | ( | ) | 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.
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.
This | will not throw any exceptions |
StringPimpl& transformToLowerCase | ( | ) | throw () |
Transforms the contents of this string to lower case.
StringPimpl& transformToUpperCase | ( | ) | throw () |
Transforms the contents of this string to upper case.
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.