Match integer datatypes with Access DB

Integer in Access is short in C/C++.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2021-12-20 19:49:29 +01:00
parent 454b02181e
commit ad79961c33
3 changed files with 44 additions and 58 deletions

View File

@ -305,7 +305,7 @@ bool ZRCola::DBSource::Open(LPCTSTR filename)
com_obj<ADOParameters> params; com_obj<ADOParameters> params;
wxVERIFY(SUCCEEDED(m_comTranslation->get_Parameters(&params))); wxVERIFY(SUCCEEDED(m_comTranslation->get_Parameters(&params)));
wxASSERT_MSG(!m_pTranslation1, wxT("ADO command parameter already created")); wxASSERT_MSG(!m_pTranslation1, wxT("ADO command parameter already created"));
wxVERIFY(SUCCEEDED(m_comTranslation->CreateParameter(bstr(L"@Script"), adInteger, adParamInput, 0, variant(DISP_E_PARAMNOTFOUND, VT_ERROR), &m_pTranslation1))); wxVERIFY(SUCCEEDED(m_comTranslation->CreateParameter(bstr(L"@Script"), adSmallInt, adParamInput, 0, variant(DISP_E_PARAMNOTFOUND, VT_ERROR), &m_pTranslation1)));
wxVERIFY(SUCCEEDED(params->Append(m_pTranslation1))); wxVERIFY(SUCCEEDED(params->Append(m_pTranslation1)));
} }
@ -322,7 +322,7 @@ bool ZRCola::DBSource::Open(LPCTSTR filename)
com_obj<ADOParameters> params; com_obj<ADOParameters> params;
wxVERIFY(SUCCEEDED(m_comTranslationSets->get_Parameters(&params))); wxVERIFY(SUCCEEDED(m_comTranslationSets->get_Parameters(&params)));
wxASSERT_MSG(!m_pTranslationSets1, wxT("ADO command parameter already created")); wxASSERT_MSG(!m_pTranslationSets1, wxT("ADO command parameter already created"));
wxVERIFY(SUCCEEDED(m_comTranslationSets->CreateParameter(bstr(L"@ID"), adInteger, adParamInput, 0, variant(DISP_E_PARAMNOTFOUND, VT_ERROR), &m_pTranslationSets1))); wxVERIFY(SUCCEEDED(m_comTranslationSets->CreateParameter(bstr(L"@ID"), adSmallInt, adParamInput, 0, variant(DISP_E_PARAMNOTFOUND, VT_ERROR), &m_pTranslationSets1)));
wxVERIFY(SUCCEEDED(params->Append(m_pTranslationSets1))); wxVERIFY(SUCCEEDED(params->Append(m_pTranslationSets1)));
} }
@ -386,15 +386,15 @@ bool ZRCola::DBSource::GetValue(const com_obj<ADOField>& f, bool& val) const
} }
bool ZRCola::DBSource::GetValue(const com_obj<ADOField>& f, int& val) const bool ZRCola::DBSource::GetValue(const com_obj<ADOField>& f, short& val) const
{ {
wxASSERT_MSG(f, wxT("field is empty")); wxASSERT_MSG(f, wxT("field is empty"));
variant v; variant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v))); wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxCHECK(SUCCEEDED(v.change_type(VT_I4)), false); wxCHECK(SUCCEEDED(v.change_type(VT_I2)), false);
val = V_I4(&v); val = V_I2(&v);
return true; return true;
} }
@ -737,7 +737,7 @@ bool ZRCola::DBSource::SelectTranslations(com_obj<ADORecordset> &rs) const
} }
bool ZRCola::DBSource::SelectTranslations(int set, winstd::com_obj<ADORecordset>& rs) const bool ZRCola::DBSource::SelectTranslations(short set, winstd::com_obj<ADORecordset>& rs) const
{ {
// Create a new recordset. // Create a new recordset.
rs.free(); rs.free();
@ -923,7 +923,7 @@ bool ZRCola::DBSource::GetTranslationSeq(const com_obj<ADORecordset>& rs, ZRCola
wxVERIFY(SUCCEEDED(flds2->get_Item(variant(L"Script"), &f_set))); wxVERIFY(SUCCEEDED(flds2->get_Item(variant(L"Script"), &f_set)));
size_t n = 0; size_t n = 0;
for (VARIANT_BOOL eof = VARIANT_TRUE; SUCCEEDED(rs_chars->get_EOF(&eof)) && !eof; rs_chars->MoveNext(), n++) { for (VARIANT_BOOL eof = VARIANT_TRUE; SUCCEEDED(rs_chars->get_EOF(&eof)) && !eof; rs_chars->MoveNext(), n++) {
int set; short set;
wxCHECK(GetValue(f_set, set), false); wxCHECK(GetValue(f_set, set), false);
ts.sets.push_back(set); ts.sets.push_back(set);
} }
@ -967,21 +967,21 @@ bool ZRCola::DBSource::GetKeySequence(const com_obj<ADORecordset>& rs, ZRCola::D
wxCHECK(GetUnicodeString(f, ks.chr), false); wxCHECK(GetUnicodeString(f, ks.chr), false);
} }
int modifiers; short modifiers;
{ {
com_obj<ADOField> f; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Modifiers"), &f))); wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"Modifiers"), &f)));
wxCHECK(GetValue(f, modifiers), false); wxCHECK(GetValue(f, modifiers), false);
} }
int keycode1; short keycode1;
{ {
com_obj<ADOField> f; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"KeyCodePre"), &f))); wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"KeyCodePre"), &f)));
wxCHECK(GetValue(f, keycode1), false); wxCHECK(GetValue(f, keycode1), false);
} }
int keycode; short keycode;
{ {
com_obj<ADOField> f; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"KeyCode"), &f))); wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"KeyCode"), &f)));
@ -999,18 +999,18 @@ bool ZRCola::DBSource::GetKeySequence(const com_obj<ADORecordset>& rs, ZRCola::D
if (keycode1) { if (keycode1) {
// First key in the sequence is complete. // First key in the sequence is complete.
keyseq::keycode kc1 = { keyseq::keycode kc1 = {
keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode1 & 0xffff)), keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode1)),
(modifiers & 0x100) != 0, (modifiers & 0x100) != 0,
(modifiers & 0x200) != 0, (modifiers & 0x200) != 0,
(modifiers & 0x400) != 0 }; (modifiers & 0x400) != 0 };
ks.seq.push_back(kc1); ks.seq.push_back(kc1);
keyseq::keycode kc2 = { keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode & 0xffff)), shift }; keyseq::keycode kc2 = { keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode)), shift };
ks.seq.push_back(kc2); ks.seq.push_back(kc2);
} else { } else {
// First key in the sequence is only modifier(s). // First key in the sequence is only modifier(s).
keyseq::keycode kc1 = { keyseq::keycode kc1 = {
keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode & 0xffff)), keyseq::keycode::translate_slen(static_cast<wchar_t>(keycode)),
shift || (modifiers & 0x100) != 0, shift || (modifiers & 0x100) != 0,
(modifiers & 0x200) != 0, (modifiers & 0x200) != 0,
(modifiers & 0x400) != 0 }; (modifiers & 0x400) != 0 };

