Manages conversion among character encodings (Ansi, Unicode, UTF-8).
class DStringProperty;
dstringproperty.h
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":
DSearchJob searchJob; searchJob.Request.setW(L"Unicode search 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.
|
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 |
|
Method |
Description |
|
Return the string as a .NET System::String | |
|
Convert the string to a COM BSTR and return it | |
|
Clear the string | |
|
This is the overview for the DStringProperty constructor overload. | |
|
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 | |
|
This is the overview for the getUi method overload. | |
|
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 |
|
This is the overview for the = operator overload. | |
|
Get const char * pointer to the string buffer |
|
Data Member |
|
protected |
|
Operator |
|
Method |
|
Copyright (c) 1995-2012 dtSearch Corp. All rights reserved.
|