Switch integer datatypes to C99
This makes code more portable. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
5cc005583c
commit
63fda12c99
@ -149,10 +149,10 @@ void wxZRColaCharacterCatalogPanel::Update()
|
||||
} else {
|
||||
// Select frequently used characters only.
|
||||
const wchar_t *src = cg.chrlst();
|
||||
const unsigned __int16 *shown = cg.chrshow();
|
||||
const uint16_t *shown = cg.chrshow();
|
||||
wxArrayString chars;
|
||||
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);
|
||||
if (mask & 1)
|
||||
chars.Add(wxString(src + i, len));
|
||||
|
@ -301,7 +301,7 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
||||
// Add name to the list.
|
||||
tag_names.push_back(std::wstring(tn.name(), tn.name_end()));
|
||||
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.
|
||||
break;
|
||||
}
|
||||
@ -718,7 +718,7 @@ wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
|
||||
|
||||
{
|
||||
// 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_ct_db.Search(hits_tag, app->m_chr_db, m_cats, hits, TestDestroyS, this)) return (wxThread::ExitCode)1;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ void wxZRColaComposerPanel::RestoreFromStateFile()
|
||||
wxFFile file(fileName, wxT("rb"));
|
||||
if (file.IsOpened()) {
|
||||
// Load source text.
|
||||
unsigned __int64 n;
|
||||
uint64_t n;
|
||||
file.Read(&n, sizeof(n));
|
||||
if (!file.Error()) {
|
||||
wxString source;
|
||||
|
@ -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.keys .clear();
|
||||
@ -205,7 +205,7 @@ void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar
|
||||
|
||||
// Convert the index.
|
||||
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.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.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.
|
||||
names.push_back(std::move(name));
|
||||
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.
|
||||
break;
|
||||
}
|
||||
|
@ -222,11 +222,11 @@ namespace ZRCola {
|
||||
///
|
||||
class chrgrp {
|
||||
public:
|
||||
short grp; ///< Character group ID
|
||||
short rank; ///< Rank
|
||||
std::wstring name; ///< Name
|
||||
std::vector<wchar_t> chars; ///< Characters (zero-delimited)
|
||||
std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially
|
||||
short grp; ///< Character group ID
|
||||
short rank; ///< Rank
|
||||
std::wstring name; ///< Name
|
||||
std::vector<wchar_t> chars; ///< Characters (zero-delimited)
|
||||
std::vector<uint16_t> show; ///< Bit vector if particular character from \c chars is displayed initially
|
||||
|
||||
inline chrgrp() : grp(0), rank(0) {}
|
||||
};
|
||||
@ -340,7 +340,7 @@ namespace ZRCola {
|
||||
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:
|
||||
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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
db.data.push_back((unsigned __int16)rec.dst.rank);
|
||||
db.data.push_back((unsigned __int16)rec.src.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
db.data.push_back((uint16_t)rec.dst.rank);
|
||||
db.data.push_back((uint16_t)rec.src.rank);
|
||||
std::wstring::size_type n = rec.dst.str.length();
|
||||
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();
|
||||
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.src.str.cbegin(), rec.src.str.cend());
|
||||
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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
std::wstring::size_type n = rec.src.length();
|
||||
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();
|
||||
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.dst.cbegin(), rec.dst.cend());
|
||||
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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.seq);
|
||||
db.data.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.seq);
|
||||
db.data.push_back((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
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();
|
||||
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());
|
||||
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.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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
uint32_t idx = db.data.size();
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
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);
|
||||
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());
|
||||
for (auto kc = rec.seq.cbegin(), kc_end = rec.seq.cend(); kc != kc_end; ++kc) {
|
||||
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)
|
||||
{
|
||||
unsigned __int32 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));
|
||||
uint32_t idx = db.data.size();
|
||||
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();
|
||||
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.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)
|
||||
{
|
||||
unsigned __int32 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));
|
||||
uint32_t idx = db.data.size();
|
||||
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();
|
||||
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.idxChr .push_back(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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.grp);
|
||||
db.data.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.grp);
|
||||
db.data.push_back((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
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();
|
||||
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.chars.cbegin(), rec.chars.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)
|
||||
{
|
||||
unsigned __int32 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));
|
||||
uint32_t idx = db.data.size();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
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.second.desc.cbegin(), rec.second.desc.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)
|
||||
{
|
||||
unsigned __int32 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.push_back((unsigned __int16)rec.rank);
|
||||
uint32_t idx = db.data.size();
|
||||
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((uint16_t)rec.rank);
|
||||
std::wstring::size_type n = rec.name.length();
|
||||
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.idxChrCat.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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.tag);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.tag);
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
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.idxChr.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 nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) {
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.tag);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.tag);
|
||||
db.data.push_back(LOWORD(ln->first));
|
||||
db.data.push_back(HIWORD(ln->first));
|
||||
std::wstring::size_type n = nm->length();
|
||||
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.idxName.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)
|
||||
{
|
||||
unsigned __int32 idx = db.data.size();
|
||||
db.data.push_back((unsigned __int16)rec.set);
|
||||
uint32_t idx = db.data.size();
|
||||
db.data.push_back((uint16_t)rec.set);
|
||||
std::wstring::size_type n = rec.chr.length();
|
||||
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.idxChr.push_back(idx);
|
||||
|
||||
|
@ -177,13 +177,13 @@ namespace ZRCola {
|
||||
///
|
||||
struct character {
|
||||
public:
|
||||
chrcatid_t cat; ///> Character category ID
|
||||
chrcatid_t cat; ///> Character category ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
unsigned __int16 desc_to; ///< Character description end in \c data
|
||||
unsigned __int16 rel_to; ///< Related characters end in \c data
|
||||
wchar_t data[]; ///< Character, character description
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
uint16_t desc_to; ///< Character description end in \c data
|
||||
uint16_t rel_to; ///< Related characters end in \c data
|
||||
wchar_t data[]; ///< Character, character description
|
||||
|
||||
private:
|
||||
inline character(_In_ const character &other);
|
||||
@ -211,38 +211,38 @@ namespace ZRCola {
|
||||
_In_opt_ size_t rel_len = 0)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
|
||||
inline const wchar_t* desc () const { return data + chr_to; };
|
||||
inline wchar_t* desc () { return data + chr_to; };
|
||||
inline const wchar_t* desc_end() const { 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 const wchar_t* desc () const { return data + chr_to; };
|
||||
inline wchar_t* desc () { return data + chr_to; };
|
||||
inline const wchar_t* desc_end() const { return data + desc_to; };
|
||||
inline wchar_t* desc_end() { return data + desc_to; };
|
||||
inline uint16_t desc_len() const { return desc_to - chr_to; };
|
||||
|
||||
inline const wchar_t* rel () const { return data + desc_to; };
|
||||
inline wchar_t* rel () { return data + desc_to; };
|
||||
inline const wchar_t* rel_end() const { 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 const wchar_t* rel () const { return data + desc_to; };
|
||||
inline wchar_t* rel () { return data + desc_to; };
|
||||
inline const wchar_t* rel_end() const { return data + rel_to; };
|
||||
inline wchar_t* rel_end() { return data + rel_to; };
|
||||
inline uint16_t rel_len() const { return rel_to - desc_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, character>
|
||||
class indexChr : public index<uint16_t, uint32_t, character>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -250,7 +250,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -272,9 +272,9 @@ namespace ZRCola {
|
||||
}
|
||||
} idxChr; ///< Character index
|
||||
|
||||
textindex<wchar_t, wchar_t, unsigned __int32> idxDsc; ///< Description index
|
||||
textindex<wchar_t, wchar_t, unsigned __int32> idxDscSub; ///< Description index (sub-terms)
|
||||
std::vector<unsigned __int16> data; ///< Character data
|
||||
textindex<wchar_t, wchar_t, uint32_t> idxDsc; ///< Description index
|
||||
textindex<wchar_t, wchar_t, uint32_t> idxDscSub; ///< Description index (sub-terms)
|
||||
std::vector<uint16_t> data; ///< Character data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -341,12 +341,12 @@ namespace ZRCola {
|
||||
///
|
||||
struct chrcat {
|
||||
public:
|
||||
chrcatid_t cat; ///< Character category ID
|
||||
unsigned __int16 rank; ///< Character category rank
|
||||
chrcatid_t cat; ///< Character category ID
|
||||
uint16_t rank; ///< Character category rank
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Character category name end in \c data
|
||||
wchar_t data[]; ///< Character category name
|
||||
uint16_t name_to; ///< Character category name end in \c data
|
||||
wchar_t data[]; ///< Character category name
|
||||
|
||||
private:
|
||||
inline chrcat(_In_ const chrcat &other);
|
||||
@ -363,13 +363,13 @@ namespace ZRCola {
|
||||
///
|
||||
inline chrcat(
|
||||
_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_ size_t name_len = 0)
|
||||
{
|
||||
this->cat = cat;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -377,14 +377,14 @@ namespace ZRCola {
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline uint16_t name_len() const { return name_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character category index
|
||||
///
|
||||
class indexChrCat : public index<unsigned __int16, unsigned __int32, chrcat>
|
||||
class indexChrCat : public index<uint16_t, uint32_t, chrcat>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -392,7 +392,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -417,7 +417,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Rank index
|
||||
///
|
||||
class indexRank : public index<unsigned __int16, unsigned __int32, chrcat>
|
||||
class indexRank : public index<uint16_t, uint32_t, chrcat>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -425,7 +425,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -462,10 +462,10 @@ namespace ZRCola {
|
||||
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(),
|
||||
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 (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
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Character category data
|
||||
std::vector<uint16_t> data; ///< Character category data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -525,14 +525,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::charac
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
@ -572,12 +572,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -611,12 +611,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -641,14 +641,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifdef _WIN32
|
||||
#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h.
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include <sal.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
@ -33,8 +34,8 @@
|
||||
|
||||
|
||||
namespace ZRCola {
|
||||
typedef unsigned __int32 recordid_t;
|
||||
typedef unsigned __int32 recordsize_t;
|
||||
typedef uint32_t recordid_t;
|
||||
typedef uint32_t recordsize_t;
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
@ -210,7 +211,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// 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>
|
||||
{
|
||||
protected:
|
||||
@ -406,7 +407,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// 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> >
|
||||
{
|
||||
public:
|
||||
@ -638,7 +639,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::i
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// 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>
|
||||
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.
|
||||
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>
|
||||
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.
|
||||
auto idx_count = idx.size();
|
||||
@ -703,7 +704,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)idx_count;
|
||||
count = (uint32_t)idx_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write index data.
|
||||
@ -720,7 +721,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)key_count;
|
||||
count = (uint32_t)key_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// Write key data.
|
||||
@ -737,7 +738,7 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
if (stream.fail()) return stream;
|
||||
count = (unsigned __int32)value_count;
|
||||
count = (uint32_t)value_count;
|
||||
stream.write((const char*)&count, sizeof(count));
|
||||
|
||||
// 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>
|
||||
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.
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
|
@ -29,7 +29,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Highlight set ID
|
||||
///
|
||||
typedef unsigned __int16 hlghtsetid_t;
|
||||
typedef uint16_t hlghtsetid_t;
|
||||
|
||||
///
|
||||
/// Highlight database
|
||||
@ -43,11 +43,11 @@ namespace ZRCola {
|
||||
///
|
||||
struct highlight {
|
||||
public:
|
||||
hlghtsetid_t set; ///< Highlight set ID
|
||||
hlghtsetid_t set; ///< Highlight set ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
|
||||
private:
|
||||
inline highlight(_In_ const highlight &other);
|
||||
@ -67,15 +67,15 @@ namespace ZRCola {
|
||||
_In_opt_ size_t chr_len = 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
|
||||
inline wchar_t chr_at(_In_ size_t i) const
|
||||
{
|
||||
@ -87,7 +87,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Highlight index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, highlight>
|
||||
class indexChr : public index<uint16_t, uint32_t, highlight>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -95,7 +95,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -138,7 +138,7 @@ namespace ZRCola {
|
||||
} idxChr; ///< Highlight index
|
||||
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Highlight data
|
||||
std::vector<uint16_t> data; ///< Highlight data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -197,12 +197,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::h
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -223,14 +223,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::highli
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -32,11 +32,11 @@ namespace ZRCola {
|
||||
///
|
||||
struct langchar {
|
||||
public:
|
||||
langid_t lang; ///< Language ID
|
||||
langid_t lang; ///< Language ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
|
||||
private:
|
||||
inline langchar(_In_ const langchar &other);
|
||||
@ -56,22 +56,22 @@ namespace ZRCola {
|
||||
_In_opt_ size_t chr_len = 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, langchar>
|
||||
class indexChr : public index<uint16_t, uint32_t, langchar>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -79,7 +79,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -109,7 +109,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Language Index
|
||||
///
|
||||
class indexLang : public index<unsigned __int16, unsigned __int32, langchar>
|
||||
class indexLang : public index<uint16_t, uint32_t, langchar>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -117,7 +117,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -143,7 +143,7 @@ namespace ZRCola {
|
||||
} idxLang; ///< Language index
|
||||
#endif
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Character data
|
||||
std::vector<uint16_t> data; ///< Character data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -196,11 +196,11 @@ namespace ZRCola {
|
||||
///
|
||||
struct language {
|
||||
public:
|
||||
langid_t lang; ///< Language ID
|
||||
langid_t lang; ///< Language ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Language name end in \c data
|
||||
wchar_t data[]; ///< Language name
|
||||
uint16_t name_to; ///< Language name end in \c data
|
||||
wchar_t data[]; ///< Language name
|
||||
|
||||
private:
|
||||
inline language(_In_ const language &other);
|
||||
@ -220,22 +220,22 @@ namespace ZRCola {
|
||||
_In_opt_ size_t name_len = 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline uint16_t name_len() const { return name_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Language index
|
||||
///
|
||||
class indexLang : public index<unsigned __int16, unsigned __int32, language>
|
||||
class indexLang : public index<uint16_t, uint32_t, language>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -243,7 +243,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -265,7 +265,7 @@ namespace ZRCola {
|
||||
}
|
||||
} idxLang; ///< Language index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Language data
|
||||
std::vector<uint16_t> data; ///< Language data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -322,12 +322,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -354,14 +354,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langch
|
||||
#endif
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
@ -393,12 +393,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::l
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -419,14 +419,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langua
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
namespace ZRCola {
|
||||
typedef unsigned __int16 tagid_t;
|
||||
typedef uint16_t tagid_t;
|
||||
|
||||
///
|
||||
/// Character Tag Database
|
||||
@ -35,11 +35,11 @@ namespace ZRCola {
|
||||
///
|
||||
struct chrtag {
|
||||
public:
|
||||
tagid_t tag; ///< Tag ID
|
||||
tagid_t tag; ///< Tag ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
wchar_t data[]; ///< Character
|
||||
|
||||
private:
|
||||
inline chrtag(_In_ const chrtag &other);
|
||||
@ -59,22 +59,22 @@ namespace ZRCola {
|
||||
_In_opt_ tagid_t tag = 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline uint16_t chr_len() const { return chr_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Character Index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, chrtag>
|
||||
class indexChr : public index<uint16_t, uint32_t, chrtag>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -82,7 +82,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -130,7 +130,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Tag Index
|
||||
///
|
||||
class indexTag : public index<unsigned __int16, unsigned __int32, chrtag>
|
||||
class indexTag : public index<uint16_t, uint32_t, chrtag>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -138,7 +138,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -182,7 +182,7 @@ namespace ZRCola {
|
||||
}
|
||||
} idxTag; ///< Tag index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Character tags data
|
||||
std::vector<uint16_t> data; ///< Character tags data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -210,7 +210,7 @@ namespace ZRCola {
|
||||
/// \param[in ] fn_abort Pointer to function to periodically test for search cancellation
|
||||
/// \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;
|
||||
};
|
||||
|
||||
|
||||
@ -229,12 +229,12 @@ namespace ZRCola {
|
||||
///
|
||||
struct tagname {
|
||||
public:
|
||||
tagid_t tag; ///< Tag ID
|
||||
LCID locale; ///< Locale ID
|
||||
tagid_t tag; ///< Tag ID
|
||||
LCID locale; ///< Locale ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Tag name end in \c data
|
||||
wchar_t data[]; ///< Tag name
|
||||
uint16_t name_to; ///< Tag name end in \c data
|
||||
wchar_t data[]; ///< Tag name
|
||||
|
||||
private:
|
||||
inline tagname(_In_ const tagname &other);
|
||||
@ -257,15 +257,15 @@ namespace ZRCola {
|
||||
{
|
||||
this->tag = tag;
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline uint16_t name_len() const { return name_to; };
|
||||
|
||||
///
|
||||
/// Compares two names
|
||||
@ -285,7 +285,7 @@ namespace ZRCola {
|
||||
/// 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.
|
||||
///
|
||||
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)) {
|
||||
case CSTR_LESS_THAN : return -1;
|
||||
@ -300,7 +300,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Name index
|
||||
///
|
||||
class indexName : public index<unsigned __int16, unsigned __int32, tagname>
|
||||
class indexName : public index<uint16_t, uint32_t, tagname>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -309,7 +309,7 @@ namespace ZRCola {
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
/// \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)
|
||||
@ -362,7 +362,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Tag index
|
||||
///
|
||||
class indexTag : public index<unsigned __int16, unsigned __int32, tagname>
|
||||
class indexTag : public index<uint16_t, uint32_t, tagname>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -371,7 +371,7 @@ namespace ZRCola {
|
||||
/// \param[in] h Reference to vector holding the data
|
||||
/// \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)
|
||||
@ -396,7 +396,7 @@ namespace ZRCola {
|
||||
}
|
||||
} idxTag; ///< Tag index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Tag data
|
||||
std::vector<uint16_t> data; ///< Tag data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -423,7 +423,7 @@ namespace ZRCola {
|
||||
/// \param[in ] fn_abort Pointer to function to periodically test for search cancellation
|
||||
/// \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
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -493,14 +493,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrtag
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
@ -536,12 +536,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -566,14 +566,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::tagnam
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -45,12 +45,12 @@ namespace ZRCola {
|
||||
///
|
||||
/// Translation set ID
|
||||
///
|
||||
typedef unsigned __int16 transetid_t;
|
||||
typedef uint16_t transetid_t;
|
||||
|
||||
///
|
||||
/// Translation sequence ID
|
||||
///
|
||||
typedef unsigned __int16 transeqid_t;
|
||||
typedef uint16_t transeqid_t;
|
||||
|
||||
///
|
||||
/// Translation database
|
||||
@ -64,14 +64,14 @@ namespace ZRCola {
|
||||
///
|
||||
struct translation {
|
||||
public:
|
||||
transetid_t set; ///< Translation set ID
|
||||
unsigned __int16 dst_rank; ///< Destination character rank
|
||||
unsigned __int16 src_rank; ///< Source character rank
|
||||
transetid_t set; ///< Translation set ID
|
||||
uint16_t dst_rank; ///< Destination character rank
|
||||
uint16_t src_rank; ///< Source character rank
|
||||
|
||||
protected:
|
||||
unsigned __int16 dst_to; ///< Destination character end in \c data
|
||||
unsigned __int16 src_to; ///< Source string end in \c data
|
||||
wchar_t data[]; ///< Destination string and source character
|
||||
uint16_t dst_to; ///< Destination character end in \c data
|
||||
uint16_t src_to; ///< Source string end in \c data
|
||||
wchar_t data[]; ///< Destination string and source character
|
||||
|
||||
private:
|
||||
inline translation(_In_ const translation &other);
|
||||
@ -90,39 +90,39 @@ namespace ZRCola {
|
||||
/// \param[in] src_len Number of UTF-16 characters in \p src
|
||||
///
|
||||
inline translation(
|
||||
_In_opt_ transetid_t set = 0,
|
||||
_In_opt_ unsigned __int16 dst_rank = 0,
|
||||
_In_opt_z_count_(dst_len) const wchar_t *dst = NULL,
|
||||
_In_opt_ size_t dst_len = 0,
|
||||
_In_opt_ unsigned __int16 src_rank = 0,
|
||||
_In_opt_z_count_(src_len) const wchar_t *src = NULL,
|
||||
_In_opt_ size_t src_len = 0)
|
||||
_In_opt_ transetid_t set = 0,
|
||||
_In_opt_ uint16_t dst_rank = 0,
|
||||
_In_opt_z_count_(dst_len) const wchar_t *dst = NULL,
|
||||
_In_opt_ size_t dst_len = 0,
|
||||
_In_opt_ uint16_t src_rank = 0,
|
||||
_In_opt_z_count_(src_len) const wchar_t *src = NULL,
|
||||
_In_opt_ size_t src_len = 0)
|
||||
{
|
||||
this->set = set;
|
||||
this->dst_rank = dst_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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* dst () const { return data; };
|
||||
inline wchar_t* dst () { return data; };
|
||||
inline const wchar_t* dst_end() const { return data + dst_to; };
|
||||
inline wchar_t* dst_end() { return data + dst_to; };
|
||||
inline unsigned __int16 dst_len() const { return dst_to; };
|
||||
inline const wchar_t* dst () const { return data; };
|
||||
inline wchar_t* dst () { return data; };
|
||||
inline const wchar_t* dst_end() const { return data + dst_to; };
|
||||
inline wchar_t* dst_end() { return data + dst_to; };
|
||||
inline uint16_t dst_len() const { return dst_to; };
|
||||
|
||||
inline wchar_t dst_at(_In_ size_t i) const
|
||||
{
|
||||
return i < dst_to ? data[i] : 0;
|
||||
}
|
||||
|
||||
inline const wchar_t* src () const { return data + dst_to; };
|
||||
inline wchar_t* src () { return data + dst_to; };
|
||||
inline const wchar_t* src_end() const { 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 const wchar_t* src () const { return data + dst_to; };
|
||||
inline wchar_t* src () { return data + dst_to; };
|
||||
inline const wchar_t* src_end() const { return data + src_to; };
|
||||
inline wchar_t* src_end() { return data + src_to; };
|
||||
inline uint16_t src_len() const { return src_to - dst_to; };
|
||||
|
||||
inline wchar_t src_at(_In_ size_t i) const
|
||||
{
|
||||
@ -135,7 +135,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Translation index
|
||||
///
|
||||
class indexSrc : public index<unsigned __int16, unsigned __int32, translation>
|
||||
class indexSrc : public index<uint16_t, uint32_t, translation>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -143,7 +143,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -200,7 +200,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Inverse translation index
|
||||
///
|
||||
class indexDst : public index<unsigned __int16, unsigned __int32, translation>
|
||||
class indexDst : public index<uint16_t, uint32_t, translation>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -208,7 +208,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -262,7 +262,7 @@ namespace ZRCola {
|
||||
} idxDst; ///< Inverse translation index
|
||||
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Transformation data
|
||||
std::vector<uint16_t> data; ///< Transformation data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -335,12 +335,12 @@ namespace ZRCola {
|
||||
///
|
||||
struct transet {
|
||||
public:
|
||||
transetid_t set; ///< Translation set ID
|
||||
transetid_t set; ///< Translation set ID
|
||||
|
||||
protected:
|
||||
unsigned __int16 src_to; ///< Source name end in \c data
|
||||
unsigned __int16 dst_to; ///< Sestination name end in \c data
|
||||
wchar_t data[]; ///< Source and destination names
|
||||
uint16_t src_to; ///< Source name end in \c data
|
||||
uint16_t dst_to; ///< Sestination name end in \c data
|
||||
wchar_t data[]; ///< Source and destination names
|
||||
|
||||
private:
|
||||
inline transet(_In_ const transet &other);
|
||||
@ -364,30 +364,30 @@ namespace ZRCola {
|
||||
_In_opt_ size_t dst_len = 0)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* src () const { return data; };
|
||||
inline wchar_t* src () { return data; };
|
||||
inline const wchar_t* src_end() const { return data + src_to; };
|
||||
inline wchar_t* src_end() { return data + src_to; };
|
||||
inline unsigned __int16 src_len() const { return src_to; };
|
||||
inline const wchar_t* src () const { return data; };
|
||||
inline wchar_t* src () { return data; };
|
||||
inline const wchar_t* src_end() const { return data + src_to; };
|
||||
inline wchar_t* src_end() { return data + src_to; };
|
||||
inline uint16_t src_len() const { return src_to; };
|
||||
|
||||
inline const wchar_t* dst () const { return data + src_to; };
|
||||
inline wchar_t* dst () { return data + src_to; };
|
||||
inline const wchar_t* dst_end() const { 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 const wchar_t* dst () const { return data + src_to; };
|
||||
inline wchar_t* dst () { return data + src_to; };
|
||||
inline const wchar_t* dst_end() const { return data + dst_to; };
|
||||
inline wchar_t* dst_end() { return data + dst_to; };
|
||||
inline uint16_t dst_len() const { return dst_to - src_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Translation set index
|
||||
///
|
||||
class indexTranSet : public index<unsigned __int16, unsigned __int32, transet>
|
||||
class indexTranSet : public index<uint16_t, uint32_t, transet>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -395,7 +395,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -417,7 +417,7 @@ namespace ZRCola {
|
||||
}
|
||||
} idxTranSet; ///< Translation set index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Translation set data
|
||||
std::vector<uint16_t> data; ///< Translation set data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -451,13 +451,13 @@ namespace ZRCola {
|
||||
///
|
||||
struct transeq {
|
||||
public:
|
||||
transeqid_t seq; ///< Translation sequence ID
|
||||
unsigned __int16 rank; ///< Translation sequence rank
|
||||
transeqid_t seq; ///< Translation sequence ID
|
||||
uint16_t rank; ///< Translation sequence rank
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Translation sequence name end in \c data
|
||||
unsigned __int16 sets_to; ///< Translation sequence sets end in \c data
|
||||
wchar_t data[]; ///< Translation sequence name and sets
|
||||
uint16_t name_to; ///< Translation sequence name end in \c data
|
||||
uint16_t sets_to; ///< Translation sequence sets end in \c data
|
||||
wchar_t data[]; ///< Translation sequence name and sets
|
||||
|
||||
private:
|
||||
inline transeq(_In_ const transeq &other);
|
||||
@ -471,43 +471,43 @@ namespace ZRCola {
|
||||
/// \param[in] rank Translation sequence rank
|
||||
/// \param[in] name Translation sequence source
|
||||
/// \param[in] name_len Number of UTF-16 characters in \p src
|
||||
/// \param[in] sets Translation sequence destination
|
||||
/// \param[in] sets_len Number of UTF-16 characters in \p sets
|
||||
/// \param[in] sets Translation sequence destination
|
||||
/// \param[in] sets_len Number of UTF-16 characters in \p sets
|
||||
///
|
||||
inline transeq(
|
||||
_In_opt_ transeqid_t seq = 0,
|
||||
_In_opt_ unsigned __int16 rank = 0,
|
||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0,
|
||||
_In_opt_count_ (sets_len) const transetid_t *sets = NULL,
|
||||
_In_opt_ size_t sets_len = 0)
|
||||
_In_opt_ transeqid_t seq = 0,
|
||||
_In_opt_ uint16_t rank = 0,
|
||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0,
|
||||
_In_opt_count_ (sets_len) const transetid_t *sets = NULL,
|
||||
_In_opt_ size_t sets_len = 0)
|
||||
{
|
||||
this->seq = seq;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline uint16_t name_len() const { return 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 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 unsigned __int16 sets_len() const { return sets_to - 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 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 uint16_t sets_len() const { return sets_to - name_to; };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Translation sequence index
|
||||
///
|
||||
class indexTranSeq : public index<unsigned __int16, unsigned __int32, transeq>
|
||||
class indexTranSeq : public index<uint16_t, uint32_t, transeq>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -515,7 +515,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -540,7 +540,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Rank index
|
||||
///
|
||||
class indexRank : public index<unsigned __int16, unsigned __int32, transeq>
|
||||
class indexRank : public index<uint16_t, uint32_t, transeq>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -548,7 +548,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -585,10 +585,10 @@ namespace ZRCola {
|
||||
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(),
|
||||
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 (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
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Translation sequence data
|
||||
std::vector<uint16_t> data; ///< Translation sequence data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -654,12 +654,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -684,14 +684,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transl
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
@ -723,12 +723,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -749,14 +749,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
@ -792,12 +792,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -822,14 +822,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::transe
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
Copyright © 2015-2022 Amebis
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef __PCH_H__
|
||||
#define __PCH_H__
|
||||
|
||||
#include "../../../include/version.h"
|
||||
|
||||
@ -17,3 +18,5 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cwctype>
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
#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) {
|
||||
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++) {
|
||||
if (fn_abort && fn_abort(cookie)) return false;
|
||||
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()) {
|
||||
std::wstring chr(ct.chr(), len);
|
||||
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);
|
||||
|
||||
@ -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);
|
||||
if (idx == hits.end()) {
|
||||
// New tag.
|
||||
hits.insert(std::make_pair(val.tag, (unsigned __int16)1));
|
||||
hits.insert(std::make_pair(val.tag, (uint16_t)1));
|
||||
} else {
|
||||
// Increase count for existing tag.
|
||||
idx->second++;
|
||||
|
@ -24,7 +24,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Character group ID
|
||||
///
|
||||
typedef unsigned __int16 chrgrpid_t;
|
||||
typedef uint16_t chrgrpid_t;
|
||||
|
||||
|
||||
///
|
||||
@ -39,13 +39,13 @@ namespace ZRCola {
|
||||
///
|
||||
struct chrgrp {
|
||||
public:
|
||||
chrgrpid_t grp; ///< Character group ID
|
||||
unsigned __int16 rank; ///< Character group rank
|
||||
chrgrpid_t grp; ///< Character group ID
|
||||
uint16_t rank; ///< Character group rank
|
||||
|
||||
protected:
|
||||
unsigned __int16 name_to; ///< Character group name end in \c data
|
||||
unsigned __int16 chrlst_to; ///< Character list end in \c data
|
||||
wchar_t data[]; ///< Character group name, character list, bit vector if particular character is displayed initially
|
||||
uint16_t name_to; ///< Character group name 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
|
||||
|
||||
public:
|
||||
///
|
||||
@ -60,49 +60,49 @@ namespace ZRCola {
|
||||
/// \param[in] chrshow Binary vector which particular character is displayed initially
|
||||
///
|
||||
inline chrgrp(
|
||||
_In_opt_ chrgrpid_t grp = 0,
|
||||
_In_opt_ unsigned __int16 rank = 0,
|
||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0,
|
||||
_In_opt_z_count_(chrlst_len) const wchar_t *chrlst = NULL,
|
||||
_In_opt_ size_t chrlst_len = 0,
|
||||
_In_opt_count_x_((chrlst_len + 15)/16) const unsigned __int16 *chrshow = NULL)
|
||||
_In_opt_ chrgrpid_t grp = 0,
|
||||
_In_opt_ uint16_t rank = 0,
|
||||
_In_opt_z_count_(name_len) const wchar_t *name = NULL,
|
||||
_In_opt_ size_t name_len = 0,
|
||||
_In_opt_z_count_(chrlst_len) const wchar_t *chrlst = NULL,
|
||||
_In_opt_ size_t chrlst_len = 0,
|
||||
_In_opt_count_x_((chrlst_len + 15)/16) const uint16_t *chrshow = NULL)
|
||||
{
|
||||
this->grp = grp;
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline unsigned __int16 name_len() const { return name_to; };
|
||||
inline const wchar_t* name () const { return data; };
|
||||
inline wchar_t* name () { return data; };
|
||||
inline const wchar_t* name_end() const { return data + name_to; };
|
||||
inline wchar_t* name_end() { return data + name_to; };
|
||||
inline uint16_t name_len() const { return name_to; };
|
||||
|
||||
inline const wchar_t* chrlst () const { return data + name_to; };
|
||||
inline wchar_t* chrlst () { return data + name_to; };
|
||||
inline const wchar_t* chrlst_end() const { 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 const wchar_t* chrlst () const { return data + name_to; };
|
||||
inline wchar_t* chrlst () { return data + name_to; };
|
||||
inline const wchar_t* chrlst_end() const { return data + chrlst_to; };
|
||||
inline wchar_t* chrlst_end() { return data + chrlst_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 unsigned __int16* chrshow () { return reinterpret_cast< unsigned __int16*>(data + chrlst_to ); };
|
||||
inline const unsigned __int16* chrshow_end() const { return reinterpret_cast<const unsigned __int16*>(data + chrlst_to + chrshow_len()); };
|
||||
inline unsigned __int16* chrshow_end() { return reinterpret_cast< unsigned __int16*>(data + chrlst_to + chrshow_len()); };
|
||||
inline unsigned __int16 chrshow_len() const { return (chrlst_len() + sizeof(*data)*8 - 1)/(sizeof(*data)*8); };
|
||||
inline const uint16_t* chrshow () const { return reinterpret_cast<const uint16_t*>(data + chrlst_to ); };
|
||||
inline uint16_t* chrshow () { return reinterpret_cast< uint16_t*>(data + chrlst_to ); };
|
||||
inline const uint16_t* chrshow_end() const { return reinterpret_cast<const uint16_t*>(data + chrlst_to + chrshow_len()); };
|
||||
inline uint16_t* chrshow_end() { return reinterpret_cast< uint16_t*>(data + chrlst_to + chrshow_len()); };
|
||||
inline uint16_t chrshow_len() const { return (chrlst_len() + sizeof(*data)*8 - 1)/(sizeof(*data)*8); };
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
///
|
||||
/// Rank index
|
||||
///
|
||||
class indexRank : public index<unsigned __int16, unsigned __int32, chrgrp>
|
||||
class indexRank : public index<uint16_t, uint32_t, chrgrp>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -110,7 +110,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -147,10 +147,10 @@ namespace ZRCola {
|
||||
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(),
|
||||
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 (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
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Character groups data
|
||||
std::vector<uint16_t> data; ///< Character groups data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -200,12 +200,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::c
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -226,14 +226,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
@ -39,20 +39,20 @@ namespace ZRCola {
|
||||
struct keyseq {
|
||||
public:
|
||||
enum modifiers_t {
|
||||
SHIFT = 1<<0, ///< SHIFT key was pressed
|
||||
CTRL = 1<<1, ///< CTRL key was pressed
|
||||
ALT = 1<<2, ///< ALT key was pressed
|
||||
SHIFT = 1<<0, ///< SHIFT key was pressed
|
||||
CTRL = 1<<1, ///< CTRL key was pressed
|
||||
ALT = 1<<2, ///< ALT key was pressed
|
||||
};
|
||||
|
||||
struct key_t {
|
||||
wchar_t key; ///< Key
|
||||
unsigned __int16 modifiers; ///< Modifiers (bitwise combination of SHIFT, CTRL and ALT)
|
||||
wchar_t key; ///< Key
|
||||
uint16_t modifiers; ///< Modifiers (bitwise combination of SHIFT, CTRL and ALT)
|
||||
};
|
||||
|
||||
protected:
|
||||
unsigned __int16 chr_to; ///< Character end in \c data
|
||||
unsigned __int16 seq_to; ///< Key sequence end in \c data
|
||||
wchar_t data[]; ///< Character and key sequence
|
||||
uint16_t chr_to; ///< Character end in \c data
|
||||
uint16_t seq_to; ///< Key sequence end in \c data
|
||||
wchar_t data[]; ///< Character and key sequence
|
||||
|
||||
public:
|
||||
///
|
||||
@ -69,23 +69,23 @@ namespace ZRCola {
|
||||
_In_opt_z_count_(chr_len) const wchar_t *chr = NULL,
|
||||
_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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + chr_to; };
|
||||
inline unsigned __int16 chr_len() const { return chr_to; };
|
||||
inline const wchar_t* chr () const { return data; };
|
||||
inline wchar_t* chr () { return data; };
|
||||
inline const wchar_t* chr_end() const { return data + chr_to; };
|
||||
inline wchar_t* chr_end() { return data + 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 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 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 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 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 uint16_t seq_len() const { return (seq_to - chr_to) * sizeof(*data) / sizeof(key_t); };
|
||||
|
||||
///
|
||||
/// Compares two key sequences
|
||||
@ -118,7 +118,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Character index
|
||||
///
|
||||
class indexChr : public index<unsigned __int16, unsigned __int32, keyseq>
|
||||
class indexChr : public index<uint16_t, uint32_t, keyseq>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -126,7 +126,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -174,7 +174,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// Key index
|
||||
///
|
||||
class indexKey : public index<unsigned __int16, unsigned __int32, keyseq>
|
||||
class indexKey : public index<uint16_t, uint32_t, keyseq>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@ -182,7 +182,7 @@ namespace ZRCola {
|
||||
///
|
||||
/// \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)
|
||||
@ -226,7 +226,7 @@ namespace ZRCola {
|
||||
}
|
||||
} idxKey; ///< Key index
|
||||
|
||||
std::vector<unsigned __int16> data; ///< Key sequences data
|
||||
std::vector<uint16_t> data; ///< Key sequences data
|
||||
|
||||
public:
|
||||
///
|
||||
@ -308,12 +308,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::k
|
||||
}
|
||||
#endif
|
||||
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));
|
||||
|
||||
// Write data.
|
||||
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;
|
||||
}
|
||||
@ -338,14 +338,14 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::keyseq
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
// Read data count.
|
||||
unsigned __int32 count;
|
||||
uint32_t count;
|
||||
stream.read((char*)&count, sizeof(count));
|
||||
if (!stream.good()) return stream;
|
||||
|
||||
if (count) {
|
||||
// Read data.
|
||||
db.data.resize(count);
|
||||
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*static_cast<std::streamsize>(count));
|
||||
stream.read((char*)db.data.data(), sizeof(uint16_t)*static_cast<std::streamsize>(count));
|
||||
} else
|
||||
db.data.clear();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user