ULJSONDictionaryDataSource implements the ULDictionaryDataSource protocol (and thus both the ULDictionary and ULDataSource protocols) by using ULAPI 8 .uld files.
More...
#include <uljsondictionarydatasource.h>
ULJSONDictionaryDataSource implements the ULDictionaryDataSource protocol (and thus both the ULDictionary and ULDataSource protocols) by using ULAPI 8 .uld files.
ULJSONDictionaryDataSource::ULJSONDictionaryDataSource |
( |
| ) |
|
ULJSONDictionaryDataSource::~ULJSONDictionaryDataSource |
( |
| ) |
|
|
virtual |
ULError ULJSONDictionaryDataSource::attach |
( |
const ULString & |
dataSourceIdentifier | ) |
|
|
virtual |
Causes this ULDataSource object to be associated with the specified data source, and reads enough information from that data source to determine its language(s), etc.
The exact behavior of attach will be dependent on the nature of the data source. If the data source is a file, then attach will read header information from the file and then close the file to save memory until the data source is actually needed. On the other hand, if the data source is a remote database, then attach might open a connection, collect header information, and then close the connection.
- Returns
- ULError::NoError if the attachment is successful, or some other ULError value if not.
- Parameters
-
[in] | dataSourceIdentifier | A string describing the data source (e.g. a file name, a database connection string, a URL, etc.). |
Implements ULDictionaryDataSource.
Creates an iterator pointing to the first ULDictionaryNode in the set of nodes associated with the specified index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.
- Returns
- ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
- Parameters
-
[in] | searchLanguage | For bilingual dictionaries, this indicates the language of the index in question. (For example, an English-Spanish data source would have both an English headword index and a Spanish headword index, and searchLanguage would tell begin() which of these indexes to use.) |
[in] | indexID | An enumerated value specifying which index to search. |
[out] | iterator | An iterator pointing to the first ULDictionaryNode associated with the specified index. |
Implements ULDictionaryDataSource.
void ULJSONDictionaryDataSource::clear |
( |
| ) |
|
|
protected |
Private method that sets this data source to its default state and releases all its dynamically allocated memory.
ULError ULJSONDictionaryDataSource::close |
( |
| ) |
|
|
virtual |
Frees dynamically allocated memory associated with this data source while keeping it attached to the file, db, etc. to which it was previously attached. Also closes any relevant files, db connections, etc.
- Returns
- ULError::NoError if the memory freeing was successful.
Implements ULDictionaryDataSource.
ULError ULJSONDictionaryDataSource::detach |
( |
| ) |
|
|
virtual |
Releases the connection between this ULDataSource object and the data source specified in the previous open() or attach() call, closing any relevant files or network connections and freeing memory in the process.
- Returns
- ULError::NoError if the attachment is successful, or some other ULError value if not.
Implements ULDictionaryDataSource.
Creates an iterator pointing to the end of the list of ULDictionaryNodes associated with the specified index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.
- Returns
- ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
- Parameters
-
[in] | searchLanguage | For bilingual dictionaries, this indicates the language of the index in question. (For example, an English-Spanish data source would have both an English headword index and a Spanish headword index, and searchLanguage would tell begin() which of these indexes to use.) |
[in] | indexID | An enumerated value specifying which index to search. |
[out] | iterator | An iterator pointing to the end of the ULDictionaryNode list associated with the specified index. |
Implements ULDictionaryDataSource.
Searches the data source(s) associated with this ULDictionary for the closest match to the specified search string, using the specified language and index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.
The "closest match" found by this method is closest in the sense of a binary search on a sorted list. More specifically, the closest match is the lexicographically smallest item in the specified index that is greater than or equal to the search string. Thus, for example, if you search for "sp" in English, you'll get an iterator pointing to the first English word starting with "sp" or "Sp" (e.g. "spa").
- Returns
- ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
- Parameters
-
[in] | searchString | The string you're looking for. |
[in] | searchLanguage | For bilingual dictionaries, this specifies the direction in which to search–i.e. the language in which searchString is to be interpreted. |
[in] | indexID | An enumerated value specifying which index to search. |
[out] | iterator | An iterator pointing to the closest match in the specified index. This iterator will point to a top-level ULDictionaryNode (i.e. one with no parent node). |
Implements ULDictionaryDataSource.
- Parameters
-
[out] | serviceList | Used to return a list of all the services this ULWorker can provide. |
Implements ULWorker.
ULString ULJSONDictionaryDataSource::getDataSourceIdentifier |
( |
| ) |
|
|
virtual |
- Returns
- the data source identifier for the data source attached to this ULDataSource object, or the empty string if no data source is attached.
Implements ULDictionaryDataSource.
Obtains the list of feature names stored in this data source. The feature names in this list are associated, in the data source itself, with integer IDs starting at 0 for the first string in featureNameList, and going up to featureNameList.length() - 1.
- Returns
- ULError::NoError if the list can be retrieved.
- Parameters
-
[out] | featureNameList | the list of feature names stored in this data source. |
Implements ULDictionaryDataSource.
const ULLanguage & ULJSONDictionaryDataSource::getFirstLanguage |
( |
| ) |
|
|
virtual |
ULForester * ULJSONDictionaryDataSource::getForester |
( |
| ) |
|
|
virtual |
ULForestType ULJSONDictionaryDataSource::getForestType |
( |
| ) |
|
|
virtual |
- Returns
- the forest type for this data source, which can be used (among other things) to decide which subclass of ULForester to assign to this data source.
Implements ULDictionaryDataSource.
ULError ULJSONDictionaryDataSource::getLocalizationRuleList |
( |
const ULLanguage & |
language, |
|
|
ULList< ULLocalizationRule > & |
localizationRulesList |
|
) |
| |
|
virtual |
Obtains the list of localization rules stored in this data source for the given language.
- Returns
- ULError::NoError if the list can be retrieved.
- Parameters
-
[in] | language | The language for which to retrieve the rules. |
[out] | localizationRuleList | The list of localization rule stored in this data source for the given language |
Implements ULDictionaryDataSource.
const ULLanguage & ULJSONDictionaryDataSource::getSecondLanguage |
( |
| ) |
|
|
virtual |
bool ULJSONDictionaryDataSource::getULDAttribute |
( |
const ULString & |
key, |
|
|
ULString & |
value |
|
) |
| |
|
virtual |
Retrieves the ULD attribute value associated with the given key if it exists for this ULD.
- Returns
- true if the uld has this attribute and false otherwise.
- Parameters
-
[in] | key | The string that is the key for the attribute you want to retrieve. |
[out] | value | The value of the attribute if it exists. |
Implements ULDictionaryDataSource.
ULDataSourceVersion ULJSONDictionaryDataSource::getVersion |
( |
| ) |
|
|
virtual |
bool ULJSONDictionaryDataSource::isOpen |
( |
| ) |
const |
|
protected |
- Returns
- true if the specified service can be performed by this ULWorker, and false otherwise.
- Parameters
-
service | The desired service. |
Implements ULWorker.
ULError ULJSONDictionaryDataSource::load |
( |
| ) |
|
|
virtual |
Perform one-time opening and loading operations. Normally, such operations are performed lazily, when the data source is first queried. If you would prefer to control the time at which loading is performed, call this method.
- Returns
- ULError::NoError if the loading was successful.
Implements ULDictionaryDataSource.
Assignment operator. This operator does not actually copy anything, so the lvalue of an assignment between ULJSONDictionaryDataSources will remain unchanged.
Equality operator. Just checks to see if the underlying data is equal.
void ULJSONDictionaryDataSource::setForester |
( |
ULForester * |
newForester | ) |
|
|
virtual |
Assigns the forester to be used by this ULDictionaryDataSource. The data source takes responsibility for deleting the forester.
- Parameters
-
[in] | newForester | A pointer to the desired forester. |
Implements ULDictionaryDataSource.
ULString* ULJSONDictionaryDataSource::featureNames |
|
protected |
ULLanguage ULJSONDictionaryDataSource::firstLanguage |
|
protected |
ULForester* ULJSONDictionaryDataSource::forester |
|
protected |
ULString ULJSONDictionaryDataSource::jsonData |
|
protected |
Json::Value ULJSONDictionaryDataSource::jsonRoot |
|
protected |
uluint32 ULJSONDictionaryDataSource::nNodes |
|
protected |
ULLanguage ULJSONDictionaryDataSource::secondLanguage |
|
protected |
The documentation for this class was generated from the following files: