Switch integer datatypes to C99

This makes code more portable.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2022-09-13 10:35:58 +02:00
parent 5cc005583c
commit 63fda12c99
15 changed files with 388 additions and 384 deletions

View File

@ -149,10 +149,10 @@ void wxZRColaCharacterCatalogPanel::Update()
} else { } else {
// Select frequently used characters only. // Select frequently used characters only.
const wchar_t *src = cg.chrlst(); const wchar_t *src = cg.chrlst();
const unsigned __int16 *shown = cg.chrshow(); const uint16_t *shown = cg.chrshow();
wxArrayString chars; wxArrayString chars;
for (size_t i = 0, i_end = cg.chrlst_len(), j = 0; i < i_end; j++) { for (size_t i = 0, i_end = cg.chrlst_len(), j = 0; i < i_end; j++) {
for (unsigned __int16 k = 0, mask = shown[j]; k < 16 && i < i_end; k++, mask >>= 1) { for (uint16_t k = 0, mask = shown[j]; k < 16 && i < i_end; k++, mask >>= 1) {
size_t len = wcsnlen(src + i, i_end - i); size_t len = wcsnlen(src + i, i_end - i);
if (mask & 1) if (mask & 1)
chars.Add(wxString(src + i, len)); chars.Add(wxString(src + i, len));

View File

@ -301,7 +301,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
// Add name to the list. // Add name to the list.
tag_names.push_back(std::wstring(tn.name(), tn.name_end())); tag_names.push_back(std::wstring(tn.name(), tn.name_end()));
break; break;
} else if (ZRCola::tagname_db::tagname::CompareName(m_locale, name->data(), (unsigned __int16)name->length(), tn.name(), tn.name_len()) == 0) } else if (ZRCola::tagname_db::tagname::CompareName(m_locale, name->data(), (uint16_t)name->length(), tn.name(), tn.name_len()) == 0)
// Name is already on the list. // Name is already on the list.
break; break;
} }
@ -718,7 +718,7 @@ wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
{ {
// Search by tags: Get tags with given names. Then, get characters of found tags. // Search by tags: Get tags with given names. Then, get characters of found tags.
std::map<ZRCola::tagid_t, unsigned __int16> hits_tag; std::map<ZRCola::tagid_t, uint16_t> hits_tag;
if (!app->m_tn_db.Search(m_search.c_str(), m_parent->m_locale, hits_tag, TestDestroyS, this)) return (wxThread::ExitCode)1; if (!app->m_tn_db.Search(m_search.c_str(), m_parent->m_locale, hits_tag, TestDestroyS, this)) return (wxThread::ExitCode)1;
if (!app->m_ct_db.Search(hits_tag, app->m_chr_db, m_cats, hits, TestDestroyS, this)) return (wxThread::ExitCode)1; if (!app->m_ct_db.Search(hits_tag, app->m_chr_db, m_cats, hits, TestDestroyS, this)) return (wxThread::ExitCode)1;
} }

View File

@ -49,7 +49,7 @@ void wxZRColaComposerPanel::RestoreFromStateFile()
wxFFile file(fileName, wxT("rb")); wxFFile file(fileName, wxT("rb"));
if (file.IsOpened()) { if (file.IsOpened()) {
// Load source text. // Load source text.
unsigned __int64 n; uint64_t n;
file.Read(&n, sizeof(n)); file.Read(&n, sizeof(n));
if (!file.Error()) { if (!file.Error()) {
wxString source; wxString source;

View File

@ -186,7 +186,7 @@ void ZRCola::DBSource::character_desc_idx::add_keywords(const set<wstring> &term
} }
void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, uint32_t> &idx) const
{ {
idx .clear(); idx .clear();
idx.keys .clear(); idx.keys .clear();
@ -205,7 +205,7 @@ void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar
// Convert the index. // Convert the index.
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) { for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
ZRCola::mappair_t<unsigned __int32> p = { idx.keys.size(), idx.values.size() }; ZRCola::mappair_t<uint32_t> p = { idx.keys.size(), idx.values.size() };
idx.push_back(p); idx.push_back(p);
idx.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.cend()); idx.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.cend());
idx.values.insert(idx.values.end(), i->second.cbegin(), i->second.cend()); idx.values.insert(idx.values.end(), i->second.cbegin(), i->second.cend());
@ -670,7 +670,7 @@ bool ZRCola::DBSource::GetTagNames(const winstd::com_obj<ADOField>& f, LCID lcid
// Add name to the list. // Add name to the list.
names.push_back(std::move(name)); names.push_back(std::move(name));
break; break;
} else if (ZRCola::tagname_db::tagname::CompareName(lcid, n->data(), (unsigned __int16)n->length(), name.data(), (unsigned __int16)name.length()) == CSTR_EQUAL) { } else if (ZRCola::tagname_db::tagname::CompareName(lcid, n->data(), (uint16_t)n->length(), name.data(), (uint16_t)name.length()) == CSTR_EQUAL) {
// Name is already on the list. // Name is already on the list.
break; break;
} }

View File

@ -226,7 +226,7 @@ namespace ZRCola {
short rank; ///< Rank short rank; ///< Rank
std::wstring name; ///< Name std::wstring name; ///< Name
std::vector<wchar_t> chars; ///< Characters (zero-delimited) std::vector<wchar_t> chars; ///< Characters (zero-delimited)
std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially std::vector<uint16_t> show; ///< Bit vector if particular character from \c chars is displayed initially
inline chrgrp() : grp(0), rank(0) {} inline chrgrp() : grp(0), rank(0) {}
}; };
@ -340,7 +340,7 @@ namespace ZRCola {
add_keywords(terms, chr, sub); add_keywords(terms, chr, sub);
} }
void save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const; void save(ZRCola::textindex<wchar_t, wchar_t, uint32_t> &idx) const;
protected: protected:
inline void add_keyword(const std::wstring &term, const std::wstring &chr) inline void add_keyword(const std::wstring &term, const std::wstring &chr)
@ -920,16 +920,16 @@ namespace ZRCola {
inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _In_ const ZRCola::DBSource::translation &rec) inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _In_ const ZRCola::DBSource::translation &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.set); db.data.push_back((uint16_t)rec.set);
db.data.push_back((unsigned __int16)rec.dst.rank); db.data.push_back((uint16_t)rec.dst.rank);
db.data.push_back((unsigned __int16)rec.src.rank); db.data.push_back((uint16_t)rec.src.rank);
std::wstring::size_type n = rec.dst.str.length(); std::wstring::size_type n = rec.dst.str.length();
wxASSERT_MSG(n <= 0xffff, wxT("destination overflow")); wxASSERT_MSG(n <= 0xffff, wxT("destination overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
n += rec.src.str.length(); n += rec.src.str.length();
wxASSERT_MSG(n <= 0xffff, wxT("source overflow")); wxASSERT_MSG(n <= 0xffff, wxT("source overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.dst.str.cbegin(), rec.dst.str.cend()); db.data.insert(db.data.end(), rec.dst.str.cbegin(), rec.dst.str.cend());
db.data.insert(db.data.end(), rec.src.str.cbegin(), rec.src.str.cend()); db.data.insert(db.data.end(), rec.src.str.cbegin(), rec.src.str.cend());
db.idxSrc.push_back(idx); db.idxSrc.push_back(idx);
@ -941,14 +941,14 @@ inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _I
inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const ZRCola::DBSource::transet &rec) inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const ZRCola::DBSource::transet &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.set); db.data.push_back((uint16_t)rec.set);
std::wstring::size_type n = rec.src.length(); std::wstring::size_type n = rec.src.length();
wxASSERT_MSG(n <= 0xffff, wxT("translation set source name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation set source name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
n += rec.dst.length(); n += rec.dst.length();
wxASSERT_MSG(n <= 0xffff, wxT("translation set destination name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation set destination name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.src.cbegin(), rec.src.cend()); db.data.insert(db.data.end(), rec.src.cbegin(), rec.src.cend());
db.data.insert(db.data.end(), rec.dst.cbegin(), rec.dst.cend()); db.data.insert(db.data.end(), rec.dst.cbegin(), rec.dst.cend());
db.idxTranSet.push_back(idx); db.idxTranSet.push_back(idx);
@ -959,18 +959,18 @@ inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const
inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const ZRCola::DBSource::transeq &rec) inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const ZRCola::DBSource::transeq &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.seq); db.data.push_back((uint16_t)rec.seq);
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((uint16_t)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation sequence name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
n += rec.sets.size(); n += rec.sets.size();
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence sets overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation sequence sets overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend()); db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
for (auto s = rec.sets.cbegin(), s_end = rec.sets.cend(); s != s_end; ++s) for (auto s = rec.sets.cbegin(), s_end = rec.sets.cend(); s != s_end; ++s)
db.data.push_back((unsigned __int16)*s); db.data.push_back((uint16_t)*s);
db.idxTranSeq.push_back(idx); db.idxTranSeq.push_back(idx);
db.idxRank .push_back(idx); db.idxRank .push_back(idx);
@ -980,13 +980,13 @@ inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const
inline ZRCola::keyseq_db& operator<<(_Inout_ ZRCola::keyseq_db &db, _In_ const ZRCola::DBSource::keyseq &rec) inline ZRCola::keyseq_db& operator<<(_Inout_ ZRCola::keyseq_db &db, _In_ const ZRCola::DBSource::keyseq &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
std::wstring::size_type n = rec.chr.length(); std::wstring::size_type n = rec.chr.length();
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((uint16_t)n);
n += rec.seq.size() * sizeof(ZRCola::keyseq_db::keyseq::key_t) / sizeof(wchar_t); n += rec.seq.size() * sizeof(ZRCola::keyseq_db::keyseq::key_t) / sizeof(wchar_t);
wxASSERT_MSG(n <= 0xffff, wxT("key sequence overflow")); wxASSERT_MSG(n <= 0xffff, wxT("key sequence overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend()); db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
for (auto kc = rec.seq.cbegin(), kc_end = rec.seq.cend(); kc != kc_end; ++kc) { for (auto kc = rec.seq.cbegin(), kc_end = rec.seq.cend(); kc != kc_end; ++kc) {
db.data.push_back(kc->key); db.data.push_back(kc->key);
@ -1004,11 +1004,11 @@ inline ZRCola::keyseq_db& operator<<(_Inout_ ZRCola::keyseq_db &db, _In_ const Z
inline ZRCola::language_db& operator<<(_Inout_ ZRCola::language_db &db, _In_ const ZRCola::DBSource::language &rec) inline ZRCola::language_db& operator<<(_Inout_ ZRCola::language_db &db, _In_ const ZRCola::DBSource::language &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.lang), reinterpret_cast<const unsigned __int16*>(&rec.lang + 1)); db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.lang), reinterpret_cast<const uint16_t*>(&rec.lang + 1));
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
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((uint16_t)n);
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend()); db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
db.idxLang.push_back(idx); db.idxLang.push_back(idx);
@ -1018,11 +1018,11 @@ inline ZRCola::language_db& operator<<(_Inout_ ZRCola::language_db &db, _In_ con
inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ const ZRCola::DBSource::langchar &rec) inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ const ZRCola::DBSource::langchar &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.lang), reinterpret_cast<const unsigned __int16*>(&rec.lang + 1)); db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.lang), reinterpret_cast<const uint16_t*>(&rec.lang + 1));
std::wstring::size_type n = rec.chr.length(); std::wstring::size_type n = rec.chr.length();
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((uint16_t)n);
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend()); db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
db.idxChr .push_back(idx); db.idxChr .push_back(idx);
#ifdef ZRCOLA_LANGCHAR_LANG_IDX #ifdef ZRCOLA_LANGCHAR_LANG_IDX
@ -1035,15 +1035,15 @@ inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ con
inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const ZRCola::DBSource::chrgrp &rec) inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const ZRCola::DBSource::chrgrp &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.grp); db.data.push_back((uint16_t)rec.grp);
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((uint16_t)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("character group name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character group name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
n += rec.chars.size(); n += rec.chars.size();
wxASSERT_MSG(n <= 0xffff, wxT("character group characters overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character group characters overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.name .cbegin(), rec.name .cend()); db.data.insert(db.data.end(), rec.name .cbegin(), rec.name .cend());
db.data.insert(db.data.end(), rec.chars.cbegin(), rec.chars.cend()); db.data.insert(db.data.end(), rec.chars.cbegin(), rec.chars.cend());
db.data.insert(db.data.end(), rec.show .cbegin(), rec.show .cend()); db.data.insert(db.data.end(), rec.show .cbegin(), rec.show .cend());
@ -1055,17 +1055,17 @@ inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const Z
inline ZRCola::character_db& operator<<(_Inout_ ZRCola::character_db &db, _In_ const ZRCola::DBSource::character &rec) inline ZRCola::character_db& operator<<(_Inout_ ZRCola::character_db &db, _In_ const ZRCola::DBSource::character &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.second.cat), reinterpret_cast<const unsigned __int16*>(&rec.second.cat + 1)); db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.second.cat), reinterpret_cast<const uint16_t*>(&rec.second.cat + 1));
std::wstring::size_type n = rec.first.length(); std::wstring::size_type n = rec.first.length();
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((uint16_t)n);
n += rec.second.desc.length(); n += rec.second.desc.length();
wxASSERT_MSG(n <= 0xffff, wxT("character description overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character description overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
n += rec.second.rel.size(); n += rec.second.rel.size();
wxASSERT_MSG(n <= 0xffff, wxT("related characters overflow")); wxASSERT_MSG(n <= 0xffff, wxT("related characters overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.first .cbegin(), rec.first .cend()); db.data.insert(db.data.end(), rec.first .cbegin(), rec.first .cend());
db.data.insert(db.data.end(), rec.second.desc.cbegin(), rec.second.desc.cend()); db.data.insert(db.data.end(), rec.second.desc.cbegin(), rec.second.desc.cend());
db.data.insert(db.data.end(), rec.second.rel .cbegin(), rec.second.rel .cend()); db.data.insert(db.data.end(), rec.second.rel .cbegin(), rec.second.rel .cend());
@ -1077,12 +1077,12 @@ inline ZRCola::character_db& operator<<(_Inout_ ZRCola::character_db &db, _In_ c
inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const ZRCola::DBSource::chrcat &rec) inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const ZRCola::DBSource::chrcat &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.cat), reinterpret_cast<const unsigned __int16*>(&rec.cat + 1)); db.data.insert(db.data.end(), reinterpret_cast<const uint16_t*>(&rec.cat), reinterpret_cast<const uint16_t*>(&rec.cat + 1));
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((uint16_t)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("character category name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character category name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend()); db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
db.idxChrCat.push_back(idx); db.idxChrCat.push_back(idx);
db.idxRank .push_back(idx); db.idxRank .push_back(idx);
@ -1093,11 +1093,11 @@ inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const Z
inline ZRCola::chrtag_db& operator<<(_Inout_ ZRCola::chrtag_db &db, _In_ const ZRCola::DBSource::chrtag &rec) inline ZRCola::chrtag_db& operator<<(_Inout_ ZRCola::chrtag_db &db, _In_ const ZRCola::DBSource::chrtag &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.tag); db.data.push_back((uint16_t)rec.tag);
std::wstring::size_type n = rec.chr.length(); std::wstring::size_type n = rec.chr.length();
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((uint16_t)n);
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend()); db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
db.idxChr.push_back(idx); db.idxChr.push_back(idx);
db.idxTag.push_back(idx); db.idxTag.push_back(idx);
@ -1110,13 +1110,13 @@ inline ZRCola::tagname_db& operator<<(_Inout_ ZRCola::tagname_db &db, _In_ const
{ {
for (auto ln = rec.names.cbegin(), ln_end = rec.names.cend(); ln != ln_end; ++ln) { for (auto ln = rec.names.cbegin(), ln_end = rec.names.cend(); ln != ln_end; ++ln) {
for (auto nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) { for (auto nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.tag); db.data.push_back((uint16_t)rec.tag);
db.data.push_back(LOWORD(ln->first)); db.data.push_back(LOWORD(ln->first));
db.data.push_back(HIWORD(ln->first)); db.data.push_back(HIWORD(ln->first));
std::wstring::size_type n = nm->length(); std::wstring::size_type n = nm->length();
wxASSERT_MSG(n <= 0xffff, wxT("tag name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("tag name overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((uint16_t)n);
db.data.insert(db.data.end(), nm->cbegin(), nm->cend()); db.data.insert(db.data.end(), nm->cbegin(), nm->cend());
db.idxName.push_back(idx); db.idxName.push_back(idx);
db.idxTag .push_back(idx); db.idxTag .push_back(idx);
@ -1129,11 +1129,11 @@ inline ZRCola::tagname_db& operator<<(_Inout_ ZRCola::tagname_db &db, _In_ const
inline ZRCola::highlight_db& operator<<(_Inout_ ZRCola::highlight_db &db, _In_ const ZRCola::DBSource::highlight &rec) inline ZRCola::highlight_db& operator<<(_Inout_ ZRCola::highlight_db &db, _In_ const ZRCola::DBSource::highlight &rec)
{ {
unsigned __int32 idx = db.data.size(); uint32_t idx = db.data.size();
db.data.push_back((unsigned __int16)rec.set); db.data.push_back((uint16_t)rec.set);
std::wstring::size_type n = rec.chr.length(); std::wstring::size_type n = rec.chr.length();
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((uint16_t)n);
db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend()); db.data.insert(db.data.end(), rec.chr.cbegin(), rec.chr.cend());
db.idxChr.push_back(idx); db.idxChr.push_back(idx);

View File

@ -180,9 +180,9 @@ namespace ZRCola {
chrcatid_t cat; ///> Character category ID chrcatid_t cat; ///> Character category ID
protected: protected:
unsigned __int16 chr_to; ///< Character end in \c data uint16_t chr_to; ///< Character end in \c data
unsigned __int16 desc_to; ///< Character description end in \c data uint16_t desc_to; ///< Character description end in \c data
unsigned __int16 rel_to; ///< Related characters end in \c data uint16_t rel_to; ///< Related characters end in \c data
wchar_t data[]; ///< Character, character description wchar_t data[]; ///< Character, character description
private: private:
@ -211,11 +211,11 @@ namespace ZRCola {
_In_opt_ size_t rel_len = 0) _In_opt_ size_t rel_len = 0)
{ {
this->cat = cat; this->cat = cat;
this->chr_to = static_cast<unsigned __int16>(chr_len); this->chr_to = static_cast<uint16_t>(chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len); if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
this->desc_to = static_cast<unsigned __int16>(this->chr_to + desc_len); this->desc_to = static_cast<uint16_t>(this->chr_to + desc_len);
if (desc && desc_len) memcpy(this->data + this->chr_to, desc, sizeof(wchar_t)*desc_len); if (desc && desc_len) memcpy(this->data + this->chr_to, desc, sizeof(wchar_t)*desc_len);
this->rel_to = static_cast<unsigned __int16>(this->desc_to + rel_len); this->rel_to = static_cast<uint16_t>(this->desc_to + rel_len);
if (rel && rel_len) memcpy(this->data + this->desc_to, rel, sizeof(wchar_t)*rel_len); if (rel && rel_len) memcpy(this->data + this->desc_to, rel, sizeof(wchar_t)*rel_len);
} }
@ -223,26 +223,26 @@ namespace ZRCola {
inline wchar_t* chr () { return data; }; inline wchar_t* chr () { return data; };
inline const wchar_t* chr_end() const { return data + chr_to; }; inline const wchar_t* chr_end() const { return data + chr_to; };
inline wchar_t* chr_end() { return data + chr_to; }; inline wchar_t* chr_end() { return data + chr_to; };
inline unsigned __int16 chr_len() const { return chr_to; }; inline uint16_t chr_len() const { return chr_to; };
inline const wchar_t* desc () const { return data + chr_to; }; inline const wchar_t* desc () const { return data + chr_to; };
inline wchar_t* desc () { return data + chr_to; }; inline wchar_t* desc () { return data + chr_to; };
inline const wchar_t* desc_end() const { return data + desc_to; }; inline const wchar_t* desc_end() const { return data + desc_to; };
inline wchar_t* desc_end() { return data + desc_to; }; inline wchar_t* desc_end() { return data + desc_to; };
inline unsigned __int16 desc_len() const { return desc_to - chr_to; }; inline uint16_t desc_len() const { return desc_to - chr_to; };
inline const wchar_t* rel () const { return data + desc_to; }; inline const wchar_t* rel () const { return data + desc_to; };
inline wchar_t* rel () { return data + desc_to; }; inline wchar_t* rel () { return data + desc_to; };
inline const wchar_t* rel_end() const { return data + rel_to; }; inline const wchar_t* rel_end() const { return data + rel_to; };
inline wchar_t* rel_end() { return data + rel_to; }; inline wchar_t* rel_end() { return data + rel_to; };
inline unsigned __int16 rel_len() const { return rel_to - desc_to; }; inline uint16_t rel_len() const { return rel_to - desc_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Character index /// Character index
/// ///
class indexChr : public index<unsigned __int16, unsigned __int32, character> class indexChr : public index<uint16_t, uint32_t, character>
{ {
public: public:
/// ///
@ -250,7 +250,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, character>(h) {} indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, character>(h) {}
/// ///
/// Compares two characters by ID (for searching) /// Compares two characters by ID (for searching)
@ -272,9 +272,9 @@ namespace ZRCola {
} }
} idxChr; ///< Character index } idxChr; ///< Character index
textindex<wchar_t, wchar_t, unsigned __int32> idxDsc; ///< Description index textindex<wchar_t, wchar_t, uint32_t> idxDsc; ///< Description index
textindex<wchar_t, wchar_t, unsigned __int32> idxDscSub; ///< Description index (sub-terms) textindex<wchar_t, wchar_t, uint32_t> idxDscSub; ///< Description index (sub-terms)
std::vector<unsigned __int16> data; ///< Character data std::vector<uint16_t> data; ///< Character data
public: public:
/// ///
@ -342,10 +342,10 @@ namespace ZRCola {
struct chrcat { struct chrcat {
public: public:
chrcatid_t cat; ///< Character category ID chrcatid_t cat; ///< Character category ID
unsigned __int16 rank; ///< Character category rank uint16_t rank; ///< Character category rank
protected: protected:
unsigned __int16 name_to; ///< Character category name end in \c data uint16_t name_to; ///< Character category name end in \c data
wchar_t data[]; ///< Character category name wchar_t data[]; ///< Character category name
private: private:
@ -363,13 +363,13 @@ namespace ZRCola {
/// ///
inline chrcat( inline chrcat(
_In_opt_ chrcatid_t cat = chrcatid_t::blank, _In_opt_ chrcatid_t cat = chrcatid_t::blank,
_In_opt_ unsigned __int16 rank = 0, _In_opt_ uint16_t 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->cat = cat; this->cat = cat;
this->rank = rank; this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len); this->name_to = static_cast<uint16_t>(name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len); if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
} }
@ -377,14 +377,14 @@ namespace ZRCola {
inline wchar_t* name () { return data; }; inline wchar_t* name () { return data; };
inline const wchar_t* name_end() const { return data + name_to; }; inline const wchar_t* name_end() const { return data + name_to; };
inline wchar_t* name_end() { return data + name_to; }; inline wchar_t* name_end() { return data + name_to; };
inline unsigned __int16 name_len() const { return name_to; }; inline uint16_t name_len() const { return name_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Character category index /// Character category index
/// ///
class indexChrCat : public index<unsigned __int16, unsigned __int32, chrcat> class indexChrCat : public index<uint16_t, uint32_t, chrcat>
{ {
public: public:
/// ///
@ -392,7 +392,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexChrCat(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {} indexChrCat(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrcat>(h) {}
/// ///
/// Compares two character categories by ID (for searching) /// Compares two character categories by ID (for searching)
@ -417,7 +417,7 @@ namespace ZRCola {
/// ///
/// Rank index /// Rank index
/// ///
class indexRank : public index<unsigned __int16, unsigned __int32, chrcat> class indexRank : public index<uint16_t, uint32_t, chrcat>
{ {
public: public:
/// ///
@ -425,7 +425,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexRank(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {} indexRank(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrcat>(h) {}
/// ///
/// Compares two character categories by ID (for searching) /// Compares two character categories by ID (for searching)
@ -462,10 +462,10 @@ namespace ZRCola {
if (a.rank < b.rank) return -1; if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1; else if (a.rank > b.rank) return +1;
unsigned __int16 uint16_t
a_name_len = a.name_len(), a_name_len = a.name_len(),
b_name_len = b.name_len(); b_name_len = b.name_len();
int r = _wcsncoll(a.name(), b.name(), std::min<unsigned __int16>(a_name_len, b_name_len)); int r = _wcsncoll(a.name(), b.name(), std::min<uint16_t>(a_name_len, b_name_len));
if (r != 0) return r; if (r != 0) return r;
if (a_name_len < b_name_len) return -1; if (a_name_len < b_name_len) return -1;
else if (a_name_len > b_name_len) return +1; else if (a_name_len > b_name_len) return +1;
@ -474,7 +474,7 @@ namespace ZRCola {
} }
} idxRank; ///< Rank index } idxRank; ///< Rank index
std::vector<unsigned __int16> data; ///< Character category data std::vector<uint16_t> data; ///< Character category data
public: public:
/// ///
@ -525,14 +525,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::charac
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();
@ -572,12 +572,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -611,12 +611,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -641,14 +641,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -8,8 +8,9 @@
#ifdef _WIN32 #ifdef _WIN32
#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h. #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h.
#include <Windows.h> #include <Windows.h>
#endif
#include <sal.h> #include <sal.h>
#endif
#include <stdint.h>
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#include <utility> #include <utility>
@ -33,8 +34,8 @@
namespace ZRCola { namespace ZRCola {
typedef unsigned __int32 recordid_t; typedef uint32_t recordid_t;
typedef unsigned __int32 recordsize_t; typedef uint32_t recordsize_t;
#pragma pack(push) #pragma pack(push)
@ -210,7 +211,7 @@ namespace ZRCola {
/// ///
/// Memory index /// Memory index
/// ///
template <class T_data, class T_idx = unsigned __int32, class T_el = T_data> template <class T_data, class T_idx = uint32_t, class T_el = T_data>
class index : public std::vector<T_idx> class index : public std::vector<T_idx>
{ {
protected: protected:
@ -406,7 +407,7 @@ namespace ZRCola {
/// ///
/// Memory text index /// Memory text index
/// ///
template <class T_key, class T_val, class T_idx = unsigned __int32> template <class T_key, class T_val, class T_idx = uint32_t>
class textindex : public std::vector< mappair_t<T_idx> > class textindex : public std::vector< mappair_t<T_idx> >
{ {
public: public:
@ -638,7 +639,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::i
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)idx_count; uint32_t count = (uint32_t)idx_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write index data. // Write index data.
@ -660,7 +661,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::i
template <class T_data, class T_idx, class T_el> template <class T_data, class T_idx, class T_el>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<T_data, T_idx, T_el> &idx) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<T_data, T_idx, T_el> &idx)
{ {
unsigned __int32 count; uint32_t count;
// Read index count. // Read index count.
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
@ -691,7 +692,7 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<
template <class T_key, class T_val, class T_idx> template <class T_key, class T_val, class T_idx>
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::textindex<T_key, T_val, T_idx> &idx) inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::textindex<T_key, T_val, T_idx> &idx)
{ {
unsigned __int32 count; uint32_t count;
// Write index count. // Write index count.
auto idx_count = idx.size(); auto idx_count = idx.size();
@ -703,7 +704,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
count = (unsigned __int32)idx_count; count = (uint32_t)idx_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write index data. // Write index data.
@ -720,7 +721,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
count = (unsigned __int32)key_count; count = (uint32_t)key_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write key data. // Write key data.
@ -737,7 +738,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
count = (unsigned __int32)value_count; count = (uint32_t)value_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write value data. // Write value data.
@ -759,7 +760,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
template <class T_key, class T_val, class T_idx> template <class T_key, class T_val, class T_idx>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textindex<T_key, T_val, T_idx> &idx) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textindex<T_key, T_val, T_idx> &idx)
{ {
unsigned __int32 count; uint32_t count;
// Read text index count. // Read text index count.
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));

View File

@ -29,7 +29,7 @@ namespace ZRCola {
/// ///
/// Highlight set ID /// Highlight set ID
/// ///
typedef unsigned __int16 hlghtsetid_t; typedef uint16_t hlghtsetid_t;
/// ///
/// Highlight database /// Highlight database
@ -46,7 +46,7 @@ namespace ZRCola {
hlghtsetid_t set; ///< Highlight set ID hlghtsetid_t set; ///< Highlight set ID
protected: protected:
unsigned __int16 chr_to; ///< Character end in \c data uint16_t chr_to; ///< Character end in \c data
wchar_t data[]; ///< Character wchar_t data[]; ///< Character
private: private:
@ -67,7 +67,7 @@ namespace ZRCola {
_In_opt_ size_t chr_len = 0) _In_opt_ size_t chr_len = 0)
{ {
this->set = set; this->set = set;
this->chr_to = static_cast<unsigned __int16>(chr_len); this->chr_to = static_cast<uint16_t>(chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len); if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
} }
@ -75,7 +75,7 @@ namespace ZRCola {
inline wchar_t* chr () { return data; }; inline wchar_t* chr () { return data; };
inline const wchar_t* chr_end() const { return data + chr_to; }; inline const wchar_t* chr_end() const { return data + chr_to; };
inline wchar_t* chr_end() { return data + chr_to; }; inline wchar_t* chr_end() { return data + chr_to; };
inline unsigned __int16 chr_len() const { return chr_to; }; inline uint16_t chr_len() const { return chr_to; };
inline wchar_t chr_at(_In_ size_t i) const inline wchar_t chr_at(_In_ size_t i) const
{ {
@ -87,7 +87,7 @@ namespace ZRCola {
/// ///
/// Highlight index /// Highlight index
/// ///
class indexChr : public index<unsigned __int16, unsigned __int32, highlight> class indexChr : public index<uint16_t, uint32_t, highlight>
{ {
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
/// ///
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, highlight>(h) {} indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, highlight>(h) {}
/// ///
/// Compares two highlights by string (for searching) /// Compares two highlights by string (for searching)
@ -138,7 +138,7 @@ namespace ZRCola {
} idxChr; ///< Highlight index } idxChr; ///< Highlight index
std::vector<unsigned __int16> data; ///< Highlight data std::vector<uint16_t> data; ///< Highlight data
public: public:
/// ///
@ -197,12 +197,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::h
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -223,14 +223,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::highli
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -35,7 +35,7 @@ namespace ZRCola {
langid_t lang; ///< Language ID langid_t lang; ///< Language ID
protected: protected:
unsigned __int16 chr_to; ///< Character end in \c data uint16_t chr_to; ///< Character end in \c data
wchar_t data[]; ///< Character wchar_t data[]; ///< Character
private: private:
@ -56,7 +56,7 @@ namespace ZRCola {
_In_opt_ size_t chr_len = 0) _In_opt_ size_t chr_len = 0)
{ {
this->lang = lang; this->lang = lang;
this->chr_to = static_cast<unsigned __int16>(chr_len); this->chr_to = static_cast<uint16_t>(chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len); if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
} }
@ -64,14 +64,14 @@ namespace ZRCola {
inline wchar_t* chr () { return data; }; inline wchar_t* chr () { return data; };
inline const wchar_t* chr_end() const { return data + chr_to; }; inline const wchar_t* chr_end() const { return data + chr_to; };
inline wchar_t* chr_end() { return data + chr_to; }; inline wchar_t* chr_end() { return data + chr_to; };
inline unsigned __int16 chr_len() const { return chr_to; }; inline uint16_t chr_len() const { return chr_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Character index /// Character index
/// ///
class indexChr : public index<unsigned __int16, unsigned __int32, langchar> class indexChr : public index<uint16_t, uint32_t, langchar>
{ {
public: public:
/// ///
@ -79,7 +79,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {} indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, langchar>(h) {}
/// ///
/// Compares two characters by ID (for searching) /// Compares two characters by ID (for searching)
@ -109,7 +109,7 @@ namespace ZRCola {
/// ///
/// Language Index /// Language Index
/// ///
class indexLang : public index<unsigned __int16, unsigned __int32, langchar> class indexLang : public index<uint16_t, uint32_t, langchar>
{ {
public: public:
/// ///
@ -117,7 +117,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {} indexLang(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, langchar>(h) {}
/// ///
/// Compares two languages by ID (for searching) /// Compares two languages by ID (for searching)
@ -143,7 +143,7 @@ namespace ZRCola {
} idxLang; ///< Language index } idxLang; ///< Language index
#endif #endif
std::vector<unsigned __int16> data; ///< Character data std::vector<uint16_t> data; ///< Character data
public: public:
/// ///
@ -199,7 +199,7 @@ namespace ZRCola {
langid_t lang; ///< Language ID langid_t lang; ///< Language ID
protected: protected:
unsigned __int16 name_to; ///< Language name end in \c data uint16_t name_to; ///< Language name end in \c data
wchar_t data[]; ///< Language name wchar_t data[]; ///< Language name
private: private:
@ -220,7 +220,7 @@ namespace ZRCola {
_In_opt_ size_t name_len = 0) _In_opt_ size_t name_len = 0)
{ {
this->lang = lang; this->lang = lang;
this->name_to = static_cast<unsigned __int16>(name_len); this->name_to = static_cast<uint16_t>(name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len); if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
} }
@ -228,14 +228,14 @@ namespace ZRCola {
inline wchar_t* name () { return data; }; inline wchar_t* name () { return data; };
inline const wchar_t* name_end() const { return data + name_to; }; inline const wchar_t* name_end() const { return data + name_to; };
inline wchar_t* name_end() { return data + name_to; }; inline wchar_t* name_end() { return data + name_to; };
inline unsigned __int16 name_len() const { return name_to; }; inline uint16_t name_len() const { return name_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Language index /// Language index
/// ///
class indexLang : public index<unsigned __int16, unsigned __int32, language> class indexLang : public index<uint16_t, uint32_t, language>
{ {
public: public:
/// ///
@ -243,7 +243,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, language>(h) {} indexLang(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, language>(h) {}
/// ///
/// Compares two languages by ID (for searching) /// Compares two languages by ID (for searching)
@ -265,7 +265,7 @@ namespace ZRCola {
} }
} idxLang; ///< Language index } idxLang; ///< Language index
std::vector<unsigned __int16> data; ///< Language data std::vector<uint16_t> data; ///< Language data
public: public:
/// ///
@ -322,12 +322,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -354,14 +354,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langch
#endif #endif
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();
@ -393,12 +393,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -419,14 +419,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langua
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -21,7 +21,7 @@
namespace ZRCola { namespace ZRCola {
typedef unsigned __int16 tagid_t; typedef uint16_t tagid_t;
/// ///
/// Character Tag Database /// Character Tag Database
@ -38,7 +38,7 @@ namespace ZRCola {
tagid_t tag; ///< Tag ID tagid_t tag; ///< Tag ID
protected: protected:
unsigned __int16 chr_to; ///< Character end in \c data uint16_t chr_to; ///< Character end in \c data
wchar_t data[]; ///< Character wchar_t data[]; ///< Character
private: private:
@ -59,7 +59,7 @@ namespace ZRCola {
_In_opt_ tagid_t tag = 0) _In_opt_ tagid_t tag = 0)
{ {
this->tag = tag; this->tag = tag;
this->chr_to = static_cast<unsigned __int16>(chr_len); this->chr_to = static_cast<uint16_t>(chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len); if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
} }
@ -67,14 +67,14 @@ namespace ZRCola {
inline wchar_t* chr () { return data; }; inline wchar_t* chr () { return data; };
inline const wchar_t* chr_end() const { return data + chr_to; }; inline const wchar_t* chr_end() const { return data + chr_to; };
inline wchar_t* chr_end() { return data + chr_to; }; inline wchar_t* chr_end() { return data + chr_to; };
inline unsigned __int16 chr_len() const { return chr_to; }; inline uint16_t chr_len() const { return chr_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Character Index /// Character Index
/// ///
class indexChr : public index<unsigned __int16, unsigned __int32, chrtag> class indexChr : public index<uint16_t, uint32_t, chrtag>
{ {
public: public:
/// ///
@ -82,7 +82,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrtag>(h) {} indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrtag>(h) {}
/// ///
/// Compares two character tags by character (for searching) /// Compares two character tags by character (for searching)
@ -130,7 +130,7 @@ namespace ZRCola {
/// ///
/// Tag Index /// Tag Index
/// ///
class indexTag : public index<unsigned __int16, unsigned __int32, chrtag> class indexTag : public index<uint16_t, uint32_t, chrtag>
{ {
public: public:
/// ///
@ -138,7 +138,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexTag(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrtag>(h) {} indexTag(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrtag>(h) {}
/// ///
/// Compares two character tags by tag (for searching) /// Compares two character tags by tag (for searching)
@ -182,7 +182,7 @@ namespace ZRCola {
} }
} idxTag; ///< Tag index } idxTag; ///< Tag index
std::vector<unsigned __int16> data; ///< Character tags data std::vector<uint16_t> data; ///< Character tags data
public: public:
/// ///
@ -210,7 +210,7 @@ namespace ZRCola {
/// \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_ const std::map<tagid_t, unsigned __int16> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<std::wstring, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const; bool Search(_In_ const std::map<tagid_t, uint16_t> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<std::wstring, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
}; };
@ -233,7 +233,7 @@ namespace ZRCola {
LCID locale; ///< Locale ID LCID locale; ///< Locale ID
protected: protected:
unsigned __int16 name_to; ///< Tag name end in \c data uint16_t name_to; ///< Tag name end in \c data
wchar_t data[]; ///< Tag name wchar_t data[]; ///< Tag name
private: private:
@ -257,7 +257,7 @@ namespace ZRCola {
{ {
this->tag = tag; this->tag = tag;
this->locale = locale; this->locale = locale;
this->name_to = static_cast<unsigned __int16>(name_len); this->name_to = static_cast<uint16_t>(name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len); if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
} }
@ -265,7 +265,7 @@ namespace ZRCola {
inline wchar_t* name () { return data; }; inline wchar_t* name () { return data; };
inline const wchar_t* name_end() const { return data + name_to; }; inline const wchar_t* name_end() const { return data + name_to; };
inline wchar_t* name_end() { return data + name_to; }; inline wchar_t* name_end() { return data + name_to; };
inline unsigned __int16 name_len() const { return name_to; }; inline uint16_t name_len() const { return name_to; };
/// ///
/// Compares two names /// Compares two names
@ -285,7 +285,7 @@ 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 locale, 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, uint16_t count_a, const wchar_t *str_b, uint16_t count_b)
{ {
switch (::CompareString(locale, SORT_STRINGSORT | NORM_IGNORECASE, str_a, count_a, str_b, count_b)) { switch (::CompareString(locale, SORT_STRINGSORT | NORM_IGNORECASE, str_a, count_a, str_b, count_b)) {
case CSTR_LESS_THAN : return -1; case CSTR_LESS_THAN : return -1;
@ -300,7 +300,7 @@ namespace ZRCola {
/// ///
/// Name index /// Name index
/// ///
class indexName : public index<unsigned __int16, unsigned __int32, tagname> class indexName : public index<uint16_t, uint32_t, tagname>
{ {
public: public:
/// ///
@ -309,7 +309,7 @@ namespace ZRCola {
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// \param[in] locale 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<uint16_t> &h) : index<uint16_t, uint32_t, tagname>(h) {}
/// ///
/// Compares two tag names by locale and name (for searching) /// Compares two tag names by locale and name (for searching)
@ -362,7 +362,7 @@ namespace ZRCola {
/// ///
/// Tag index /// Tag index
/// ///
class indexTag : public index<unsigned __int16, unsigned __int32, tagname> class indexTag : public index<uint16_t, uint32_t, tagname>
{ {
public: public:
/// ///
@ -371,7 +371,7 @@ namespace ZRCola {
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// \param[in] locale Locale used to perform tag name comparison /// \param[in] locale Locale used to perform tag name comparison
/// ///
indexTag(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, tagname>(h) {} indexTag(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, tagname>(h) {}
/// ///
/// Compares two tag names by tag (for searching) /// Compares two tag names by tag (for searching)
@ -396,7 +396,7 @@ namespace ZRCola {
} }
} idxTag; ///< Tag index } idxTag; ///< Tag index
std::vector<unsigned __int16> data; ///< Tag data std::vector<uint16_t> data; ///< Tag data
public: public:
/// ///
@ -423,7 +423,7 @@ namespace ZRCola {
/// \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_ LCID locale, _Inout_ std::map<tagid_t, unsigned __int16> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const; bool Search(_In_z_ const wchar_t *str, _In_ LCID locale, _Inout_ std::map<tagid_t, uint16_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
}; };
@ -463,12 +463,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -493,14 +493,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrtag
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();
@ -536,12 +536,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -566,14 +566,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::tagnam
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -45,12 +45,12 @@ namespace ZRCola {
/// ///
/// Translation set ID /// Translation set ID
/// ///
typedef unsigned __int16 transetid_t; typedef uint16_t transetid_t;
/// ///
/// Translation sequence ID /// Translation sequence ID
/// ///
typedef unsigned __int16 transeqid_t; typedef uint16_t transeqid_t;
/// ///
/// Translation database /// Translation database
@ -65,12 +65,12 @@ namespace ZRCola {
struct translation { struct translation {
public: public:
transetid_t set; ///< Translation set ID transetid_t set; ///< Translation set ID
unsigned __int16 dst_rank; ///< Destination character rank uint16_t dst_rank; ///< Destination character rank
unsigned __int16 src_rank; ///< Source character rank uint16_t src_rank; ///< Source character rank
protected: protected:
unsigned __int16 dst_to; ///< Destination character end in \c data uint16_t dst_to; ///< Destination character end in \c data
unsigned __int16 src_to; ///< Source string end in \c data uint16_t src_to; ///< Source string end in \c data
wchar_t data[]; ///< Destination string and source character wchar_t data[]; ///< Destination string and source character
private: private:
@ -91,19 +91,19 @@ namespace ZRCola {
/// ///
inline translation( inline translation(
_In_opt_ transetid_t set = 0, _In_opt_ transetid_t set = 0,
_In_opt_ unsigned __int16 dst_rank = 0, _In_opt_ uint16_t dst_rank = 0,
_In_opt_z_count_(dst_len) const wchar_t *dst = NULL, _In_opt_z_count_(dst_len) const wchar_t *dst = NULL,
_In_opt_ size_t dst_len = 0, _In_opt_ size_t dst_len = 0,
_In_opt_ unsigned __int16 src_rank = 0, _In_opt_ uint16_t src_rank = 0,
_In_opt_z_count_(src_len) const wchar_t *src = NULL, _In_opt_z_count_(src_len) const wchar_t *src = NULL,
_In_opt_ size_t src_len = 0) _In_opt_ size_t src_len = 0)
{ {
this->set = set; this->set = set;
this->dst_rank = dst_rank; this->dst_rank = dst_rank;
this->src_rank = src_rank; this->src_rank = src_rank;
this->dst_to = static_cast<unsigned __int16>(dst_len); this->dst_to = static_cast<uint16_t>(dst_len);
if (dst && dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len); if (dst && dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len);
this->src_to = static_cast<unsigned __int16>(this->dst_to + src_len); this->src_to = static_cast<uint16_t>(this->dst_to + src_len);
if (src && src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len); if (src && src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len);
} }
@ -111,7 +111,7 @@ namespace ZRCola {
inline wchar_t* dst () { return data; }; inline wchar_t* dst () { return data; };
inline const wchar_t* dst_end() const { return data + dst_to; }; inline const wchar_t* dst_end() const { return data + dst_to; };
inline wchar_t* dst_end() { return data + dst_to; }; inline wchar_t* dst_end() { return data + dst_to; };
inline unsigned __int16 dst_len() const { return dst_to; }; inline uint16_t dst_len() const { return dst_to; };
inline wchar_t dst_at(_In_ size_t i) const inline wchar_t dst_at(_In_ size_t i) const
{ {
@ -122,7 +122,7 @@ namespace ZRCola {
inline wchar_t* src () { return data + dst_to; }; inline wchar_t* src () { return data + dst_to; };
inline const wchar_t* src_end() const { return data + src_to; }; inline const wchar_t* src_end() const { return data + src_to; };
inline wchar_t* src_end() { return data + src_to; }; inline wchar_t* src_end() { return data + src_to; };
inline unsigned __int16 src_len() const { return src_to - dst_to; }; inline uint16_t src_len() const { return src_to - dst_to; };
inline wchar_t src_at(_In_ size_t i) const inline wchar_t src_at(_In_ size_t i) const
{ {
@ -135,7 +135,7 @@ namespace ZRCola {
/// ///
/// Translation index /// Translation index
/// ///
class indexSrc : public index<unsigned __int16, unsigned __int32, translation> class indexSrc : public index<uint16_t, uint32_t, translation>
{ {
public: public:
/// ///
@ -143,7 +143,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexSrc(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {} indexSrc(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, translation>(h) {}
/// ///
/// Compares two transformations by string (for searching) /// Compares two transformations by string (for searching)
@ -200,7 +200,7 @@ namespace ZRCola {
/// ///
/// Inverse translation index /// Inverse translation index
/// ///
class indexDst : public index<unsigned __int16, unsigned __int32, translation> class indexDst : public index<uint16_t, uint32_t, translation>
{ {
public: public:
/// ///
@ -208,7 +208,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexDst(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {} indexDst(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, translation>(h) {}
/// ///
/// Compares two transformations by character (for searching) /// Compares two transformations by character (for searching)
@ -262,7 +262,7 @@ namespace ZRCola {
} idxDst; ///< Inverse translation index } idxDst; ///< Inverse translation index
std::vector<unsigned __int16> data; ///< Transformation data std::vector<uint16_t> data; ///< Transformation data
public: public:
/// ///
@ -338,8 +338,8 @@ namespace ZRCola {
transetid_t set; ///< Translation set ID transetid_t set; ///< Translation set ID
protected: protected:
unsigned __int16 src_to; ///< Source name end in \c data uint16_t src_to; ///< Source name end in \c data
unsigned __int16 dst_to; ///< Sestination name end in \c data uint16_t dst_to; ///< Sestination name end in \c data
wchar_t data[]; ///< Source and destination names wchar_t data[]; ///< Source and destination names
private: private:
@ -364,9 +364,9 @@ namespace ZRCola {
_In_opt_ size_t dst_len = 0) _In_opt_ size_t dst_len = 0)
{ {
this->set = set; this->set = set;
this->src_to = static_cast<unsigned __int16>(src_len); this->src_to = static_cast<uint16_t>(src_len);
if (src && src_len) memcpy(this->data, src, sizeof(wchar_t)*src_len); if (src && src_len) memcpy(this->data, src, sizeof(wchar_t)*src_len);
this->dst_to = static_cast<unsigned __int16>(this->src_to + dst_len); this->dst_to = static_cast<uint16_t>(this->src_to + dst_len);
if (dst && dst_len) memcpy(this->data + this->src_to, dst, sizeof(wchar_t)*dst_len); if (dst && dst_len) memcpy(this->data + this->src_to, dst, sizeof(wchar_t)*dst_len);
} }
@ -374,20 +374,20 @@ namespace ZRCola {
inline wchar_t* src () { return data; }; inline wchar_t* src () { return data; };
inline const wchar_t* src_end() const { return data + src_to; }; inline const wchar_t* src_end() const { return data + src_to; };
inline wchar_t* src_end() { return data + src_to; }; inline wchar_t* src_end() { return data + src_to; };
inline unsigned __int16 src_len() const { return src_to; }; inline uint16_t src_len() const { return src_to; };
inline const wchar_t* dst () const { return data + src_to; }; inline const wchar_t* dst () const { return data + src_to; };
inline wchar_t* dst () { return data + src_to; }; inline wchar_t* dst () { return data + src_to; };
inline const wchar_t* dst_end() const { return data + dst_to; }; inline const wchar_t* dst_end() const { return data + dst_to; };
inline wchar_t* dst_end() { return data + dst_to; }; inline wchar_t* dst_end() { return data + dst_to; };
inline unsigned __int16 dst_len() const { return dst_to - src_to; }; inline uint16_t dst_len() const { return dst_to - src_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Translation set index /// Translation set index
/// ///
class indexTranSet : public index<unsigned __int16, unsigned __int32, transet> class indexTranSet : public index<uint16_t, uint32_t, transet>
{ {
public: public:
/// ///
@ -395,7 +395,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexTranSet(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, transet>(h) {} indexTranSet(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, transet>(h) {}
/// ///
/// Compares two translation sets by ID (for searching) /// Compares two translation sets by ID (for searching)
@ -417,7 +417,7 @@ namespace ZRCola {
} }
} idxTranSet; ///< Translation set index } idxTranSet; ///< Translation set index
std::vector<unsigned __int16> data; ///< Translation set data std::vector<uint16_t> data; ///< Translation set data
public: public:
/// ///
@ -452,11 +452,11 @@ namespace ZRCola {
struct transeq { struct transeq {
public: public:
transeqid_t seq; ///< Translation sequence ID transeqid_t seq; ///< Translation sequence ID
unsigned __int16 rank; ///< Translation sequence rank uint16_t rank; ///< Translation sequence rank
protected: protected:
unsigned __int16 name_to; ///< Translation sequence name end in \c data uint16_t name_to; ///< Translation sequence name end in \c data
unsigned __int16 sets_to; ///< Translation sequence sets end in \c data uint16_t sets_to; ///< Translation sequence sets end in \c data
wchar_t data[]; ///< Translation sequence name and sets wchar_t data[]; ///< Translation sequence name and sets
private: private:
@ -476,7 +476,7 @@ namespace ZRCola {
/// ///
inline transeq( inline transeq(
_In_opt_ transeqid_t seq = 0, _In_opt_ transeqid_t seq = 0,
_In_opt_ unsigned __int16 rank = 0, _In_opt_ uint16_t 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,
_In_opt_count_ (sets_len) const transetid_t *sets = NULL, _In_opt_count_ (sets_len) const transetid_t *sets = NULL,
@ -484,9 +484,9 @@ namespace ZRCola {
{ {
this->seq = seq; this->seq = seq;
this->rank = rank; this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len); this->name_to = static_cast<uint16_t>(name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len); if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
this->sets_to = static_cast<unsigned __int16>(this->name_to + sets_len); this->sets_to = static_cast<uint16_t>(this->name_to + sets_len);
if (sets && sets_len) memcpy(this->data + this->name_to, sets, sizeof(transetid_t)*sets_len); if (sets && sets_len) memcpy(this->data + this->name_to, sets, sizeof(transetid_t)*sets_len);
} }
@ -494,20 +494,20 @@ namespace ZRCola {
inline wchar_t* name () { return data; }; inline wchar_t* name () { return data; };
inline const wchar_t* name_end() const { return data + name_to; }; inline const wchar_t* name_end() const { return data + name_to; };
inline wchar_t* name_end() { return data + name_to; }; inline wchar_t* name_end() { return data + name_to; };
inline unsigned __int16 name_len() const { return name_to; }; inline uint16_t name_len() const { return name_to; };
inline const transetid_t* sets () const { return reinterpret_cast<const transetid_t*>(data + name_to); }; inline const transetid_t* sets () const { return reinterpret_cast<const transetid_t*>(data + name_to); };
inline transetid_t* sets () { return reinterpret_cast< transetid_t*>(data + name_to); }; inline transetid_t* sets () { return reinterpret_cast< transetid_t*>(data + name_to); };
inline const transetid_t* sets_end() const { return reinterpret_cast<const transetid_t*>(data + sets_to); }; inline const transetid_t* sets_end() const { return reinterpret_cast<const transetid_t*>(data + sets_to); };
inline transetid_t* sets_end() { return reinterpret_cast< transetid_t*>(data + sets_to); }; inline transetid_t* sets_end() { return reinterpret_cast< transetid_t*>(data + sets_to); };
inline unsigned __int16 sets_len() const { return sets_to - name_to; }; inline uint16_t sets_len() const { return sets_to - name_to; };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Translation sequence index /// Translation sequence index
/// ///
class indexTranSeq : public index<unsigned __int16, unsigned __int32, transeq> class indexTranSeq : public index<uint16_t, uint32_t, transeq>
{ {
public: public:
/// ///
@ -515,7 +515,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexTranSeq(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, transeq>(h) {} indexTranSeq(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, transeq>(h) {}
/// ///
/// Compares two translation sequences by ID (for searching) /// Compares two translation sequences by ID (for searching)
@ -540,7 +540,7 @@ namespace ZRCola {
/// ///
/// Rank index /// Rank index
/// ///
class indexRank : public index<unsigned __int16, unsigned __int32, transeq> class indexRank : public index<uint16_t, uint32_t, transeq>
{ {
public: public:
/// ///
@ -548,7 +548,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexRank(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, transeq>(h) {} indexRank(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, transeq>(h) {}
/// ///
/// Compares two translation sets by rank (for searching) /// Compares two translation sets by rank (for searching)
@ -585,10 +585,10 @@ namespace ZRCola {
if (a.rank < b.rank) return -1; if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1; else if (a.rank > b.rank) return +1;
unsigned __int16 uint16_t
a_name_len = a.name_len(), a_name_len = a.name_len(),
b_name_len = b.name_len(); b_name_len = b.name_len();
int r = _wcsncoll(a.name(), b.name(), std::min<unsigned __int16>(a_name_len, b_name_len)); int r = _wcsncoll(a.name(), b.name(), std::min<uint16_t>(a_name_len, b_name_len));
if (r != 0) return r; if (r != 0) return r;
if (a_name_len < b_name_len) return -1; if (a_name_len < b_name_len) return -1;
else if (a_name_len > b_name_len) return +1; else if (a_name_len > b_name_len) return +1;
@ -597,7 +597,7 @@ namespace ZRCola {
} }
} idxRank; ///< Rank index } idxRank; ///< Rank index
std::vector<unsigned __int16> data; ///< Translation sequence data std::vector<uint16_t> data; ///< Translation sequence data
public: public:
/// ///
@ -654,12 +654,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -684,14 +684,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transl
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();
@ -723,12 +723,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -749,14 +749,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();
@ -792,12 +792,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -822,14 +822,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -3,7 +3,8 @@
Copyright © 2015-2022 Amebis Copyright © 2015-2022 Amebis
*/ */
#pragma once #ifndef __PCH_H__
#define __PCH_H__
#include "../../../include/version.h" #include "../../../include/version.h"
@ -17,3 +18,5 @@
#include <algorithm> #include <algorithm>
#include <cwctype> #include <cwctype>
#endif

View File

@ -6,7 +6,7 @@
#include "pch.h" #include "pch.h"
bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<std::wstring, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, uint16_t> &tags, _In_ const character_db &ch_db, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<std::wstring, charrank_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const
{ {
for (auto tag = tags.cbegin(), tag_end = tags.cend(); tag != tag_end; ++tag) { for (auto tag = tags.cbegin(), tag_end = tags.cend(); tag != tag_end; ++tag) {
if (fn_abort && fn_abort(cookie)) return false; if (fn_abort && fn_abort(cookie)) return false;
@ -17,7 +17,7 @@ bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &t
for (size_t i = start; i < end; i++) { for (size_t i = start; i < end; i++) {
if (fn_abort && fn_abort(cookie)) return false; if (fn_abort && fn_abort(cookie)) return false;
const chrtag &ct = idxTag[i]; const chrtag &ct = idxTag[i];
unsigned __int16 len = ct.chr_len(); uint16_t len = ct.chr_len();
if (cats.find(ch_db.GetCharCat(ct.chr(), len)) != cats.end()) { if (cats.find(ch_db.GetCharCat(ct.chr(), len)) != cats.end()) {
std::wstring chr(ct.chr(), len); std::wstring chr(ct.chr(), len);
auto idx = hits.find(chr); auto idx = hits.find(chr);
@ -37,7 +37,7 @@ bool ZRCola::chrtag_db::Search(_In_ const std::map<tagid_t, unsigned __int16> &t
} }
bool ZRCola::tagname_db::Search(_In_z_ const wchar_t *str, _In_ LCID locale, _Inout_ std::map<tagid_t, unsigned __int16> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const bool ZRCola::tagname_db::Search(_In_z_ const wchar_t *str, _In_ LCID locale, _Inout_ std::map<tagid_t, uint16_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const
{ {
assert(str); assert(str);
@ -92,7 +92,7 @@ bool ZRCola::tagname_db::Search(_In_z_ const wchar_t *str, _In_ LCID locale, _In
auto idx = hits.find(val.tag); auto idx = hits.find(val.tag);
if (idx == hits.end()) { if (idx == hits.end()) {
// New tag. // New tag.
hits.insert(std::make_pair(val.tag, (unsigned __int16)1)); hits.insert(std::make_pair(val.tag, (uint16_t)1));
} else { } else {
// Increase count for existing tag. // Increase count for existing tag.
idx->second++; idx->second++;

View File

@ -24,7 +24,7 @@ namespace ZRCola {
/// ///
/// Character group ID /// Character group ID
/// ///
typedef unsigned __int16 chrgrpid_t; typedef uint16_t chrgrpid_t;
/// ///
@ -40,11 +40,11 @@ namespace ZRCola {
struct chrgrp { struct chrgrp {
public: public:
chrgrpid_t grp; ///< Character group ID chrgrpid_t grp; ///< Character group ID
unsigned __int16 rank; ///< Character group rank uint16_t rank; ///< Character group rank
protected: protected:
unsigned __int16 name_to; ///< Character group name end in \c data uint16_t name_to; ///< Character group name end in \c data
unsigned __int16 chrlst_to; ///< Character list end in \c data uint16_t chrlst_to; ///< Character list end in \c data
wchar_t data[]; ///< Character group name, character list, bit vector if particular character is displayed initially wchar_t data[]; ///< Character group name, character list, bit vector if particular character is displayed initially
public: public:
@ -61,18 +61,18 @@ namespace ZRCola {
/// ///
inline chrgrp( inline chrgrp(
_In_opt_ chrgrpid_t grp = 0, _In_opt_ chrgrpid_t grp = 0,
_In_opt_ unsigned __int16 rank = 0, _In_opt_ uint16_t 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,
_In_opt_z_count_(chrlst_len) const wchar_t *chrlst = NULL, _In_opt_z_count_(chrlst_len) const wchar_t *chrlst = NULL,
_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 uint16_t *chrshow = NULL)
{ {
this->grp = grp; this->grp = grp;
this->rank = rank; this->rank = rank;
this->name_to = static_cast<unsigned __int16>(name_len); this->name_to = static_cast<uint16_t>(name_len);
if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len); if (name && name_len) memcpy(this->data, name, sizeof(wchar_t)*name_len);
this->chrlst_to = static_cast<unsigned __int16>(this->name_to + chrlst_len); this->chrlst_to = static_cast<uint16_t>(this->name_to + chrlst_len);
if (chrlst && chrshow && chrlst_len) { if (chrlst && chrshow && chrlst_len) {
memcpy(this->data + this->name_to, chrlst, sizeof(wchar_t)*chrlst_len); memcpy(this->data + this->name_to, chrlst, sizeof(wchar_t)*chrlst_len);
memcpy(this->data + this->chrlst_to, chrshow, (chrlst_len + sizeof(*data)*8 - 1)/8); memcpy(this->data + this->chrlst_to, chrshow, (chrlst_len + sizeof(*data)*8 - 1)/8);
@ -83,26 +83,26 @@ namespace ZRCola {
inline wchar_t* name () { return data; }; inline wchar_t* name () { return data; };
inline const wchar_t* name_end() const { return data + name_to; }; inline const wchar_t* name_end() const { return data + name_to; };
inline wchar_t* name_end() { return data + name_to; }; inline wchar_t* name_end() { return data + name_to; };
inline unsigned __int16 name_len() const { return name_to; }; inline uint16_t name_len() const { return name_to; };
inline const wchar_t* chrlst () const { return data + name_to; }; inline const wchar_t* chrlst () const { return data + name_to; };
inline wchar_t* chrlst () { return data + name_to; }; inline wchar_t* chrlst () { return data + name_to; };
inline const wchar_t* chrlst_end() const { return data + chrlst_to; }; inline const wchar_t* chrlst_end() const { return data + chrlst_to; };
inline wchar_t* chrlst_end() { return data + chrlst_to; }; inline wchar_t* chrlst_end() { return data + chrlst_to; };
inline unsigned __int16 chrlst_len() const { return chrlst_to - name_to; }; inline uint16_t chrlst_len() const { return chrlst_to - name_to; };
inline const unsigned __int16* chrshow () const { return reinterpret_cast<const unsigned __int16*>(data + chrlst_to ); }; inline const uint16_t* chrshow () const { return reinterpret_cast<const uint16_t*>(data + chrlst_to ); };
inline unsigned __int16* chrshow () { return reinterpret_cast< unsigned __int16*>(data + chrlst_to ); }; inline uint16_t* chrshow () { return reinterpret_cast< uint16_t*>(data + chrlst_to ); };
inline const unsigned __int16* chrshow_end() const { return reinterpret_cast<const unsigned __int16*>(data + chrlst_to + chrshow_len()); }; inline const uint16_t* chrshow_end() const { return reinterpret_cast<const uint16_t*>(data + chrlst_to + chrshow_len()); };
inline unsigned __int16* chrshow_end() { return reinterpret_cast< unsigned __int16*>(data + chrlst_to + chrshow_len()); }; inline uint16_t* chrshow_end() { return reinterpret_cast< uint16_t*>(data + chrlst_to + chrshow_len()); };
inline unsigned __int16 chrshow_len() const { return (chrlst_len() + sizeof(*data)*8 - 1)/(sizeof(*data)*8); }; inline uint16_t chrshow_len() const { return (chrlst_len() + sizeof(*data)*8 - 1)/(sizeof(*data)*8); };
}; };
#pragma pack(pop) #pragma pack(pop)
/// ///
/// Rank index /// Rank index
/// ///
class indexRank : public index<unsigned __int16, unsigned __int32, chrgrp> class indexRank : public index<uint16_t, uint32_t, chrgrp>
{ {
public: public:
/// ///
@ -110,7 +110,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexRank(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrgrp>(h) {} indexRank(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, chrgrp>(h) {}
/// ///
/// Compares two character groups by rank (for searching) /// Compares two character groups by rank (for searching)
@ -147,10 +147,10 @@ namespace ZRCola {
if (a.rank < b.rank) return -1; if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1; else if (a.rank > b.rank) return +1;
unsigned __int16 uint16_t
a_name_len = a.name_len(), a_name_len = a.name_len(),
b_name_len = b.name_len(); b_name_len = b.name_len();
int r = _wcsncoll(a.name(), b.name(), std::min<unsigned __int16>(a_name_len, b_name_len)); int r = _wcsncoll(a.name(), b.name(), std::min<uint16_t>(a_name_len, b_name_len));
if (r != 0) return r; if (r != 0) return r;
if (a_name_len < b_name_len) return -1; if (a_name_len < b_name_len) return -1;
else if (a_name_len > b_name_len) return +1; else if (a_name_len > b_name_len) return +1;
@ -159,7 +159,7 @@ namespace ZRCola {
} }
} idxRank; ///< Rank index } idxRank; ///< Rank index
std::vector<unsigned __int16> data; ///< Character groups data std::vector<uint16_t> data; ///< Character groups data
public: public:
/// ///
@ -200,12 +200,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -226,14 +226,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();

View File

@ -46,12 +46,12 @@ namespace ZRCola {
struct key_t { struct key_t {
wchar_t key; ///< Key wchar_t key; ///< Key
unsigned __int16 modifiers; ///< Modifiers (bitwise combination of SHIFT, CTRL and ALT) uint16_t modifiers; ///< Modifiers (bitwise combination of SHIFT, CTRL and ALT)
}; };
protected: protected:
unsigned __int16 chr_to; ///< Character end in \c data uint16_t chr_to; ///< Character end in \c data
unsigned __int16 seq_to; ///< Key sequence end in \c data uint16_t seq_to; ///< Key sequence end in \c data
wchar_t data[]; ///< Character and key sequence wchar_t data[]; ///< Character and key sequence
public: public:
@ -69,9 +69,9 @@ namespace ZRCola {
_In_opt_z_count_(chr_len) const wchar_t *chr = NULL, _In_opt_z_count_(chr_len) const wchar_t *chr = NULL,
_In_opt_ size_t chr_len = 0) _In_opt_ size_t chr_len = 0)
{ {
this->chr_to = static_cast<unsigned __int16>(chr_len); this->chr_to = static_cast<uint16_t>(chr_len);
if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len); if (chr && chr_len) memcpy(this->data, chr, sizeof(wchar_t)*chr_len);
this->seq_to = static_cast<unsigned __int16>(this->chr_to + seq_count * sizeof(key_t) / sizeof(*data)); this->seq_to = static_cast<uint16_t>(this->chr_to + seq_count * sizeof(key_t) / sizeof(*data));
if (seq && seq_count) memcpy(this->data + this->chr_to, seq, sizeof(key_t)*seq_count); if (seq && seq_count) memcpy(this->data + this->chr_to, seq, sizeof(key_t)*seq_count);
} }
@ -79,13 +79,13 @@ namespace ZRCola {
inline wchar_t* chr () { return data; }; inline wchar_t* chr () { return data; };
inline const wchar_t* chr_end() const { return data + chr_to; }; inline const wchar_t* chr_end() const { return data + chr_to; };
inline wchar_t* chr_end() { return data + chr_to; }; inline wchar_t* chr_end() { return data + chr_to; };
inline unsigned __int16 chr_len() const { return chr_to; }; inline uint16_t chr_len() const { return chr_to; };
inline const key_t* seq () const { return reinterpret_cast<const key_t*>(data + chr_to); }; inline const key_t* seq () const { return reinterpret_cast<const key_t*>(data + chr_to); };
inline key_t* seq () { return reinterpret_cast< key_t*>(data + chr_to); }; inline key_t* seq () { return reinterpret_cast< key_t*>(data + chr_to); };
inline const key_t* seq_end() const { return reinterpret_cast<const key_t*>(data + seq_to); }; inline const key_t* seq_end() const { return reinterpret_cast<const key_t*>(data + seq_to); };
inline key_t* seq_end() { return reinterpret_cast< key_t*>(data + seq_to); }; inline key_t* seq_end() { return reinterpret_cast< key_t*>(data + seq_to); };
inline unsigned __int16 seq_len() const { return (seq_to - chr_to) * sizeof(*data) / sizeof(key_t); }; inline uint16_t seq_len() const { return (seq_to - chr_to) * sizeof(*data) / sizeof(key_t); };
/// ///
/// Compares two key sequences /// Compares two key sequences
@ -118,7 +118,7 @@ namespace ZRCola {
/// ///
/// Character index /// Character index
/// ///
class indexChr : public index<unsigned __int16, unsigned __int32, keyseq> class indexChr : public index<uint16_t, uint32_t, keyseq>
{ {
public: public:
/// ///
@ -126,7 +126,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexChr(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, keyseq>(h) {} indexChr(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, keyseq>(h) {}
/// ///
/// Compares two key sequences by character (for searching) /// Compares two key sequences by character (for searching)
@ -174,7 +174,7 @@ namespace ZRCola {
/// ///
/// Key index /// Key index
/// ///
class indexKey : public index<unsigned __int16, unsigned __int32, keyseq> class indexKey : public index<uint16_t, uint32_t, keyseq>
{ {
public: public:
/// ///
@ -182,7 +182,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \param[in] h Reference to vector holding the data
/// ///
indexKey(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, keyseq>(h) {} indexKey(_In_ std::vector<uint16_t> &h) : index<uint16_t, uint32_t, keyseq>(h) {}
/// ///
/// Compares two key sequences by key (for searching) /// Compares two key sequences by key (for searching)
@ -226,7 +226,7 @@ namespace ZRCola {
} }
} idxKey; ///< Key index } idxKey; ///< Key index
std::vector<unsigned __int16> data; ///< Key sequences data std::vector<uint16_t> data; ///< Key sequences data
public: public:
/// ///
@ -308,12 +308,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::k
} }
#endif #endif
if (stream.fail()) return stream; if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count; uint32_t count = (uint32_t)data_count;
stream.write((const char*)&count, sizeof(count)); stream.write((const char*)&count, sizeof(count));
// Write data. // Write data.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.write((const char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
return stream; return stream;
} }
@ -338,14 +338,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::keyseq
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count; uint32_t count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) { if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count)); stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
} else } else
db.data.clear(); db.data.clear();