View File

@ -47,7 +47,7 @@ namespace ZRCola {
/// ///
class charseq { class charseq {
public: public:
int rank; ///< Sequence rank short rank; ///< Sequence rank
std::wstring str; ///< Sequence string std::wstring str; ///< Sequence string
inline charseq() : inline charseq() :
@ -55,19 +55,19 @@ namespace ZRCola {
{ {
} }
inline charseq(_In_ int _rank, _In_z_ const wchar_t *_str) : inline charseq(_In_ short _rank, _In_z_ const wchar_t *_str) :
rank(_rank), rank(_rank),
str (_str) str (_str)
{ {
} }
inline charseq(_In_ int _rank, _In_ const std::wstring &_str) : inline charseq(_In_ short _rank, _In_ const std::wstring &_str) :
rank(_rank), rank(_rank),
str (_str) str (_str)
{ {
} }
inline charseq(_In_ int _rank, _Inout_ std::wstring &&_str) : inline charseq(_In_ short _rank, _Inout_ std::wstring &&_str) :
rank(_rank), rank(_rank),
str (std::move(_str)) str (std::move(_str))
{ {
@ -113,12 +113,12 @@ namespace ZRCola {
/// ///
class translation { class translation {
public: public:
int set; ///< Translation set ID short set; ///< Translation set ID
charseq src; ///< Source sequence charseq src; ///< Source sequence
std::string norm; ///< Normalization footprint std::string norm; ///< Normalization footprint
charseq dst; ///< Destination sequence charseq dst; ///< Destination sequence
inline translation() : set((int)ZRCOLA_TRANSETID_DEFAULT) {} inline translation() : set((short)ZRCOLA_TRANSETID_DEFAULT) {}
}; };
@ -127,11 +127,11 @@ namespace ZRCola {
/// ///
class transet { class transet {
public: public:
int set; ///< ID short set; ///< ID
std::wstring src; ///< Source name std::wstring src; ///< Source name
std::wstring dst; ///< Destination name std::wstring dst; ///< Destination name
inline transet() : set((int)ZRCOLA_TRANSETID_DEFAULT) {} inline transet() : set((short)ZRCOLA_TRANSETID_DEFAULT) {}
}; };
@ -140,10 +140,10 @@ namespace ZRCola {
/// ///
class transeq { class transeq {
public: public:
int seq; ///< ID short seq; ///< ID
int rank; ///< Rank short rank; ///< Rank
std::wstring name; ///< Name std::wstring name; ///< Name
std::vector<int> sets; ///< Sets std::vector<short> sets; ///< Sets
inline transeq() : inline transeq() :
seq(0), seq(0),
@ -222,8 +222,8 @@ namespace ZRCola {
/// ///
class chrgrp { class chrgrp {
public: public:
int grp; ///< Character group ID short grp; ///< Character group ID
int rank; ///< Rank short rank; ///< Rank
std::wstring name; ///< Name std::wstring name; ///< Name
std::vector<wchar_t> chars; ///< Characters (zero-delimited) std::vector<wchar_t> chars; ///< Characters (zero-delimited)
std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially std::vector<unsigned __int16> show; ///< Bit vector if particular character from \c chars is displayed initially
@ -373,7 +373,7 @@ namespace ZRCola {
class chrcat { class chrcat {
public: public:
ZRCola::chrcatid_t cat; ///> Category ID ZRCola::chrcatid_t cat; ///> Category ID
int rank; ///< Rank short rank; ///< Rank
std::wstring name; ///< Name std::wstring name; ///< Name
inline chrcat() : cat(ZRCola::chrcatid_t::blank), rank(0) {} inline chrcat() : cat(ZRCola::chrcatid_t::blank), rank(0) {}
@ -386,7 +386,7 @@ namespace ZRCola {
class chrtag { class chrtag {
public: public:
std::wstring chr; ///> Character std::wstring chr; ///> Character
int tag; ///< Tag ID short tag; ///< Tag ID
inline chrtag() : tag(0) {} inline chrtag() : tag(0) {}
}; };
@ -397,7 +397,7 @@ namespace ZRCola {
/// ///
class tagname { class tagname {
public: public:
int tag; ///< Tag ID short tag; ///< Tag ID
std::map<LCID, std::list<std::wstring> > names; ///< Names std::map<LCID, std::list<std::wstring> > names; ///< Names
inline tagname() : tag(0) {} inline tagname() : tag(0) {}
@ -486,7 +486,7 @@ namespace ZRCola {
/// - true when successful /// - true when successful
/// - false otherwise /// - false otherwise
/// ///
bool GetValue(const winstd::com_obj<ADOField>& f, int& val) const; bool GetValue(const winstd::com_obj<ADOField>& f, short& val) const;
/// ///
/// Gets string from ZRCola.zrc database /// Gets string from ZRCola.zrc database
@ -628,7 +628,7 @@ namespace ZRCola {
/// - true when query succeeds /// - true when query succeeds
/// - false otherwise /// - false otherwise
/// ///
bool SelectTranslations(int set, winstd::com_obj<ADORecordset>& rs) const; bool SelectTranslations(short set, winstd::com_obj<ADORecordset>& rs) const;
/// ///
/// Returns translation data /// Returns translation data
@ -894,11 +894,8 @@ namespace ZRCola {
inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _In_ const ZRCola::DBSource::translation &rec) inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _In_ const ZRCola::DBSource::translation &rec)
{ {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff0000 <= rec.set && rec.set <= (int)0x0000ffff, wxT("translation set id out of bounds"));
db.data.push_back((unsigned __int16)rec.set); db.data.push_back((unsigned __int16)rec.set);
wxASSERT_MSG((int)0xffff8000 <= rec.dst.rank && rec.dst.rank <= (int)0x00007fff, wxT("destination character rank out of bounds"));
db.data.push_back((unsigned __int16)rec.dst.rank); db.data.push_back((unsigned __int16)rec.dst.rank);
wxASSERT_MSG((int)0xffff8000 <= rec.src.rank && rec.src.rank <= (int)0x00007fff, wxT("source character rank out of bounds"));
db.data.push_back((unsigned __int16)rec.src.rank); db.data.push_back((unsigned __int16)rec.src.rank);
std::wstring::size_type n = rec.dst.str.length(); std::wstring::size_type n = rec.dst.str.length();
wxASSERT_MSG(n <= 0xffff, wxT("destination overflow")); wxASSERT_MSG(n <= 0xffff, wxT("destination overflow"));
@ -918,7 +915,6 @@ inline ZRCola::translation_db& operator<<(_Inout_ ZRCola::translation_db &db, _I
inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const ZRCola::DBSource::transet &rec) inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const ZRCola::DBSource::transet &rec)
{ {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff0000 <= rec.set && rec.set <= (int)0x0000ffff, wxT("translation set id out of bounds"));
db.data.push_back((unsigned __int16)rec.set); db.data.push_back((unsigned __int16)rec.set);
std::wstring::size_type n = rec.src.length(); std::wstring::size_type n = rec.src.length();
wxASSERT_MSG(n <= 0xffff, wxT("translation set source name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation set source name overflow"));
@ -937,9 +933,7 @@ inline ZRCola::transet_db& operator<<(_Inout_ ZRCola::transet_db &db, _In_ const
inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const ZRCola::DBSource::transeq &rec) inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const ZRCola::DBSource::transeq &rec)
{ {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= rec.seq && rec.seq <= (int)0x00007fff, wxT("translation sequence id out of bounds"));
db.data.push_back((unsigned __int16)rec.seq); db.data.push_back((unsigned __int16)rec.seq);
wxASSERT_MSG((int)0xffff8000 <= rec.rank && rec.rank <= (int)0x00007fff, wxT("translation rank id out of bounds"));
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((unsigned __int16)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation sequence name overflow"));
@ -948,11 +942,8 @@ inline ZRCola::transeq_db& operator<<(_Inout_ ZRCola::transeq_db &db, _In_ const
wxASSERT_MSG(n <= 0xffff, wxT("translation sequence sets overflow")); wxASSERT_MSG(n <= 0xffff, wxT("translation sequence sets overflow"));
db.data.push_back((unsigned __int16)n); db.data.push_back((unsigned __int16)n);
db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend()); db.data.insert(db.data.end(), rec.name.cbegin(), rec.name.cend());
for (auto s = rec.sets.cbegin(), s_end = rec.sets.cend(); s != s_end; ++s) { for (auto s = rec.sets.cbegin(), s_end = rec.sets.cend(); s != s_end; ++s)
int val = *s; db.data.push_back((unsigned __int16)*s);
wxASSERT_MSG(val <= 0xffff, wxT("translation sequence ID overflow"));
db.data.push_back((unsigned __int16)val);
}
db.idxTranSeq.push_back(idx); db.idxTranSeq.push_back(idx);
db.idxRank .push_back(idx); db.idxRank .push_back(idx);
@ -1018,9 +1009,7 @@ inline ZRCola::langchar_db& operator<<(_Inout_ ZRCola::langchar_db &db, _In_ con
inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const ZRCola::DBSource::chrgrp &rec) inline ZRCola::chrgrp_db& operator<<(_Inout_ ZRCola::chrgrp_db &db, _In_ const ZRCola::DBSource::chrgrp &rec)
{ {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= rec.grp && rec.grp <= (int)0x00007fff, wxT("character group ID out of bounds"));
db.data.push_back((unsigned __int16)rec.grp); db.data.push_back((unsigned __int16)rec.grp);
wxASSERT_MSG((int)0xffff8000 <= rec.rank && rec.rank <= (int)0x00007fff, wxT("character group rank out of bounds"));
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((unsigned __int16)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("character group name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character group name overflow"));
@ -1063,7 +1052,6 @@ inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const Z
{ {
unsigned __int32 idx = db.data.size(); 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.insert(db.data.end(), reinterpret_cast<const unsigned __int16*>(&rec.cat), reinterpret_cast<const unsigned __int16*>(&rec.cat + 1));
wxASSERT_MSG((int)0xffff8000 <= rec.rank && rec.rank <= (int)0x00007fff, wxT("character category rank out of bounds"));
db.data.push_back((unsigned __int16)rec.rank); db.data.push_back((unsigned __int16)rec.rank);
std::wstring::size_type n = rec.name.length(); std::wstring::size_type n = rec.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("character category name overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character category name overflow"));
@ -1079,7 +1067,6 @@ inline ZRCola::chrcat_db& operator<<(_Inout_ ZRCola::chrcat_db &db, _In_ const Z
inline ZRCola::chrtag_db& operator<<(_Inout_ ZRCola::chrtag_db &db, _In_ const ZRCola::DBSource::chrtag &rec) inline ZRCola::chrtag_db& operator<<(_Inout_ ZRCola::chrtag_db &db, _In_ const ZRCola::DBSource::chrtag &rec)
{ {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= rec.tag && rec.tag <= (int)0x00007fff, wxT("tag out of bounds"));
db.data.push_back((unsigned __int16)rec.tag); db.data.push_back((unsigned __int16)rec.tag);
std::wstring::size_type n = rec.chr.length(); std::wstring::size_type n = rec.chr.length();
wxASSERT_MSG(n <= 0xffff, wxT("character overflow")); wxASSERT_MSG(n <= 0xffff, wxT("character overflow"));
@ -1097,7 +1084,6 @@ inline ZRCola::tagname_db& operator<<(_Inout_ ZRCola::tagname_db &db, _In_ const
for (auto ln = rec.names.cbegin(), ln_end = rec.names.cend(); ln != ln_end; ++ln) { for (auto ln = rec.names.cbegin(), ln_end = rec.names.cend(); ln != ln_end; ++ln) {
for (auto nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) { for (auto nm = ln->second.cbegin(), nm_end = ln->second.cend(); nm != nm_end; ++nm) {
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= rec.tag && rec.tag <= (int)0x00007fff, wxT("tag out of bounds"));
db.data.push_back((unsigned __int16)rec.tag); db.data.push_back((unsigned __int16)rec.tag);
db.data.push_back(LOWORD(ln->first)); db.data.push_back(LOWORD(ln->first));
db.data.push_back(HIWORD(ln->first)); db.data.push_back(HIWORD(ln->first));

View File

@ -16,8 +16,8 @@ using namespace winstd;
class com_translation class com_translation
{ {
public: public:
int rank_src; ///< Source sequence rank short rank_src; ///< Source sequence rank
int rank_dst; ///< Destination character rank short rank_dst; ///< Destination character rank
string norm; ///< Normalization footprint string norm; ///< Normalization footprint
inline com_translation() : inline com_translation() :
@ -26,20 +26,20 @@ public:
{ {
} }
inline com_translation(int _rank_src, int _rank_dst) : inline com_translation(short _rank_src, short _rank_dst) :
rank_src(_rank_src), rank_src(_rank_src),
rank_dst(_rank_dst) rank_dst(_rank_dst)
{ {
} }
inline com_translation(int _rank_src, int _rank_dst, const char *_norm) : inline com_translation(short _rank_src, short _rank_dst, const char *_norm) :
rank_src(_rank_src), rank_src(_rank_src),
rank_dst(_rank_dst), rank_dst(_rank_dst),
norm (_norm ) norm (_norm )
{ {
} }
inline com_translation(int _rank_src, int _rank_dst, string &&_norm) : inline com_translation(short _rank_src, short _rank_dst, string &&_norm) :
rank_src( _rank_src ), rank_src( _rank_src ),
rank_dst( _rank_dst ), rank_dst( _rank_dst ),
norm (std::move(_norm )) norm (std::move(_norm ))
@ -365,8 +365,8 @@ int _tmain(int argc, _TCHAR *argv[])
translation_db::mapped_type::mapped_type ct(d1->second.rank_src + r->rank, d1->second.rank_dst); translation_db::mapped_type::mapped_type ct(d1->second.rank_src + r->rank, d1->second.rank_dst);
auto hit = t2->second.find(r->str); auto hit = t2->second.find(r->str);
if (hit != t2->second.end()) { if (hit != t2->second.end()) {
hit->second.rank_src = std::min<int>(hit->second.rank_src, ct.rank_src); hit->second.rank_src = std::min<short>(hit->second.rank_src, ct.rank_src);
hit->second.rank_dst = std::max<int>(hit->second.rank_dst, ct.rank_dst); hit->second.rank_dst = std::max<short>(hit->second.rank_dst, ct.rank_dst);
} else } else
t2->second.insert(pair<translation_db::mapped_type::key_type, translation_db::mapped_type::mapped_type>(r->str, std::move(ct))); t2->second.insert(pair<translation_db::mapped_type::key_type, translation_db::mapped_type::mapped_type>(r->str, std::move(ct)));
} }
@ -384,7 +384,7 @@ int _tmain(int argc, _TCHAR *argv[])
// Add translation to index and data. // Add translation to index and data.
trans.dst.str = t->first; trans.dst.str = t->first;
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) { for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) {
trans.set = (int)ZRCOLA_TRANSETID_DEFAULT; trans.set = (short)ZRCOLA_TRANSETID_DEFAULT;
trans.dst.rank = d->second.rank_dst; trans.dst.rank = d->second.rank_dst;
trans.src.rank = d->second.rank_src; trans.src.rank = d->second.rank_src;
trans.src.str = d->first; trans.src.str = d->first;
@ -398,7 +398,7 @@ int _tmain(int argc, _TCHAR *argv[])
break; break;
} }
if (!has_pua) { if (!has_pua) {
trans.set = (int)ZRCOLA_TRANSETID_UNICODE; trans.set = (short)ZRCOLA_TRANSETID_UNICODE;
db_trans << trans; db_trans << trans;
} }
} }
@ -428,7 +428,7 @@ int _tmain(int argc, _TCHAR *argv[])
// Read translation set from the database. // Read translation set from the database.
ZRCola::DBSource::transet ts; ZRCola::DBSource::transet ts;
if (src.GetTranslationSet(rs, ts)) { if (src.GetTranslationSet(rs, ts)) {
if (ts.set <= (int)ZRCOLA_TRANSETID_DEFAULT) if (ts.set <= (short)ZRCOLA_TRANSETID_DEFAULT)
continue; continue;
if (build_pot) { if (build_pot) {