chrcatid_t_blank and langid_t_blank are static members of their respective structures now

This commit is contained in:
Simon Rozman 2016-10-06 23:17:24 +02:00
parent e4e8609a00
commit dddc2d5794
8 changed files with 47 additions and 19 deletions

View File

@ -26,7 +26,7 @@
wxZRColaSettings::wxZRColaSettings(wxWindow* parent) : wxZRColaSettings::wxZRColaSettings(wxWindow* parent) :
m_lang_auto(true), m_lang_auto(true),
m_lang(ZRCola::langid_t_blank), m_lang(ZRCola::langid_t::blank),
wxZRColaSettingsBase(parent) wxZRColaSettingsBase(parent)
{ {
ZRColaApp *app = ((ZRColaApp*)wxTheApp); ZRColaApp *app = ((ZRColaApp*)wxTheApp);
@ -184,7 +184,7 @@ bool wxPersistentZRColaSettings::Restore()
const auto &lang = app->m_lang_db.idxLng[0]; const auto &lang = app->m_lang_db.idxLng[0];
wnd->m_lang = lang.id; wnd->m_lang = lang.id;
} else } else
wnd->m_lang = ZRCola::langid_t_blank; wnd->m_lang = ZRCola::langid_t::blank;
return wxPersistentDialog::Restore(); return wxPersistentDialog::Restore();
} }

View File

@ -20,6 +20,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\character.cpp" /> <ClCompile Include="..\src\character.cpp" />
<ClCompile Include="..\src\common.cpp" />
<ClCompile Include="..\src\language.cpp" /> <ClCompile Include="..\src\language.cpp" />
<ClCompile Include="..\src\mapping.cpp" /> <ClCompile Include="..\src\mapping.cpp" />
<ClCompile Include="..\src\normalize.cpp" /> <ClCompile Include="..\src\normalize.cpp" />

View File

@ -33,6 +33,9 @@
<ClCompile Include="..\src\character.cpp"> <ClCompile Include="..\src\character.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\common.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\stdafx.h"> <ClInclude Include="..\src\stdafx.h">

View File

@ -45,7 +45,7 @@ namespace ZRCola {
/// Character category ID type /// Character category ID type
/// Two letter abbreviation, non-terminated /// Two letter abbreviation, non-terminated
/// ///
struct chrcatid_t { struct ZRCOLA_API chrcatid_t {
char data[2]; char data[2];
inline chrcatid_t& operator=(const chrcatid_t &src) inline chrcatid_t& operator=(const chrcatid_t &src)
@ -60,15 +60,14 @@ namespace ZRCola {
data[1] = (data[0] = src[0]) != 0 ? src[1] : 0; data[1] = (data[0] = src[0]) != 0 ? src[1] : 0;
return *this; return *this;
} }
///
/// Blank character category
///
static const chrcatid_t blank;
}; };
///
/// Blank character category
///
const chrcatid_t chrcatid_t_blank = {};
/// ///
/// Compares two character category IDs /// Compares two character category IDs
/// ///
@ -251,14 +250,14 @@ namespace ZRCola {
/// ///
/// \returns /// \returns
/// - Character category if character found /// - Character category if character found
/// - `ZRCola::chrcatid_t_blank` otherwise /// - `ZRCola::chrcatid_t::blank` otherwise
/// ///
inline chrcatid_t GetCharCat(wchar_t c) const inline chrcatid_t GetCharCat(wchar_t c) const
{ {
char _chr[sizeof(character)]; char _chr[sizeof(character)];
((character *)_chr)->chr = c; ((character *)_chr)->chr = c;
indexChar::size_type start; indexChar::size_type start;
return idxChr.find(*((character *)_chr), start) ? idxChr[start].cat : chrcatid_t_blank; return idxChr.find(*((character *)_chr), start) ? idxChr[start].cat : chrcatid_t::blank;
} }
}; };

View File

@ -76,7 +76,7 @@ namespace ZRCola {
/// Language ID type /// Language ID type
/// Three letter abbreviation, zero terminated /// Three letter abbreviation, zero terminated
/// ///
struct langid_t { struct ZRCOLA_API langid_t {
char data[4]; char data[4];
inline langid_t& operator=(const langid_t &src) inline langid_t& operator=(const langid_t &src)
@ -99,15 +99,14 @@ namespace ZRCola {
src[3] : 0; src[3] : 0;
return *this; return *this;
} }
///
/// Blank language ID
///
static const langid_t blank;
}; };
///
/// Blank language ID
///
const langid_t langid_t_blank = {};
/// ///
/// Compares two language IDs /// Compares two language IDs
/// ///

View File

@ -224,7 +224,7 @@ namespace ZRCola {
/// ///
inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const
{ {
Decompose(input, inputMax, NULL, langid_t_blank, output, map); Decompose(input, inputMax, NULL, langid_t::blank, output, map);
} }
/// ///

View File

@ -20,6 +20,9 @@
#include "stdafx.h" #include "stdafx.h"
const ZRCola::chrcatid_t ZRCola::chrcatid_t::blank = {};
bool ZRCola::character_db::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), _In_opt_ void *cookie) const bool ZRCola::character_db::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), _In_opt_ void *cookie) const
{ {
assert(str); assert(str);

View File

@ -0,0 +1,23 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
const ZRCola::langid_t ZRCola::langid_t::blank = {};