lang >> locale

This commit is contained in:
Simon Rozman 2016-10-12 18:40:07 +02:00
parent f53779dbad
commit 650ad13a30
2 changed files with 14 additions and 16 deletions

View File

@ -238,8 +238,8 @@ namespace ZRCola {
/// \param[in ] cats Set of categories, character must be a part of /// \param[in ] cats Set of categories, character must be a part of
/// \param[inout] hits (character, count) map to append full-word hits to /// \param[inout] hits (character, count) map to append full-word hits to
/// \param[inout] hits_sub (character, count) map to append partial-word hits to /// \param[inout] hits_sub (character, count) map to append partial-word hits to
/// \param[in] fn_abort Pointer to function to periodically test for search cancellation /// \param[in ] fn_abort Pointer to function to periodically test for search cancellation
/// \param[in] cookie Cookie for \p fn_abort call /// \param[in ] cookie Cookie for \p fn_abort call
/// ///
bool Search(_In_z_ const wchar_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, charrank_t> &hits, _Inout_ std::map<wchar_t, charrank_t> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const; bool Search(_In_z_ const wchar_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, charrank_t> &hits, _Inout_ std::map<wchar_t, charrank_t> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;

View File

@ -188,14 +188,14 @@ namespace ZRCola {
/// ///
struct tagname { struct tagname {
tagid_t tag; ///< Tag ID tagid_t tag; ///< Tag ID
LCID lang; ///< Language ID LCID locale; ///< Locale ID
unsigned __int16 name_len; ///< \c name length (in characters) unsigned __int16 name_len; ///< \c name length (in characters)
wchar_t name[]; ///< Tag localized name wchar_t name[]; ///< Tag localized name
/// ///
/// Compares two names /// Compares two names
/// ///
/// \param[in] lcid Locale ID to use for compare /// \param[in] locale Locale ID to use for compare
/// \param[in] str_a First name /// \param[in] str_a First name
/// \param[in] count_a Number of characters in string \p str_a /// \param[in] count_a Number of characters in string \p str_a
/// \param[in] str_b Second name /// \param[in] str_b Second name
@ -210,9 +210,9 @@ namespace ZRCola {
/// The function does not treat \\0 characters as terminators for performance reasons. /// The function does not treat \\0 characters as terminators for performance reasons.
/// Therefore \p count_a and \p count_b must represent exact string lengths. /// Therefore \p count_a and \p count_b must represent exact string lengths.
/// ///
static inline int CompareName(LCID lcid, const wchar_t *str_a, unsigned __int16 count_a, const wchar_t *str_b, unsigned __int16 count_b) static inline int CompareName(LCID locale, const wchar_t *str_a, unsigned __int16 count_a, const wchar_t *str_b, unsigned __int16 count_b)
{ {
switch (CompareString(lcid, LINGUISTIC_IGNORECASE | LINGUISTIC_IGNOREDIACRITIC | NORM_LINGUISTIC_CASING | NORM_IGNOREWIDTH, str_a, count_a, str_b, count_b)) { switch (CompareString(locale, LINGUISTIC_IGNORECASE | LINGUISTIC_IGNOREDIACRITIC | NORM_LINGUISTIC_CASING | NORM_IGNOREWIDTH, str_a, count_a, str_b, count_b)) {
case CSTR_LESS_THAN : return -1; case CSTR_LESS_THAN : return -1;
case CSTR_EQUAL : return 0; case CSTR_EQUAL : return 0;
case CSTR_GREATER_THAN: return 1; case CSTR_GREATER_THAN: return 1;
@ -231,8 +231,8 @@ namespace ZRCola {
/// ///
/// Constructs the index /// Constructs the index
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// \param[in] lcid Locale used to perform tag name comparison /// \param[in] locale Locale used to perform tag name comparison
/// ///
indexName(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, tagname>(h) {} indexName(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, tagname>(h) {}
@ -249,10 +249,10 @@ namespace ZRCola {
/// ///
virtual int compare(_In_ const tagname &a, _In_ const tagname &b) const virtual int compare(_In_ const tagname &a, _In_ const tagname &b) const
{ {
if (a.lang < b.lang) return -1; if (a.locale < b.locale) return -1;
else if (a.lang > b.lang) return 1; else if (a.locale > b.locale) return 1;
int r = tagname::CompareName(a.lang, a.name, a.name_len, b.name, b.name_len); int r = tagname::CompareName(a.locale, a.name, a.name_len, b.name, b.name_len);
if (r != 0) return r; if (r != 0) return r;
return 0; return 0;
@ -271,10 +271,10 @@ namespace ZRCola {
/// ///
virtual int compare_sort(_In_ const tagname &a, _In_ const tagname &b) const virtual int compare_sort(_In_ const tagname &a, _In_ const tagname &b) const
{ {
if (a.lang < b.lang) return -1; if (a.locale < b.locale) return -1;
else if (a.lang > b.lang) return 1; else if (a.locale > b.locale) return 1;
int r = tagname::CompareName(a.lang, a.name, a.name_len, b.name, b.name_len); int r = tagname::CompareName(a.locale, a.name, a.name_len, b.name, b.name_len);
if (r != 0) return r; if (r != 0) return r;
if (a.tag < b.tag) return -1; if (a.tag < b.tag) return -1;
@ -290,8 +290,6 @@ namespace ZRCola {
/// ///
/// Constructs the database /// Constructs the database
/// ///
/// \param[in] lcid Locale used to perform tag name comparison
///
inline tagname_db() : idxName(data) {} inline tagname_db() : idxName(data) {}
}; };