#include <Helper-classes.hh>
Public Member Functions | |
| ~StringManager () throw () | |
| destroys the strings in the various lists | |
| void | drain () throw () |
| frees memory of all owned strings | |
| char * | disown (char *str) throw ( std::logic_error ) |
| grant ownership of the string to the calling code | |
| XMLCh * | disown (XMLCh *str) throw ( std::logic_error ) |
| grant ownership of the string to the calling code | |
| XMLCh * | convert (const char *str) |
| transcode the supplied C string to XMLCh* and take ownership of the XMLCh* | |
| XMLCh * | convert (const std::string &str) |
| transcode the supplied C++ string to XMLCh* and take ownership of the XMLCh* | |
| char * | convert (const XMLCh *str) |
| transcode the supplied XMLCh* to a C string and take ownership of the C string | |
It's a wrapper around and an alternative to direct XMLString::transcode() calls, which require the calling code to manually/individually free the memory of the returned strings.
This class releases all of the owned pointers in its destructor. You can either pass a StringManager pointer around a set of related classes and perform all of the memory cleanup at the end (with a single delete() call); or create a StringManager object and let scoping rules trigger the destructor for you.
Several decisions were made in the design of this class:
| char * StringManager::convert | ( | const XMLCh * | str | ) |
transcode the supplied XMLCh* to a C string and take ownership of the C string
The returned char* will be added to the const pool; calls to own() must therefore pass a const char* parameter
| XMLCh * StringManager::convert | ( | const std::string & | str | ) |
transcode the supplied C++ string to XMLCh* and take ownership of the XMLCh*
The returned XMLCh* will be added to the const pool; calls to own() must therefore pass a const XMLCh* parameter
| XMLCh * StringManager::convert | ( | const char * | str | ) |
transcode the supplied C string to XMLCh* and take ownership of the XMLCh*
The returned XMLCh* will be added to the const pool; calls to own() must therefore pass a const XMLCh* parameter
| XMLCh * StringManager::disown | ( | XMLCh * | str | ) | throw ( std::logic_error ) |
grant ownership of the string to the calling code
throw std::logic_error if the specified string isn't found
| char * StringManager::disown | ( | char * | str | ) | throw ( std::logic_error ) |
grant ownership of the string to the calling code
throw std::logic_error if the specified string isn't found
1.4.7