Switch integer datatypes to C99
This makes code more portable. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user