From dddc2d579445d390da4c0c1d441ca71463163b09 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 6 Oct 2016 23:17:24 +0200 Subject: [PATCH] chrcatid_t_blank and langid_t_blank are static members of their respective structures now --- ZRCola/zrcolasettings.cpp | 4 ++-- lib/libZRCola/build/libZRCola.vcxproj | 1 + lib/libZRCola/build/libZRCola.vcxproj.filters | 3 +++ lib/libZRCola/include/zrcola/character.h | 17 +++++++------- lib/libZRCola/include/zrcola/common.h | 13 +++++------ lib/libZRCola/include/zrcola/translate.h | 2 +- lib/libZRCola/src/character.cpp | 3 +++ lib/libZRCola/src/common.cpp | 23 +++++++++++++++++++ 8 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 lib/libZRCola/src/common.cpp diff --git a/ZRCola/zrcolasettings.cpp b/ZRCola/zrcolasettings.cpp index 3f3bdba..4fb76f9 100644 --- a/ZRCola/zrcolasettings.cpp +++ b/ZRCola/zrcolasettings.cpp @@ -26,7 +26,7 @@ wxZRColaSettings::wxZRColaSettings(wxWindow* parent) : m_lang_auto(true), - m_lang(ZRCola::langid_t_blank), + m_lang(ZRCola::langid_t::blank), wxZRColaSettingsBase(parent) { ZRColaApp *app = ((ZRColaApp*)wxTheApp); @@ -184,7 +184,7 @@ bool wxPersistentZRColaSettings::Restore() const auto &lang = app->m_lang_db.idxLng[0]; wnd->m_lang = lang.id; } else - wnd->m_lang = ZRCola::langid_t_blank; + wnd->m_lang = ZRCola::langid_t::blank; return wxPersistentDialog::Restore(); } diff --git a/lib/libZRCola/build/libZRCola.vcxproj b/lib/libZRCola/build/libZRCola.vcxproj index c4d15b2..f077c81 100644 --- a/lib/libZRCola/build/libZRCola.vcxproj +++ b/lib/libZRCola/build/libZRCola.vcxproj @@ -20,6 +20,7 @@ + diff --git a/lib/libZRCola/build/libZRCola.vcxproj.filters b/lib/libZRCola/build/libZRCola.vcxproj.filters index 3bce8e1..eb80148 100644 --- a/lib/libZRCola/build/libZRCola.vcxproj.filters +++ b/lib/libZRCola/build/libZRCola.vcxproj.filters @@ -33,6 +33,9 @@ Source Files + + Source Files + diff --git a/lib/libZRCola/include/zrcola/character.h b/lib/libZRCola/include/zrcola/character.h index d050c55..fe3265e 100644 --- a/lib/libZRCola/include/zrcola/character.h +++ b/lib/libZRCola/include/zrcola/character.h @@ -45,7 +45,7 @@ namespace ZRCola { /// Character category ID type /// Two letter abbreviation, non-terminated /// - struct chrcatid_t { + struct ZRCOLA_API chrcatid_t { char data[2]; inline chrcatid_t& operator=(const chrcatid_t &src) @@ -60,15 +60,14 @@ namespace ZRCola { data[1] = (data[0] = src[0]) != 0 ? src[1] : 0; return *this; } + + /// + /// Blank character category + /// + static const chrcatid_t blank; }; - /// - /// Blank character category - /// - const chrcatid_t chrcatid_t_blank = {}; - - /// /// Compares two character category IDs /// @@ -251,14 +250,14 @@ namespace ZRCola { /// /// \returns /// - Character category if character found - /// - `ZRCola::chrcatid_t_blank` otherwise + /// - `ZRCola::chrcatid_t::blank` otherwise /// inline chrcatid_t GetCharCat(wchar_t c) const { char _chr[sizeof(character)]; ((character *)_chr)->chr = c; 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; } }; diff --git a/lib/libZRCola/include/zrcola/common.h b/lib/libZRCola/include/zrcola/common.h index d4b1174..d2cc876 100644 --- a/lib/libZRCola/include/zrcola/common.h +++ b/lib/libZRCola/include/zrcola/common.h @@ -76,7 +76,7 @@ namespace ZRCola { /// Language ID type /// Three letter abbreviation, zero terminated /// - struct langid_t { + struct ZRCOLA_API langid_t { char data[4]; inline langid_t& operator=(const langid_t &src) @@ -99,15 +99,14 @@ namespace ZRCola { src[3] : 0; return *this; } + + /// + /// Blank language ID + /// + static const langid_t blank; }; - /// - /// Blank language ID - /// - const langid_t langid_t_blank = {}; - - /// /// Compares two language IDs /// diff --git a/lib/libZRCola/include/zrcola/translate.h b/lib/libZRCola/include/zrcola/translate.h index 5cf5dbc..6824a5c 100644 --- a/lib/libZRCola/include/zrcola/translate.h +++ b/lib/libZRCola/include/zrcola/translate.h @@ -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* map = NULL) const { - Decompose(input, inputMax, NULL, langid_t_blank, output, map); + Decompose(input, inputMax, NULL, langid_t::blank, output, map); } /// diff --git a/lib/libZRCola/src/character.cpp b/lib/libZRCola/src/character.cpp index a94a7b9..3d76d95 100644 --- a/lib/libZRCola/src/character.cpp +++ b/lib/libZRCola/src/character.cpp @@ -20,6 +20,9 @@ #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 &cats, _Inout_ std::map &hits, _Inout_ std::map &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const { assert(str); diff --git a/lib/libZRCola/src/common.cpp b/lib/libZRCola/src/common.cpp new file mode 100644 index 0000000..3f1b17b --- /dev/null +++ b/lib/libZRCola/src/common.cpp @@ -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 . +*/ + +#include "stdafx.h" + + +const ZRCola::langid_t ZRCola::langid_t::blank = {};