Manages conversion among character encodings (Ansi, Unicode, UTF-8).
File: dstringproperty.h
Namespace: dtSearch
Data Member |
Description |
---|---|
Used if the value is associated with a fixed-length buffer | |
Used if the value is associated with a const char * pointer that should be updated each time string contents change |
Data Member |
Description |
---|---|
Used if the value is associated with a fixed-length buffer | |
Used if the value is associated with a const char * pointer that should be updated each time string contents change |
Operator |
Description |
---|---|
Copy a DStringProperty | |
Copy a string | |
Store a Unicode string | |
Get const char * pointer to the string buffer |
Method |
Description |
---|---|
Copy constructor | |
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 attaching an existing string buffer | |
Constructor initializing with a string value | |
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 initializing with a Unicode string value | |
Return the string as a .NET System::String | |
Convert the string to a COM BSTR and return it | |
Clear the string | |
Get the string as Ansi | |
Convert the string from a dtsStringHandle, optionally deleting the handle after the string has been converted | |
Returns the length of the string | |
Get the string as UTF-8 | |
Unicode | |
Unicode Get the string as TCHAR | |
Get the string as Unicode | |
Returns true if the string is empty or contains only whitespace | |
If this property is linked to an API structure string pointer or buffer, update the pointer or buffer every time its value changes. | |
Store a .NET System::String | |
Store an Ansi string | |
Store a UTF-8 string | |
Store a const TCHAR * string | |
Store a Unicode string | |
Get char * pointer to the string buffer |
Method |
Description |
---|---|
Copy constructor | |
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 attaching an existing string buffer | |
Constructor initializing with a string value | |
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 initializing with a Unicode string value | |
Return the string as a .NET System::String | |
Convert the string to a COM BSTR and return it | |
Clear the string | |
Get the string as Ansi | |
Convert the string from a dtsStringHandle, optionally deleting the handle after the string has been converted | |
Returns the length of the string | |
Get the string as UTF-8 | |
Unicode | |
Unicode Get the string as TCHAR | |
Get the string as Unicode | |
Returns true if the string is empty or contains only whitespace | |
If this property is linked to an API structure string pointer or buffer, update the pointer or buffer every time its value changes. | |
Store a .NET System::String | |
Store an Ansi string | |
Store a UTF-8 string | |
Store a const TCHAR * string | |
Store a Unicode string | |
Get char * pointer to the string buffer |
Operator |
Description |
---|---|
Copy a DStringProperty | |
Copy a string | |
Store a Unicode string | |
Get const char * pointer to the string buffer |
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:
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.