Manages conversion among character encodings (Ansi, Unicode, UTF-8).
Set and get functions are provided for each encoding type. DStringProperty stores text internally in a DString in UTF-8, the same format that the dtSearch Engine uses.
The dtSearch Engine's C++ support classes use DStringProperty to provide easy access to strings passed to or from the dtSearch Engine. For example, DSearchJob uses a DStringProperty, "Request" for the search request string. Any changes to Request are automatically reflected in dtsSearchJob.request. The following code sets up a search job using a Unicode string to initialize the "request":
A DStringProperty maintains a text buffer, value, with a UTF-8 representation of the text.
DStringProperty is designed to be associated with a structure element, so that set*() or get*() calls will provide easy access to the contents of a string in a structure. A string member of a structure can be either a char * (a pointer to a memory location) or a char[N], a fixed-length buffer of N bytes. DStringProperty has constructors that will work with either variation.
Each time the string is changed, potentially causing reallocation of the buffer, the const char * string pointer is updated to point to the new buffer.
In this example, DStringProperty is declared to manage the dtsSearchJob.request string:
Each time a DStringProperty changes, it calls onValueChange, which sets *pValue to the new string buffer in value. This keeps the string pointer in the API structure consistent with the contents of the string buffer.