Clean-up
This commit is contained in:
parent
cc4a150501
commit
acbae76737
@ -42,8 +42,8 @@ wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
|
|||||||
dat >> rec;
|
dat >> rec;
|
||||||
if (!dat.good()) {
|
if (!dat.good()) {
|
||||||
wxFAIL_MSG(wxT("Error reading character group data from ZRCola.zrcdb."));
|
wxFAIL_MSG(wxT("Error reading character group data from ZRCola.zrcdb."));
|
||||||
m_cg_db.idxRnk.clear();
|
m_cg_db.idxRank.clear();
|
||||||
m_cg_db.data .clear();
|
m_cg_db.data .clear();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
wxFAIL_MSG(wxT("ZRCola.zrcdb has no character group data."));
|
wxFAIL_MSG(wxT("ZRCola.zrcdb has no character group data."));
|
||||||
@ -52,16 +52,16 @@ wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
|
|||||||
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
|
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cg_db.idxRnk.empty()) {
|
if (!m_cg_db.idxRank.empty()) {
|
||||||
// Populate character group list.
|
// Populate character group list.
|
||||||
for (size_t i = 0, n = m_cg_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = m_cg_db.idxRank.size(); i < n; i++) {
|
||||||
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRnk[i];
|
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRank[i];
|
||||||
wxString
|
wxString
|
||||||
label(cg.name(), cg.name_len()),
|
label(cg.name(), cg.name_len()),
|
||||||
label_tran2(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
|
label_tran2(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
|
||||||
m_choice->Insert(label_tran2, i);
|
m_choice->Insert(label_tran2, i);
|
||||||
}
|
}
|
||||||
m_cg_id = m_cg_db.idxRnk[0].id;
|
m_cg_id = m_cg_db.idxRank[0].grp;
|
||||||
m_choice->Select(0);
|
m_choice->Select(0);
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
@ -83,10 +83,10 @@ wxZRColaCharacterCatalogPanel::~wxZRColaCharacterCatalogPanel()
|
|||||||
|
|
||||||
void wxZRColaCharacterCatalogPanel::OnChoice(wxCommandEvent& event)
|
void wxZRColaCharacterCatalogPanel::OnChoice(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRnk[event.GetSelection()];
|
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRank[event.GetSelection()];
|
||||||
|
|
||||||
if (m_cg_id != cg.id) {
|
if (m_cg_id != cg.grp) {
|
||||||
m_cg_id = cg.id;
|
m_cg_id = cg.grp;
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ void wxZRColaCharacterCatalogPanel::OnFocusSource(wxCommandEvent& event)
|
|||||||
|
|
||||||
void wxZRColaCharacterCatalogPanel::Update()
|
void wxZRColaCharacterCatalogPanel::Update()
|
||||||
{
|
{
|
||||||
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRnk[m_choice->GetSelection()];
|
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRank[m_choice->GetSelection()];
|
||||||
|
|
||||||
if (m_show_all->GetValue()) {
|
if (m_show_all->GetValue()) {
|
||||||
m_grid->SetCharacters(
|
m_grid->SetCharacters(
|
||||||
@ -210,11 +210,11 @@ bool wxPersistentZRColaCharacterCatalogPanel::Restore()
|
|||||||
// Restore selected character group.
|
// Restore selected character group.
|
||||||
int cg_id;
|
int cg_id;
|
||||||
if (RestoreValue(wxT("charGroup"), &cg_id)) {
|
if (RestoreValue(wxT("charGroup"), &cg_id)) {
|
||||||
for (size_t i = 0, n = wnd->m_cg_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = wnd->m_cg_db.idxRank.size(); i < n; i++) {
|
||||||
const ZRCola::chrgrp_db::chrgrp &cg = wnd->m_cg_db.idxRnk[i];
|
const ZRCola::chrgrp_db::chrgrp &cg = wnd->m_cg_db.idxRank[i];
|
||||||
if (cg.id == cg_id) {
|
if (cg.grp == cg_id) {
|
||||||
if (wnd->m_cg_id != cg.id) {
|
if (wnd->m_cg_id != cg.grp) {
|
||||||
wnd->m_cg_id = cg.id;
|
wnd->m_cg_id = cg.grp;
|
||||||
wnd->m_choice->Select(i);
|
wnd->m_choice->Select(i);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
@ -217,11 +217,11 @@ wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) :
|
|||||||
|
|
||||||
// Fill categories.
|
// Fill categories.
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
|
||||||
const auto &cc = app->m_cc_db.idxRnk[i];
|
const auto &cc = app->m_cc_db.idxRank[i];
|
||||||
int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name(), cc.name_len()), wxT("ZRCola-zrcdb")), i);
|
int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name(), cc.name_len()), wxT("ZRCola-zrcdb")), i);
|
||||||
m_categories->Check(idx);
|
m_categories->Check(idx);
|
||||||
m_ccOrder.insert(std::make_pair(cc.id, idx));
|
m_ccOrder.insert(std::make_pair(cc.cat, idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetResults();
|
ResetResults();
|
||||||
@ -277,7 +277,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
char cc[sizeof(ZRCola::chrcat_db::chrcat)] = {};
|
char cc[sizeof(ZRCola::chrcat_db::chrcat)] = {};
|
||||||
((ZRCola::chrcat_db::chrcat*)cc)->id = chr.cat;
|
((ZRCola::chrcat_db::chrcat*)cc)->cat= chr.cat;
|
||||||
size_t start;
|
size_t start;
|
||||||
// Update character category.
|
// Update character category.
|
||||||
if (app->m_cc_db.idxChrCat.find(*((ZRCola::chrcat_db::chrcat*)cc), start)) {
|
if (app->m_cc_db.idxChrCat.find(*((ZRCola::chrcat_db::chrcat*)cc), start)) {
|
||||||
@ -359,10 +359,10 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
|||||||
m_searchThread->m_search.assign(val.c_str(), val.Length());
|
m_searchThread->m_search.assign(val.c_str(), val.Length());
|
||||||
|
|
||||||
// Select categories.
|
// Select categories.
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
|
||||||
const auto &cc = app->m_cc_db.idxRnk[i];
|
const auto &cc = app->m_cc_db.idxRank[i];
|
||||||
if (m_categories->IsChecked(i))
|
if (m_categories->IsChecked(i))
|
||||||
m_searchThread->m_cats.insert(cc.id);
|
m_searchThread->m_cats.insert(cc.cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_searchThread->Run() != wxTHREAD_NO_ERROR) {
|
if (m_searchThread->Run() != wxTHREAD_NO_ERROR) {
|
||||||
@ -407,7 +407,7 @@ void wxZRColaCharSelect::OnCategoriesAll(wxHyperlinkEvent& event)
|
|||||||
event.StopPropagation();
|
event.StopPropagation();
|
||||||
|
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++)
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
|
||||||
m_categories->Check(i, true);
|
m_categories->Check(i, true);
|
||||||
|
|
||||||
m_searchChanged = true;
|
m_searchChanged = true;
|
||||||
@ -419,7 +419,7 @@ void wxZRColaCharSelect::OnCategoriesNone(wxHyperlinkEvent& event)
|
|||||||
event.StopPropagation();
|
event.StopPropagation();
|
||||||
|
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++)
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
|
||||||
m_categories->Check(i, false);
|
m_categories->Check(i, false);
|
||||||
|
|
||||||
m_searchChanged = true;
|
m_searchChanged = true;
|
||||||
@ -431,7 +431,7 @@ void wxZRColaCharSelect::OnCategoriesInvert(wxHyperlinkEvent& event)
|
|||||||
event.StopPropagation();
|
event.StopPropagation();
|
||||||
|
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++)
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++)
|
||||||
m_categories->Check(i, !m_categories->IsChecked(i));
|
m_categories->Check(i, !m_categories->IsChecked(i));
|
||||||
|
|
||||||
m_searchChanged = true;
|
m_searchChanged = true;
|
||||||
@ -817,10 +817,10 @@ void wxPersistentZRColaCharSelect::Save() const
|
|||||||
}
|
}
|
||||||
SaveValue(wxT("recentChars2"), val);
|
SaveValue(wxT("recentChars2"), val);
|
||||||
|
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
|
||||||
const auto &cc = app->m_cc_db.idxRnk[i];
|
const auto &cc = app->m_cc_db.idxRank[i];
|
||||||
wxString name(wxT("category"));
|
wxString name(wxT("category"));
|
||||||
name.Append(cc.id.data, _countof(cc.id.data));
|
name.Append(cc.cat.data, _countof(cc.cat.data));
|
||||||
SaveValue(name, wnd->m_categories->IsChecked(i));
|
SaveValue(name, wnd->m_categories->IsChecked(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,10 +867,10 @@ bool wxPersistentZRColaCharSelect::Restore()
|
|||||||
wnd->m_gridRecent->SetCharacters(val);
|
wnd->m_gridRecent->SetCharacters(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
|
for (size_t i = 0, n = app->m_cc_db.idxRank.size(); i < n; i++) {
|
||||||
const auto &cc = app->m_cc_db.idxRnk[i];
|
const auto &cc = app->m_cc_db.idxRank[i];
|
||||||
wxString name(wxT("category"));
|
wxString name(wxT("category"));
|
||||||
name.Append(cc.id.data, _countof(cc.id.data));
|
name.Append(cc.cat.data, _countof(cc.cat.data));
|
||||||
bool val;
|
bool val;
|
||||||
if (RestoreValue(name, &val))
|
if (RestoreValue(name, &val))
|
||||||
wnd->m_categories->Check(i, val);
|
wnd->m_categories->Check(i, val);
|
||||||
|
@ -31,8 +31,8 @@ wxZRColaSettings::wxZRColaSettings(wxWindow* parent) :
|
|||||||
{
|
{
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
m_languages->Clear();
|
m_languages->Clear();
|
||||||
for (size_t i = 0, n = app->m_lang_db.idxLng.size(); i < n; i++) {
|
for (size_t i = 0, n = app->m_lang_db.idxLang.size(); i < n; i++) {
|
||||||
const auto &lang = app->m_lang_db.idxLng[i];
|
const auto &lang = app->m_lang_db.idxLang[i];
|
||||||
wxString
|
wxString
|
||||||
label(lang.name(), lang.name_len()),
|
label(lang.name(), lang.name_len()),
|
||||||
label_tran(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
|
label_tran(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
|
||||||
@ -59,9 +59,9 @@ void wxZRColaSettings::OnInitDialog(wxInitDialogEvent& event)
|
|||||||
|
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
char l[sizeof(ZRCola::language_db::language)] = {};
|
char l[sizeof(ZRCola::language_db::language)] = {};
|
||||||
((ZRCola::language_db::language*)l)->id = m_lang;
|
((ZRCola::language_db::language*)l)->lang = m_lang;
|
||||||
ZRCola::language_db::indexLang::size_type start;
|
ZRCola::language_db::indexLang::size_type start;
|
||||||
m_languages->Select(app->m_lang_db.idxLng.find(*(ZRCola::language_db::language*)l, start) ? start : -1);
|
m_languages->Select(app->m_lang_db.idxLang.find(*(ZRCola::language_db::language*)l, start) ? start : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,10 +122,10 @@ void wxZRColaSettings::OnApplyButtonClick(wxCommandEvent& event)
|
|||||||
m_lang_auto = false;
|
m_lang_auto = false;
|
||||||
|
|
||||||
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
|
||||||
const auto &lang = app->m_lang_db.idxLng[m_languages->GetSelection()];
|
const auto &lang = app->m_lang_db.idxLang[m_languages->GetSelection()];
|
||||||
|
|
||||||
if (m_lang != lang.id) {
|
if (m_lang != lang.lang) {
|
||||||
m_lang = lang.id;
|
m_lang = lang.lang;
|
||||||
|
|
||||||
// Notify destination text something changed and should re-inverse translate.
|
// Notify destination text something changed and should re-inverse translate.
|
||||||
wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED);
|
wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED);
|
||||||
@ -179,9 +179,9 @@ bool wxPersistentZRColaSettings::Restore()
|
|||||||
} else if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) {
|
} else if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) {
|
||||||
// The language was read from configuration.
|
// The language was read from configuration.
|
||||||
wnd->m_lang = lang.c_str();
|
wnd->m_lang = lang.c_str();
|
||||||
} else if (!app->m_lang_db.idxLng.empty()) {
|
} else if (!app->m_lang_db.idxLang.empty()) {
|
||||||
const auto &lang = app->m_lang_db.idxLng[0];
|
const auto &lang = app->m_lang_db.idxLang[0];
|
||||||
wnd->m_lang = lang.id;
|
wnd->m_lang = lang.lang;
|
||||||
} else
|
} else
|
||||||
wnd->m_lang = ZRCola::langid_t::blank;
|
wnd->m_lang = ZRCola::langid_t::blank;
|
||||||
|
|
||||||
|
@ -225,9 +225,9 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
ZRCola::translation_db db;
|
ZRCola::translation_db db;
|
||||||
|
|
||||||
// Preallocate memory.
|
// Preallocate memory.
|
||||||
db.idxTrans .reserve(count);
|
db.idxSrc.reserve(count);
|
||||||
db.idxTransInv.reserve(count);
|
db.idxDst.reserve(count);
|
||||||
db.data .reserve(count*5);
|
db.data .reserve(count*5);
|
||||||
|
|
||||||
// Parse translations and build index and data.
|
// Parse translations and build index and data.
|
||||||
for (auto t = db_temp2.cbegin(), t_end = db_temp2.cend(); t != t_end; ++t) {
|
for (auto t = db_temp2.cbegin(), t_end = db_temp2.cend(); t != t_end; ++t) {
|
||||||
@ -247,14 +247,14 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
db.data.push_back((unsigned __int16)n);
|
db.data.push_back((unsigned __int16)n);
|
||||||
db.data.insert(db.data.end(), t->first .cbegin(), t->first .cend());
|
db.data.insert(db.data.end(), t->first .cbegin(), t->first .cend());
|
||||||
db.data.insert(db.data.end(), d->second.str.cbegin(), d->second.str.cend());
|
db.data.insert(db.data.end(), d->second.str.cbegin(), d->second.str.cend());
|
||||||
db.idxTrans .push_back(idx);
|
db.idxSrc.push_back(idx);
|
||||||
db.idxTransInv.push_back(idx);
|
db.idxDst.push_back(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxTrans .sort();
|
db.idxSrc.sort();
|
||||||
db.idxTransInv.sort();
|
db.idxDst.sort();
|
||||||
|
|
||||||
// Write translations to file.
|
// Write translations to file.
|
||||||
dst << ZRCola::translation_rec(db);
|
dst << ZRCola::translation_rec(db);
|
||||||
@ -351,8 +351,8 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
ZRCola::language_db db;
|
ZRCola::language_db db;
|
||||||
|
|
||||||
// Preallocate memory.
|
// Preallocate memory.
|
||||||
db.idxLng.reserve(count);
|
db.idxLang.reserve(count);
|
||||||
db.data .reserve(count*4);
|
db.data .reserve(count*4);
|
||||||
|
|
||||||
// Parse languages and build index and data.
|
// Parse languages and build index and data.
|
||||||
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
||||||
@ -368,13 +368,13 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
wxASSERT_MSG(n <= 0xffff, wxT("language name overflow"));
|
wxASSERT_MSG(n <= 0xffff, wxT("language name overflow"));
|
||||||
db.data.push_back((unsigned __int16)n);
|
db.data.push_back((unsigned __int16)n);
|
||||||
db.data.insert(db.data.end(), lang.name.cbegin(), lang.name.cend());
|
db.data.insert(db.data.end(), lang.name.cbegin(), lang.name.cend());
|
||||||
db.idxLng.push_back(idx);
|
db.idxLang.push_back(idx);
|
||||||
} else
|
} else
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxLng.sort();
|
db.idxLang.sort();
|
||||||
|
|
||||||
// Write languages to file.
|
// Write languages to file.
|
||||||
dst << ZRCola::language_rec(db);
|
dst << ZRCola::language_rec(db);
|
||||||
@ -398,11 +398,11 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
ZRCola::langchar_db db;
|
ZRCola::langchar_db db;
|
||||||
|
|
||||||
// Preallocate memory.
|
// Preallocate memory.
|
||||||
db.idxChr.reserve(count);
|
db.idxChr .reserve(count);
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
db.idxLng.reserve(count);
|
db.idxLang.reserve(count);
|
||||||
#endif
|
#endif
|
||||||
db.data .reserve(count*4);
|
db.data .reserve(count*4);
|
||||||
|
|
||||||
// Parse language characters and build index and data.
|
// Parse language characters and build index and data.
|
||||||
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
||||||
@ -415,9 +415,9 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
|
||||||
db.data.push_back((unsigned __int16)n);
|
db.data.push_back((unsigned __int16)n);
|
||||||
db.data.insert(db.data.end(), lc.chr.cbegin(), lc.chr.cend());
|
db.data.insert(db.data.end(), lc.chr.cbegin(), lc.chr.cend());
|
||||||
db.idxChr.push_back(idx);
|
db.idxChr .push_back(idx);
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
db.idxLng.push_back(idx);
|
db.idxLang.push_back(idx);
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
@ -426,7 +426,7 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxChr .sort();
|
db.idxChr .sort();
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
db.idxLng.sort();
|
db.idxLang.sort();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Write language characters to file.
|
// Write language characters to file.
|
||||||
@ -451,8 +451,8 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
ZRCola::chrgrp_db db;
|
ZRCola::chrgrp_db db;
|
||||||
|
|
||||||
// Preallocate memory.
|
// Preallocate memory.
|
||||||
db.idxRnk.reserve(count);
|
db.idxRank.reserve(count);
|
||||||
db.data .reserve(count*4);
|
db.data .reserve(count*4);
|
||||||
|
|
||||||
// Parse character groups and build index and data.
|
// Parse character groups and build index and data.
|
||||||
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
for (; !ZRCola::DBSource::IsEOF(rs); rs->MoveNext()) {
|
||||||
@ -481,13 +481,13 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
db.data.insert(db.data.end(), cg.name .cbegin(), cg.name .cend());
|
db.data.insert(db.data.end(), cg.name .cbegin(), cg.name .cend());
|
||||||
db.data.insert(db.data.end(), cg.chars.cbegin(), cg.chars.cend());
|
db.data.insert(db.data.end(), cg.chars.cbegin(), cg.chars.cend());
|
||||||
db.data.insert(db.data.end(), cg.show .cbegin(), cg.show .cend());
|
db.data.insert(db.data.end(), cg.show .cbegin(), cg.show .cend());
|
||||||
db.idxRnk.push_back(idx);
|
db.idxRank.push_back(idx);
|
||||||
} else
|
} else
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxRnk.sort();
|
db.idxRank.sort();
|
||||||
|
|
||||||
// Write character groups to file.
|
// Write character groups to file.
|
||||||
dst << ZRCola::chrgrp_rec(db);
|
dst << ZRCola::chrgrp_rec(db);
|
||||||
@ -589,7 +589,7 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
|
|
||||||
// Preallocate memory.
|
// Preallocate memory.
|
||||||
db.idxChrCat.reserve(count);
|
db.idxChrCat.reserve(count);
|
||||||
db.idxRnk .reserve(count);
|
db.idxRank .reserve(count);
|
||||||
db.data .reserve(count*4);
|
db.data .reserve(count*4);
|
||||||
|
|
||||||
// Parse character categories and build index and data.
|
// Parse character categories and build index and data.
|
||||||
@ -614,14 +614,14 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
db.data.push_back((unsigned __int16)n);
|
db.data.push_back((unsigned __int16)n);
|
||||||
db.data.insert(db.data.end(), cc.name.cbegin(), cc.name.cend());
|
db.data.insert(db.data.end(), cc.name.cbegin(), cc.name.cend());
|
||||||
db.idxChrCat.push_back(idx);
|
db.idxChrCat.push_back(idx);
|
||||||
db.idxRnk .push_back(idx);
|
db.idxRank .push_back(idx);
|
||||||
} else
|
} else
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxChrCat.sort();
|
db.idxChrCat.sort();
|
||||||
db.idxRnk .sort();
|
db.idxRank .sort();
|
||||||
|
|
||||||
// Write character categories to file.
|
// Write character categories to file.
|
||||||
dst << ZRCola::chrcat_rec(db);
|
dst << ZRCola::chrcat_rec(db);
|
||||||
@ -668,7 +668,7 @@ int _tmain(int argc, _TCHAR *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort indices.
|
// Sort indices.
|
||||||
db.idxChr .sort();
|
db.idxChr.sort();
|
||||||
db.idxTag.sort();
|
db.idxTag.sort();
|
||||||
|
|
||||||
// Write characters tags to file.
|
// Write characters tags to file.
|
||||||
|
@ -184,7 +184,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
struct character {
|
struct character {
|
||||||
public:
|
public:
|
||||||
chrcatid_t cat; ///> Category ID
|
chrcatid_t cat; ///> Character category ID
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned __int16 chr_to; ///< Character end in \c data
|
unsigned __int16 chr_to; ///< Character end in \c data
|
||||||
@ -249,7 +249,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Character index
|
/// Character index
|
||||||
///
|
///
|
||||||
class indexChar : public index<unsigned __int16, unsigned __int32, character>
|
class indexChr : public index<unsigned __int16, unsigned __int32, character>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -257,7 +257,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexChar(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, character>(h) {}
|
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, character>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two characters by ID (for searching)
|
/// Compares two characters by ID (for searching)
|
||||||
@ -327,7 +327,7 @@ namespace ZRCola {
|
|||||||
assert(len <= 0xffff);
|
assert(len <= 0xffff);
|
||||||
std::unique_ptr<character> c((character*)new char[sizeof(character) + sizeof(wchar_t)*len]);
|
std::unique_ptr<character> c((character*)new char[sizeof(character) + sizeof(wchar_t)*len]);
|
||||||
c->character::character(chr, len);
|
c->character::character(chr, len);
|
||||||
indexChar::size_type start;
|
indexChr::size_type start;
|
||||||
return idxChr.find(*c, start) ? idxChr[start].cat : chrcatid_t::blank;
|
return idxChr.find(*c, start) ? idxChr[start].cat : chrcatid_t::blank;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -348,7 +348,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
struct chrcat {
|
struct chrcat {
|
||||||
public:
|
public:
|
||||||
chrcatid_t id; ///< Character category ID
|
chrcatid_t cat; ///< Character category ID
|
||||||
unsigned __int16 rank; ///< Character category rank
|
unsigned __int16 rank; ///< Character category rank
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -363,18 +363,18 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the character category
|
/// Constructs the character category
|
||||||
///
|
///
|
||||||
/// \param[in] id Character category ID
|
/// \param[in] cat Character category ID
|
||||||
/// \param[in] rank Character category rank
|
/// \param[in] rank Character category rank
|
||||||
/// \param[in] name Character category name
|
/// \param[in] name Character category name
|
||||||
/// \param[in] name_len Number of UTF-16 characters in \p name
|
/// \param[in] name_len Number of UTF-16 characters in \p name
|
||||||
///
|
///
|
||||||
inline chrcat(
|
inline chrcat(
|
||||||
_In_opt_ chrcatid_t id = chrcatid_t::blank,
|
_In_opt_ chrcatid_t cat = chrcatid_t::blank,
|
||||||
_In_opt_ unsigned __int16 rank = 0,
|
_In_opt_ unsigned __int16 rank = 0,
|
||||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||||
_In_opt_ size_t name_len = 0)
|
_In_opt_ size_t name_len = 0)
|
||||||
{
|
{
|
||||||
this->id = id;
|
this->cat = cat;
|
||||||
this->rank = rank;
|
this->rank = rank;
|
||||||
this->name_to = static_cast<unsigned __int16>(name_len);
|
this->name_to = static_cast<unsigned __int16>(name_len);
|
||||||
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
||||||
@ -414,11 +414,12 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
|
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
|
||||||
{
|
{
|
||||||
if (a.id < b.id) return -1;
|
if (a.cat < b.cat) return -1;
|
||||||
else if (a.id > b.id) return 1;
|
else if (a.cat > b.cat) return 1;
|
||||||
else return 0;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
} idxChrCat; ///< Character category index
|
} idxChrCat; ///< Character category index
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Rank index
|
/// Rank index
|
||||||
@ -478,7 +479,7 @@ namespace ZRCola {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxRnk; ///< Rank index
|
} idxRank; ///< Rank index
|
||||||
|
|
||||||
std::vector<unsigned __int16> data; ///< Character category data
|
std::vector<unsigned __int16> data; ///< Character category data
|
||||||
|
|
||||||
@ -486,7 +487,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the database
|
/// Constructs the database
|
||||||
///
|
///
|
||||||
inline chrcat_db() : idxChrCat(data), idxRnk(data) {}
|
inline chrcat_db() : idxChrCat(data), idxRank(data) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clears the database
|
/// Clears the database
|
||||||
@ -494,7 +495,7 @@ namespace ZRCola {
|
|||||||
inline void clear()
|
inline void clear()
|
||||||
{
|
{
|
||||||
idxChrCat.clear();
|
idxChrCat.clear();
|
||||||
idxRnk .clear();
|
idxRank .clear();
|
||||||
data .clear();
|
data .clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -605,7 +606,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
|||||||
|
|
||||||
// Write rank index.
|
// Write rank index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxRnk;
|
stream << db.idxRank;
|
||||||
|
|
||||||
// Write data count.
|
// Write data count.
|
||||||
auto data_count = db.data.size();
|
auto data_count = db.data.size();
|
||||||
@ -643,7 +644,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat
|
|||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read rank index.
|
// Read rank index.
|
||||||
stream >> db.idxRnk;
|
stream >> db.idxRank;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read data count.
|
// Read data count.
|
||||||
|
@ -85,7 +85,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Character index
|
/// Character index
|
||||||
///
|
///
|
||||||
class indexChar : public index<unsigned __int16, unsigned __int32, langchar>
|
class indexChr : public index<unsigned __int16, unsigned __int32, langchar>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -93,7 +93,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexChar(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
|
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two characters by ID (for searching)
|
/// Compares two characters by ID (for searching)
|
||||||
@ -121,9 +121,9 @@ namespace ZRCola {
|
|||||||
|
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
///
|
///
|
||||||
/// Character Language Index
|
/// Language Index
|
||||||
///
|
///
|
||||||
class indexCharLang : public index<unsigned __int16, unsigned __int32, langchar>
|
class indexLang : public index<unsigned __int16, unsigned __int32, langchar>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -131,7 +131,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexCharLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
|
indexLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two languages by ID (for searching)
|
/// Compares two languages by ID (for searching)
|
||||||
@ -154,7 +154,7 @@ namespace ZRCola {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxLng; ///< Character language index
|
} idxLang; ///< Language index
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<unsigned __int16> data; ///< Character data
|
std::vector<unsigned __int16> data; ///< Character data
|
||||||
@ -165,7 +165,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
inline langchar_db() : idxChr(data)
|
inline langchar_db() : idxChr(data)
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
, idxLng(data)
|
, idxLang(data)
|
||||||
#endif
|
#endif
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -174,11 +174,11 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
inline void clear()
|
inline void clear()
|
||||||
{
|
{
|
||||||
idxChr.clear();
|
idxChr .clear();
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
idxLng.clear();
|
idxLang.clear();
|
||||||
#endif
|
#endif
|
||||||
data .clear();
|
data .clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -210,7 +210,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
struct language {
|
struct language {
|
||||||
public:
|
public:
|
||||||
langid_t id; ///< Language ID
|
langid_t lang; ///< Language ID
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned __int16 name_to; ///< Language name end in \c data
|
unsigned __int16 name_to; ///< Language name end in \c data
|
||||||
@ -224,16 +224,16 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the language
|
/// Constructs the language
|
||||||
///
|
///
|
||||||
/// \param[in] id Language ID
|
/// \param[in] lang Language ID
|
||||||
/// \param[in] name Language name
|
/// \param[in] name Language name
|
||||||
/// \param[in] name_len Number of UTF-16 characters in \p name
|
/// \param[in] name_len Number of UTF-16 characters in \p name
|
||||||
///
|
///
|
||||||
inline language(
|
inline language(
|
||||||
_In_opt_ langid_t id = langid_t::blank,
|
_In_opt_ langid_t lang = langid_t::blank,
|
||||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||||
_In_opt_ size_t name_len = 0)
|
_In_opt_ size_t name_len = 0)
|
||||||
{
|
{
|
||||||
this->id = id;
|
this->lang = lang;
|
||||||
this->name_to = static_cast<unsigned __int16>(name_len);
|
this->name_to = static_cast<unsigned __int16>(name_len);
|
||||||
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
||||||
}
|
}
|
||||||
@ -272,12 +272,12 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
virtual int compare(_In_ const language &a, _In_ const language &b) const
|
virtual int compare(_In_ const language &a, _In_ const language &b) const
|
||||||
{
|
{
|
||||||
if (a.id < b.id) return -1;
|
if (a.lang < b.lang) return -1;
|
||||||
else if (a.id > b.id) return 1;
|
else if (a.lang > b.lang) return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxLng; ///< Language index
|
} idxLang; ///< Language index
|
||||||
|
|
||||||
std::vector<unsigned __int16> data; ///< Language data
|
std::vector<unsigned __int16> data; ///< Language data
|
||||||
|
|
||||||
@ -285,15 +285,15 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the database
|
/// Constructs the database
|
||||||
///
|
///
|
||||||
inline language_db() : idxLng(data) {}
|
inline language_db() : idxLang(data) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clears the database
|
/// Clears the database
|
||||||
///
|
///
|
||||||
inline void clear()
|
inline void clear()
|
||||||
{
|
{
|
||||||
idxLng.clear();
|
idxLang.clear();
|
||||||
data .clear();
|
data .clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
|
|||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
// Write language index.
|
// Write language index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxLng;
|
stream << db.idxLang;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Write data count.
|
// Write data count.
|
||||||
@ -363,7 +363,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langch
|
|||||||
|
|
||||||
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
|
||||||
// Read language index.
|
// Read language index.
|
||||||
stream >> db.idxLng;
|
stream >> db.idxLang;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
|
|||||||
{
|
{
|
||||||
// Write language index.
|
// Write language index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxLng;
|
stream << db.idxLang;
|
||||||
|
|
||||||
// Write data count.
|
// Write data count.
|
||||||
auto data_count = db.data.size();
|
auto data_count = db.data.size();
|
||||||
@ -429,7 +429,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
|
|||||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::language_db &db)
|
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::language_db &db)
|
||||||
{
|
{
|
||||||
// Read language index.
|
// Read language index.
|
||||||
stream >> db.idxLng;
|
stream >> db.idxLang;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read data count.
|
// Read data count.
|
||||||
|
@ -87,7 +87,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Character Index
|
/// Character Index
|
||||||
///
|
///
|
||||||
class indexChar : public index<unsigned __int16, unsigned __int32, chrtag>
|
class indexChr : public index<unsigned __int16, unsigned __int32, chrtag>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -95,7 +95,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexChar(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrtag>(h) {}
|
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrtag>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two character tags by character (for searching)
|
/// Compares two character tags by character (for searching)
|
||||||
|
@ -123,7 +123,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Translation index
|
/// Translation index
|
||||||
///
|
///
|
||||||
class indexTrans : public index<unsigned __int16, unsigned __int32, translation>
|
class indexSrc : public index<unsigned __int16, unsigned __int32, translation>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -131,7 +131,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexTrans(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
|
indexSrc(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two transformations by string (for searching)
|
/// Compares two transformations by string (for searching)
|
||||||
@ -182,13 +182,13 @@ namespace ZRCola {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxTrans; ///< Translation index
|
} idxSrc; ///< Translation index
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Inverse translation index
|
/// Inverse translation index
|
||||||
///
|
///
|
||||||
class indexTransInv : public index<unsigned __int16, unsigned __int32, translation>
|
class indexDst : public index<unsigned __int16, unsigned __int32, translation>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
@ -196,7 +196,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// \param[in] h Reference to vector holding the data
|
/// \param[in] h Reference to vector holding the data
|
||||||
///
|
///
|
||||||
indexTransInv(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
|
indexDst(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Compares two transformations by character (for searching)
|
/// Compares two transformations by character (for searching)
|
||||||
@ -247,7 +247,7 @@ namespace ZRCola {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxTransInv; ///< Inverse translation index
|
} idxDst; ///< Inverse translation index
|
||||||
|
|
||||||
|
|
||||||
std::vector<unsigned __int16> data; ///< Transformation data
|
std::vector<unsigned __int16> data; ///< Transformation data
|
||||||
@ -256,16 +256,16 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the database
|
/// Constructs the database
|
||||||
///
|
///
|
||||||
inline translation_db() : idxTrans(data), idxTransInv(data) {}
|
inline translation_db() : idxSrc(data), idxDst(data) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clears the database
|
/// Clears the database
|
||||||
///
|
///
|
||||||
inline void clear()
|
inline void clear()
|
||||||
{
|
{
|
||||||
idxTrans .clear();
|
idxSrc.clear();
|
||||||
idxTransInv.clear();
|
idxDst.clear();
|
||||||
data .clear();
|
data .clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -309,10 +309,114 @@ namespace ZRCola {
|
|||||||
|
|
||||||
|
|
||||||
typedef ZRCOLA_API stdex::idrec::record<translation_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> translation_rec;
|
typedef ZRCOLA_API stdex::idrec::record<translation_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> translation_rec;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Translation set database
|
||||||
|
///
|
||||||
|
class ZRCOLA_API transet_db {
|
||||||
|
public:
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(2)
|
||||||
|
///
|
||||||
|
/// Translation set data
|
||||||
|
///
|
||||||
|
struct transet {
|
||||||
|
public:
|
||||||
|
transetid_t set; ///< Translation set ID
|
||||||
|
|
||||||
|
protected:
|
||||||
|
unsigned __int16 name_to; ///< Translation set name end in \c data
|
||||||
|
wchar_t data[]; ///< Translation set name
|
||||||
|
|
||||||
|
private:
|
||||||
|
inline transet(_In_ const transet &other);
|
||||||
|
inline transet& operator=(_In_ const transet &other);
|
||||||
|
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs the translation set
|
||||||
|
///
|
||||||
|
/// \param[in] set Translation set ID
|
||||||
|
/// \param[in] name Translation set name
|
||||||
|
/// \param[in] name_len Number of UTF-16 characters in \p name
|
||||||
|
///
|
||||||
|
inline transet(
|
||||||
|
_In_opt_ transetid_t set = 0,
|
||||||
|
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||||
|
_In_opt_ size_t name_len = 0)
|
||||||
|
{
|
||||||
|
this->set = set;
|
||||||
|
this->name_to = static_cast<unsigned __int16>(name_len);
|
||||||
|
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const wchar_t* name () const { return data; };
|
||||||
|
inline wchar_t* name () { return data; };
|
||||||
|
inline const wchar_t* name_end() const { return data + name_to; };
|
||||||
|
inline wchar_t* name_end() { return data + name_to; };
|
||||||
|
inline unsigned __int16 name_len() const { return name_to; };
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Translation set index
|
||||||
|
///
|
||||||
|
class indexTranSet : public index<unsigned __int16, unsigned __int32, transet>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs the index
|
||||||
|
///
|
||||||
|
/// \param[in] h Reference to vector holding the data
|
||||||
|
///
|
||||||
|
indexTranSet(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, transet>(h) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Compares two translation sets by ID (for searching)
|
||||||
|
///
|
||||||
|
/// \param[in] a Pointer to first element
|
||||||
|
/// \param[in] b Pointer to second element
|
||||||
|
///
|
||||||
|
/// \returns
|
||||||
|
/// - <0 when a < b
|
||||||
|
/// - =0 when a == b
|
||||||
|
/// - >0 when a > b
|
||||||
|
///
|
||||||
|
virtual int compare(_In_ const transet &a, _In_ const transet &b) const
|
||||||
|
{
|
||||||
|
if (a.set < b.set) return -1;
|
||||||
|
else if (a.set > b.set) return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} idxTranSet; ///< Translation set index
|
||||||
|
|
||||||
|
std::vector<unsigned __int16> data; ///< Translation set data
|
||||||
|
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Constructs the database
|
||||||
|
///
|
||||||
|
inline transet_db() : idxTranSet(data) {}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Clears the database
|
||||||
|
///
|
||||||
|
inline void clear()
|
||||||
|
{
|
||||||
|
idxTranSet.clear();
|
||||||
|
data .clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef ZRCOLA_API stdex::idrec::record<transet_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> transet_rec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const ZRCola::recordid_t ZRCola::translation_rec::id = *(ZRCola::recordid_t*)"TRN";
|
const ZRCola::recordid_t ZRCola::translation_rec::id = *(ZRCola::recordid_t*)"TRN";
|
||||||
|
const ZRCola::recordid_t ZRCola::transet_rec ::id = *(ZRCola::recordid_t*)"TSE";
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -327,11 +431,11 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
|||||||
{
|
{
|
||||||
// Write translation index.
|
// Write translation index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxTrans;
|
stream << db.idxSrc;
|
||||||
|
|
||||||
// Write inverse translation index.
|
// Write inverse translation index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxTransInv;
|
stream << db.idxDst;
|
||||||
|
|
||||||
// Write data count.
|
// Write data count.
|
||||||
auto data_count = db.data.size();
|
auto data_count = db.data.size();
|
||||||
@ -365,11 +469,76 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
|||||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db)
|
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db)
|
||||||
{
|
{
|
||||||
// Read translation index.
|
// Read translation index.
|
||||||
stream >> db.idxTrans;
|
stream >> db.idxSrc;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read inverse translation index.
|
// Read inverse translation index.
|
||||||
stream >> db.idxTransInv;
|
stream >> db.idxDst;
|
||||||
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
|
// Read data count.
|
||||||
|
unsigned __int32 count;
|
||||||
|
stream.read((char*)&count, sizeof(count));
|
||||||
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
// Read data.
|
||||||
|
db.data.resize(count);
|
||||||
|
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
|
||||||
|
} else
|
||||||
|
db.data.clear();
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Writes translation set database to a stream
|
||||||
|
///
|
||||||
|
/// \param[in] stream Output stream
|
||||||
|
/// \param[in] db Translation set database
|
||||||
|
///
|
||||||
|
/// \returns The stream \p stream
|
||||||
|
///
|
||||||
|
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::transet_db &db)
|
||||||
|
{
|
||||||
|
// Write translation set index.
|
||||||
|
if (stream.fail()) return stream;
|
||||||
|
stream << db.idxTranSet;
|
||||||
|
|
||||||
|
// Write data count.
|
||||||
|
auto data_count = db.data.size();
|
||||||
|
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
|
||||||
|
// 4G check
|
||||||
|
if (data_count > 0xffffffff) {
|
||||||
|
stream.setstate(std::ios_base::failbit);
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (stream.fail()) return stream;
|
||||||
|
unsigned __int32 count = (unsigned __int32)data_count;
|
||||||
|
stream.write((const char*)&count, sizeof(count));
|
||||||
|
|
||||||
|
// Write data.
|
||||||
|
if (stream.fail()) return stream;
|
||||||
|
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reads translation set database from a stream
|
||||||
|
///
|
||||||
|
/// \param[in ] stream Input stream
|
||||||
|
/// \param[out] db Translation set database
|
||||||
|
///
|
||||||
|
/// \returns The stream \p stream
|
||||||
|
///
|
||||||
|
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transet_db &db)
|
||||||
|
{
|
||||||
|
// Read translation set index.
|
||||||
|
stream >> db.idxTranSet;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read data count.
|
// Read data count.
|
||||||
|
@ -77,6 +77,6 @@ bool ZRCola::langchar_db::IsLocalCharacter(_In_ const wchar_t *chr, _In_ const w
|
|||||||
assert(n <= 0xffff);
|
assert(n <= 0xffff);
|
||||||
std::unique_ptr<langchar> lc((langchar*)new char[sizeof(langchar) + sizeof(wchar_t)*n]);
|
std::unique_ptr<langchar> lc((langchar*)new char[sizeof(langchar) + sizeof(wchar_t)*n]);
|
||||||
lc->langchar::langchar(lang, chr, n);
|
lc->langchar::langchar(lang, chr, n);
|
||||||
indexChar::size_type start;
|
indexChr::size_type start;
|
||||||
return idxChr.find(*lc, start);
|
return idxChr.find(*lc, start);
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
|||||||
map->clear();
|
map->clear();
|
||||||
|
|
||||||
// Limit search to the given set first.
|
// Limit search to the given set first.
|
||||||
indexTrans::size_type l_set, r_set;
|
indexSrc::size_type l_set, r_set;
|
||||||
idxTrans.find(translation(set ), l_set);
|
idxSrc.find(translation(set ), l_set);
|
||||||
idxTrans.find(translation(set + 1), r_set);
|
idxSrc.find(translation(set + 1), r_set);
|
||||||
|
|
||||||
for (size_t i = 0; i < inputMax;) {
|
for (size_t i = 0; i < inputMax;) {
|
||||||
// Find the longest matching translation at i-th character.
|
// Find the longest matching translation at i-th character.
|
||||||
@ -50,7 +50,7 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
|||||||
// Get the j-th character of the translation.
|
// Get the j-th character of the translation.
|
||||||
// All translations that get short on characters are lexically ordered before.
|
// All translations that get short on characters are lexically ordered before.
|
||||||
// Thus the j-th character is considered 0.
|
// Thus the j-th character is considered 0.
|
||||||
const translation &trans = idxTrans[m];
|
const translation &trans = idxSrc[m];
|
||||||
wchar_t s = trans.src_at(j);
|
wchar_t s = trans.src_at(j);
|
||||||
|
|
||||||
// Do the bisection test.
|
// Do the bisection test.
|
||||||
@ -62,7 +62,7 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
|||||||
// Narrow the search area on the left to start at the first translation in the run.
|
// Narrow the search area on the left to start at the first translation in the run.
|
||||||
for (size_t rr = m; l < rr;) {
|
for (size_t rr = m; l < rr;) {
|
||||||
size_t m = (l + rr) / 2;
|
size_t m = (l + rr) / 2;
|
||||||
const translation &trans = idxTrans[m];
|
const translation &trans = idxSrc[m];
|
||||||
wchar_t s = trans.src_at(j);
|
wchar_t s = trans.src_at(j);
|
||||||
if (c <= s) rr = m; else l = m + 1;
|
if (c <= s) rr = m; else l = m + 1;
|
||||||
}
|
}
|
||||||
@ -70,12 +70,12 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
|||||||
// Narrow the search area on the right to end at the first translation not in the run.
|
// Narrow the search area on the right to end at the first translation not in the run.
|
||||||
for (size_t ll = m + 1; ll < r;) {
|
for (size_t ll = m + 1; ll < r;) {
|
||||||
size_t m = (ll + r) / 2;
|
size_t m = (ll + r) / 2;
|
||||||
const translation &trans = idxTrans[m];
|
const translation &trans = idxSrc[m];
|
||||||
wchar_t s = trans.src_at(j);
|
wchar_t s = trans.src_at(j);
|
||||||
if (s <= c) ll = m + 1; else r = m;
|
if (s <= c) ll = m + 1; else r = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
const translation &trans = idxTrans[l];
|
const translation &trans = idxSrc[l];
|
||||||
if (j + 1 == trans.src_len()) {
|
if (j + 1 == trans.src_len()) {
|
||||||
// The first translation of the run was a match (thus far). Save it.
|
// The first translation of the run was a match (thus far). Save it.
|
||||||
l_match = l;
|
l_match = l;
|
||||||
@ -88,7 +88,7 @@ void ZRCola::translation_db::Translate(_In_ transetid_t set, _In_z_count_(inputM
|
|||||||
|
|
||||||
if (l_match < r_set) {
|
if (l_match < r_set) {
|
||||||
// The saved translation was an exact match.
|
// The saved translation was an exact match.
|
||||||
const translation &trans = idxTrans[l_match];
|
const translation &trans = idxSrc[l_match];
|
||||||
output.append(trans.dst(), trans.dst_end());
|
output.append(trans.dst(), trans.dst_end());
|
||||||
i += trans.src_len();
|
i += trans.src_len();
|
||||||
if (trans.src_len() != trans.dst_len() && map) {
|
if (trans.src_len() != trans.dst_len() && map) {
|
||||||
@ -118,9 +118,9 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
|||||||
map->clear();
|
map->clear();
|
||||||
|
|
||||||
// Limit search to the given set first.
|
// Limit search to the given set first.
|
||||||
indexTransInv::size_type l_set, r_set;
|
indexDst::size_type l_set, r_set;
|
||||||
idxTransInv.find(translation(set ), l_set);
|
idxDst.find(translation(set ), l_set);
|
||||||
idxTransInv.find(translation(set + 1), r_set);
|
idxDst.find(translation(set + 1), r_set);
|
||||||
|
|
||||||
for (size_t i = 0; i < inputMax;) {
|
for (size_t i = 0; i < inputMax;) {
|
||||||
// Find the longest matching inverse translation at i-th character.
|
// Find the longest matching inverse translation at i-th character.
|
||||||
@ -134,7 +134,7 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
|||||||
// Get the j-th character of the inverse translation.
|
// Get the j-th character of the inverse translation.
|
||||||
// All inverse translations that get short on characters are lexically ordered before.
|
// All inverse translations that get short on characters are lexically ordered before.
|
||||||
// Thus the j-th character is considered 0.
|
// Thus the j-th character is considered 0.
|
||||||
const translation &trans = idxTransInv[m];
|
const translation &trans = idxDst[m];
|
||||||
wchar_t s = trans.dst_at(j);
|
wchar_t s = trans.dst_at(j);
|
||||||
|
|
||||||
// Do the bisection test.
|
// Do the bisection test.
|
||||||
@ -146,7 +146,7 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
|||||||
// Narrow the search area on the left to start at the first inverse translation in the run.
|
// Narrow the search area on the left to start at the first inverse translation in the run.
|
||||||
for (size_t rr = m; l < rr;) {
|
for (size_t rr = m; l < rr;) {
|
||||||
size_t m = (l + rr) / 2;
|
size_t m = (l + rr) / 2;
|
||||||
const translation &trans = idxTransInv[m];
|
const translation &trans = idxDst[m];
|
||||||
wchar_t s = trans.dst_at(j);
|
wchar_t s = trans.dst_at(j);
|
||||||
if (c <= s) rr = m; else l = m + 1;
|
if (c <= s) rr = m; else l = m + 1;
|
||||||
}
|
}
|
||||||
@ -154,12 +154,12 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
|||||||
// Narrow the search area on the right to end at the first inverse translation not in the run.
|
// Narrow the search area on the right to end at the first inverse translation not in the run.
|
||||||
for (size_t ll = m + 1; ll < r;) {
|
for (size_t ll = m + 1; ll < r;) {
|
||||||
size_t m = (ll + r) / 2;
|
size_t m = (ll + r) / 2;
|
||||||
const translation &trans = idxTransInv[m];
|
const translation &trans = idxDst[m];
|
||||||
wchar_t s = trans.dst_at(j);
|
wchar_t s = trans.dst_at(j);
|
||||||
if (s <= c) ll = m + 1; else r = m;
|
if (s <= c) ll = m + 1; else r = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
const translation &trans = idxTransInv[l];
|
const translation &trans = idxDst[l];
|
||||||
if (j + 1 == trans.dst_len()) {
|
if (j + 1 == trans.dst_len()) {
|
||||||
// The first inverse translation of the run was a match (thus far). Save it.
|
// The first inverse translation of the run was a match (thus far). Save it.
|
||||||
l_match = l;
|
l_match = l;
|
||||||
@ -172,7 +172,7 @@ void ZRCola::translation_db::TranslateInv(_In_ transetid_t set, _In_z_count_(inp
|
|||||||
|
|
||||||
if (l_match < r_set) {
|
if (l_match < r_set) {
|
||||||
// The saved inverse translation was an exact match.
|
// The saved inverse translation was an exact match.
|
||||||
const translation &trans = idxTransInv[l_match];
|
const translation &trans = idxDst[l_match];
|
||||||
if (trans.src_len() && trans.src()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.dst(), trans.dst_end(), lang))) {
|
if (trans.src_len() && trans.src()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.dst(), trans.dst_end(), lang))) {
|
||||||
// Append source sequence.
|
// Append source sequence.
|
||||||
output.append(trans.src(), trans.src_end());
|
output.append(trans.src(), trans.src_end());
|
||||||
|
@ -35,6 +35,12 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ZRCola {
|
namespace ZRCola {
|
||||||
|
///
|
||||||
|
/// Character group ID
|
||||||
|
///
|
||||||
|
typedef unsigned __int16 chrgrpid_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Character group database
|
/// Character group database
|
||||||
///
|
///
|
||||||
@ -47,7 +53,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
struct chrgrp {
|
struct chrgrp {
|
||||||
public:
|
public:
|
||||||
unsigned __int16 id; ///< Character group ID
|
chrgrpid_t grp; ///< Character group ID
|
||||||
unsigned __int16 rank; ///< Character group rank
|
unsigned __int16 rank; ///< Character group rank
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -59,7 +65,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the character group
|
/// Constructs the character group
|
||||||
///
|
///
|
||||||
/// \param[in] id Character group ID
|
/// \param[in] grp Character group ID
|
||||||
/// \param[in] rank Character group rank
|
/// \param[in] rank Character group rank
|
||||||
/// \param[in] name Character group name
|
/// \param[in] name Character group name
|
||||||
/// \param[in] name_len Number of UTF-16 characters in \p name
|
/// \param[in] name_len Number of UTF-16 characters in \p name
|
||||||
@ -68,7 +74,7 @@ namespace ZRCola {
|
|||||||
/// \param[in] chrshow Binary vector which particular character is displayed initially
|
/// \param[in] chrshow Binary vector which particular character is displayed initially
|
||||||
///
|
///
|
||||||
inline chrgrp(
|
inline chrgrp(
|
||||||
_In_opt_ unsigned __int16 id = 0,
|
_In_opt_ chrgrpid_t grp = 0,
|
||||||
_In_opt_ unsigned __int16 rank = 0,
|
_In_opt_ unsigned __int16 rank = 0,
|
||||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||||
_In_opt_ size_t name_len = 0,
|
_In_opt_ size_t name_len = 0,
|
||||||
@ -76,7 +82,7 @@ namespace ZRCola {
|
|||||||
_In_opt_ size_t chrlst_len = 0,
|
_In_opt_ size_t chrlst_len = 0,
|
||||||
_In_opt_count_x_((chrlst_len + 15)/16) const unsigned __int16 *chrshow = NULL)
|
_In_opt_count_x_((chrlst_len + 15)/16) const unsigned __int16 *chrshow = NULL)
|
||||||
{
|
{
|
||||||
this->id = id;
|
this->grp = grp;
|
||||||
this->rank = rank;
|
this->rank = rank;
|
||||||
this->name_to = static_cast<unsigned __int16>(name_len);
|
this->name_to = static_cast<unsigned __int16>(name_len);
|
||||||
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
if (name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
|
||||||
@ -165,7 +171,7 @@ namespace ZRCola {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} idxRnk; ///< Rank index
|
} idxRank; ///< Rank index
|
||||||
|
|
||||||
std::vector<unsigned __int16> data; ///< Character groups data
|
std::vector<unsigned __int16> data; ///< Character groups data
|
||||||
|
|
||||||
@ -173,7 +179,7 @@ namespace ZRCola {
|
|||||||
///
|
///
|
||||||
/// Constructs the database
|
/// Constructs the database
|
||||||
///
|
///
|
||||||
inline chrgrp_db() : idxRnk(data) {}
|
inline chrgrp_db() : idxRank(data) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +202,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
|||||||
{
|
{
|
||||||
// Write rank index.
|
// Write rank index.
|
||||||
if (stream.fail()) return stream;
|
if (stream.fail()) return stream;
|
||||||
stream << db.idxRnk;
|
stream << db.idxRank;
|
||||||
|
|
||||||
// Write data count.
|
// Write data count.
|
||||||
auto data_count = db.data.size();
|
auto data_count = db.data.size();
|
||||||
@ -230,7 +236,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
|||||||
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp_db &db)
|
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp_db &db)
|
||||||
{
|
{
|
||||||
// Read rank index.
|
// Read rank index.
|
||||||
stream >> db.idxRnk;
|
stream >> db.idxRank;
|
||||||
if (!stream.good()) return stream;
|
if (!stream.good()) return stream;
|
||||||
|
|
||||||
// Read data count.
|
// Read data count.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user