Constructor attaching an existing string buffer AND a const char * pointer, for values that are stored both ways, such as dtsOptions.userThesaurusFile and dtsOptions.userThesaurusFile2
Constructor initializing the DStringProperty with the address of a const char * pointer. The const char * pointer will always point to the string buffer in value.
Constructor attaching an existing string buffer AND a const char * pointer, for values that are stored both ways, such as dtsOptions.userThesaurusFile and dtsOptions.userThesaurusFile2
Constructor initializing the DStringProperty with the address of a const char * pointer. The const char * pointer will always point to the string buffer in value.
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":
"W", "A", "U8", and "Ui" versions of "set" and "get" functions are provided to get or set the string value as Unicode (W), Ansi (A), UTF-8 (U8), or TCHAR or CString (Ui).
Implementation Details:
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:
dtsSearchJob searchJob;
DStringProperty xrequest(&searchJob.request);
// Now any change to xrequest automatically causes searchJob.request to point to the// updated string
xrequest.setW(L"Unicode search request");
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.