aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authoriseg <iseg@yandex-team.ru>2022-02-10 16:49:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:39 +0300
commit8b71ce88bea710a9663bb143e4916f961c57212e (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp
parentf828a15ab90e9ca8e848f83caf95c95f06be46e7 (diff)
downloadydb-8b71ce88bea710a9663bb143e4916f961c57212e.tar.gz
Restoring authorship annotation for <iseg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/charset/codepage.cpp38
-rw-r--r--library/cpp/charset/codepage.h58
-rw-r--r--library/cpp/charset/recyr.hh2
-rw-r--r--library/cpp/containers/atomizer/atomizer.h52
-rw-r--r--library/cpp/containers/str_map/str_map.h58
-rw-r--r--library/cpp/deprecated/mapped_file/mapped_file.cpp2
-rw-r--r--library/cpp/deprecated/mapped_file/mapped_file.h2
-rw-r--r--library/cpp/getopt/small/opt.cpp24
-rw-r--r--library/cpp/http/misc/httpdate.cpp10
-rw-r--r--library/cpp/http/misc/httpdate.h4
-rw-r--r--library/cpp/packedtypes/longs.h104
11 files changed, 177 insertions, 177 deletions
diff --git a/library/cpp/charset/codepage.cpp b/library/cpp/charset/codepage.cpp
index 8e2df10531..0431bef31b 100644
--- a/library/cpp/charset/codepage.cpp
+++ b/library/cpp/charset/codepage.cpp
@@ -64,26 +64,26 @@ char* CodePage::ToUpper(const char* b, char* to) const {
}
int CodePage::stricmp(const char* dst, const char* src) const {
- unsigned char f, l;
- do {
+ unsigned char f, l;
+ do {
f = ToLower(*dst++);
l = ToLower(*src++);
- } while (f && (f == l));
- return f - l;
-}
-
+ } while (f && (f == l));
+ return f - l;
+}
+
int CodePage::strnicmp(const char* dst, const char* src, size_t len) const {
- unsigned char f, l;
- if (len) {
- do {
+ unsigned char f, l;
+ if (len) {
+ do {
f = ToLower(*dst++);
l = ToLower(*src++);
- } while (--len && f && (f == l));
- return f - l;
- }
- return 0;
-}
-
+ } while (--len && f && (f == l));
+ return f - l;
+ }
+ return 0;
+}
+
static const CodePage UNSUPPORTED_CODEPAGE = {
CODES_UNSUPPORTED,
{
@@ -179,7 +179,7 @@ public:
}
}
}
-
+
inline ECharset CharsetByName(TStringBuf name) {
if (!name)
return CODES_UNKNOWN;
@@ -187,15 +187,15 @@ public:
TData::const_iterator it = Data.find(name);
if (it == Data.end())
return CODES_UNKNOWN;
-
+
return it->second;
}
};
ECharset CharsetByName(TStringBuf name) {
return Singleton<TCodePageHash>()->CharsetByName(name);
-}
-
+}
+
ECharset CharsetByNameOrDie(TStringBuf name) {
ECharset result = CharsetByName(name);
if (result == CODES_UNKNOWN)
diff --git a/library/cpp/charset/codepage.h b/library/cpp/charset/codepage.h
index 22d555b158..30a02a4610 100644
--- a/library/cpp/charset/codepage.h
+++ b/library/cpp/charset/codepage.h
@@ -13,19 +13,19 @@
#include <cctype>
-struct CodePage;
-struct Recoder;
-struct Encoder;
-
+struct CodePage;
+struct Recoder;
+struct Encoder;
+
/*****************************************************************\
* struct CodePage *
\*****************************************************************/
-struct CodePage {
+struct CodePage {
ECharset CPEnum; // int MIBEnum;
const char* Names[30]; // name[0] -- preferred mime-name
wchar32 unicode[256];
const char* DefaultChar; //[CCL_NUM]
-
+
bool IsLower(unsigned char ch) const {
return ::IsLower(unicode[ch]);
}
@@ -77,12 +77,12 @@ struct CodePage {
inline unsigned char ToUpper(unsigned char ch) const;
inline unsigned char ToLower(unsigned char ch) const;
inline unsigned char ToTitle(unsigned char ch) const;
-
+
inline int ToDigit(unsigned char ch) const {
return ::ToDigit(unicode[ch]);
}
- static void Initialize();
+ static void Initialize();
inline bool SingleByteCodepage() const {
return DefaultChar != nullptr;
@@ -90,7 +90,7 @@ struct CodePage {
inline bool NativeCodepage() const {
return SingleByteCodepage() || CPEnum == CODES_UTF8;
}
-};
+};
class TCodePageHash;
@@ -151,7 +151,7 @@ inline bool ValidCodepage(ECharset e) {
inline const CodePage* CodePageByCharset(ECharset e) {
return ::NCodepagePrivate::TCodepagesMap::Instance().Get(e);
-}
+}
ECharset CharsetByName(TStringBuf name);
@@ -176,7 +176,7 @@ inline const char* NameByCharsetSafe(ECharset e) {
inline const char* NameByCodePage(const CodePage* CP) {
return CP->Names[0];
}
-
+
inline const CodePage* CodePageByName(const char* name) {
ECharset code = CharsetByName(name);
if (code == CODES_UNKNOWN)
@@ -190,7 +190,7 @@ ECharset EncodingHintByName(const char* name);
/*****************************************************************\
* struct Encoder *
\*****************************************************************/
-struct Encoder {
+struct Encoder {
char* Table[256];
const char* DefaultChar;
@@ -198,7 +198,7 @@ struct Encoder {
if (ch > 0xFFFF)
return 0;
return (unsigned char)Table[(ch >> 8) & 255][ch & 255];
- }
+ }
inline char Tr(wchar32 ch) const {
char code = Code(ch);
@@ -206,11 +206,11 @@ struct Encoder {
code = DefaultChar[NUnicode::CharType(ch)];
Y_ASSERT(code != 0 || ch == 0);
return code;
- }
+ }
inline unsigned char operator[](wchar32 ch) const {
- return Tr(ch);
- }
+ return Tr(ch);
+ }
void Tr(const wchar32* in, char* out, size_t len) const;
void Tr(const wchar32* in, char* out) const;
@@ -220,27 +220,27 @@ struct Encoder {
/*****************************************************************\
* struct Recoder *
\*****************************************************************/
-struct Recoder {
+struct Recoder {
unsigned char Table[257];
void Create(const CodePage& source, const CodePage& target);
void Create(const CodePage& source, const Encoder* wideTarget);
-
+
void Create(const CodePage& page, wchar32 (*mapper)(wchar32));
void Create(const CodePage& page, const Encoder* widePage, wchar32 (*mapper)(wchar32));
inline unsigned char Tr(unsigned char c) const {
- return Table[c];
- }
+ return Table[c];
+ }
inline unsigned char operator[](unsigned char c) const {
- return Table[c];
- }
+ return Table[c];
+ }
void Tr(const char* in, char* out, size_t len) const;
void Tr(const char* in, char* out) const;
void Tr(char* in_out, size_t len) const;
void Tr(char* in_out) const;
-};
-
+};
+
extern const struct Encoder& WideCharToYandex;
const Encoder& EncoderByCharset(ECharset enc);
@@ -276,16 +276,16 @@ inline const Encoder& EncoderByCharset(ECharset enc) {
inline unsigned char CodePage::ToUpper(unsigned char ch) const {
return NCodepagePrivate::TCodePageData::rcdr_to_upper[CPEnum].Table[ch];
-}
+}
inline unsigned char CodePage::ToLower(unsigned char ch) const {
return NCodepagePrivate::TCodePageData::rcdr_to_lower[CPEnum].Table[ch];
-}
+}
inline unsigned char CodePage::ToTitle(unsigned char ch) const {
return NCodepagePrivate::TCodePageData::rcdr_to_title[CPEnum].Table[ch];
-}
-
+}
+
extern const CodePage& csYandex;
-
+
/// these functions change (lowers) [end] position in case of utf-8
/// null character is NOT assumed or written at [*end]
void DecodeUnknownPlane(wchar16* start, wchar16*& end, const ECharset enc4unk);
diff --git a/library/cpp/charset/recyr.hh b/library/cpp/charset/recyr.hh
index e22ec3b9bc..5ec8734bcf 100644
--- a/library/cpp/charset/recyr.hh
+++ b/library/cpp/charset/recyr.hh
@@ -10,7 +10,7 @@
#include "doccodes.h"
#include "iconv.h"
#include "recyr_int.hh"
-
+
///////////////////////////////////////////////////////////////////////////////////////
// input buf -> output buf //
///////////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/containers/atomizer/atomizer.h b/library/cpp/containers/atomizer/atomizer.h
index dd8a3d0a5b..5e40f47ab9 100644
--- a/library/cpp/containers/atomizer/atomizer.h
+++ b/library/cpp/containers/atomizer/atomizer.h
@@ -1,5 +1,5 @@
#pragma once
-
+
#include <library/cpp/containers/str_map/str_map.h>
#include <util/generic/vector.h>
@@ -14,12 +14,12 @@ class atomizer;
template <class T, class HashFcn = THash<const char*>, class EqualTo = TEqualTo<const char*>>
class super_atomizer;
-template <class HashFcn, class EqualTo>
+template <class HashFcn, class EqualTo>
class atomizer: public string_hash<ui32, HashFcn, EqualTo> {
private:
TVector<const char*> order;
-public:
+public:
using iterator = typename string_hash<ui32, HashFcn, EqualTo>::iterator;
using const_iterator = typename string_hash<ui32, HashFcn, EqualTo>::const_iterator;
using value_type = typename string_hash<ui32, HashFcn, EqualTo>::value_type;
@@ -34,13 +34,13 @@ public:
using string_hash<ui32, HashFcn, EqualTo>::clear_hash;
atomizer() {
- order.reserve(HASH_SIZE_DEFAULT);
- }
+ order.reserve(HASH_SIZE_DEFAULT);
+ }
atomizer(size_type hash_size, pool_size_type pool_size)
: string_hash<ui32, HashFcn, EqualTo>(hash_size, pool_size)
- {
- order.reserve(hash_size);
- }
+ {
+ order.reserve(hash_size);
+ }
~atomizer() = default;
ui32 string_to_atom(const char* key) {
const char* old_begin = pool.Begin();
@@ -49,36 +49,36 @@ public:
if (ins.second) { // new?
if (pool.Begin() != old_begin) // repoint?
for (TVector<const char*>::iterator ptr = order.begin(); ptr != order.end(); ++ptr)
- if (old_begin <= *ptr && *ptr < old_end) // from old pool?
+ if (old_begin <= *ptr && *ptr < old_end) // from old pool?
*ptr += pool.Begin() - old_begin;
- order.push_back((*ins.first).first); // copy of 'key'
- }
+ order.push_back((*ins.first).first); // copy of 'key'
+ }
return (ui32)(*ins.first).second;
- }
-
+ }
+
ui32 perm_string_to_atom(const char* key) {
value_type val(key, ui32(size() + 1));
std::pair<iterator, bool> ins = this->insert(val);
- if (ins.second)
- order.push_back((*ins.first).first); // == copy of 'key'
+ if (ins.second)
+ order.push_back((*ins.first).first); // == copy of 'key'
return (ui32)(*ins.first).second; // == size()+1
- }
+ }
ui32 find_atom(const char* key) const {
const_iterator it = find(key);
- if (it == end())
- return 0; // INVALID_ATOM
- else
+ if (it == end())
+ return 0; // INVALID_ATOM
+ else
return (ui32)(*it).second;
- }
+ }
const char* get_atom_name(ui32 atom) const {
- if (atom && atom <= size())
+ if (atom && atom <= size())
return order[atom - 1];
return nullptr;
- }
+ }
void clear_atomizer() {
- clear_hash();
- order.clear();
- }
+ clear_hash();
+ order.clear();
+ }
void SaveC2N(FILE* f) const { // we write sorted file
for (ui32 i = 0; i < order.size(); i++)
if (order[i])
@@ -197,4 +197,4 @@ public:
clear_hash();
order.clear();
}
-};
+};
diff --git a/library/cpp/containers/str_map/str_map.h b/library/cpp/containers/str_map/str_map.h
index a6d44db7c4..31b00d1b99 100644
--- a/library/cpp/containers/str_map/str_map.h
+++ b/library/cpp/containers/str_map/str_map.h
@@ -1,5 +1,5 @@
#pragma once
-
+
#include <util/memory/segmented_string_pool.h>
#include <util/generic/map.h>
#include <util/generic/hash.h>
@@ -7,14 +7,14 @@
#include <util/str_stl.h> // less<> and equal_to<> for const char*
#include <utility>
#include <util/generic/noncopyable.h>
-
+
template <class T, class HashFcn = THash<const char*>, class EqualTo = TEqualTo<const char*>, class Alloc = std::allocator<const char*>>
class string_hash;
template <class T, class HashFcn = THash<const char*>, class EqualTo = TEqualTo<const char*>>
class segmented_string_hash;
-template <class Map>
+template <class Map>
inline std::pair<typename Map::iterator, bool>
pool_insert(Map* m, const char* key, const typename Map::mapped_type& data, TBuffer& pool) {
std::pair<typename Map::iterator, bool> ins = m->insert(typename Map::value_type(key, data));
@@ -23,23 +23,23 @@ pool_insert(Map* m, const char* key, const typename Map::mapped_type& data, TBuf
const char* old_pool = pool.Begin();
pool.Append(key, buflen);
if (pool.Begin() != old_pool) // repoint?
- for (typename Map::iterator it = m->begin(); it != m->end(); ++it)
- if ((*it).first != key)
+ for (typename Map::iterator it = m->begin(); it != m->end(); ++it)
+ if ((*it).first != key)
const_cast<const char*&>((*it).first) += (pool.Begin() - old_pool);
const_cast<const char*&>((*ins.first).first) = pool.End() - buflen;
- }
- return ins;
-}
-
+ }
+ return ins;
+}
+
#define HASH_SIZE_DEFAULT 100
#define AVERAGEWORD_BUF 10
template <class T, class HashFcn, class EqualTo, class Alloc>
class string_hash: public THashMap<const char*, T, HashFcn, EqualTo, Alloc> {
-protected:
+protected:
TBuffer pool;
-public:
+public:
using yh = THashMap<const char*, T, HashFcn, EqualTo, Alloc>;
using iterator = typename yh::iterator;
using const_iterator = typename yh::const_iterator;
@@ -48,24 +48,24 @@ public:
using pool_size_type = typename yh::size_type;
string_hash() {
pool.Reserve(HASH_SIZE_DEFAULT * AVERAGEWORD_BUF); // reserve here
- }
+ }
string_hash(size_type hash_size, pool_size_type pool_size)
: THashMap<const char*, T, HashFcn, EqualTo, Alloc>(hash_size)
- {
+ {
pool.Reserve(pool_size); // reserve here
- }
-
+ }
+
std::pair<iterator, bool> insert_copy(const char* key, const mapped_type& data) {
- return ::pool_insert(this, key, data, pool);
- }
-
+ return ::pool_insert(this, key, data, pool);
+ }
+
void clear_hash() {
yh::clear();
pool.Clear();
- }
+ }
pool_size_type pool_size() const {
return pool.Size();
- }
+ }
string_hash(const string_hash& sh)
: THashMap<const char*, T, HashFcn, EqualTo, Alloc>()
@@ -98,8 +98,8 @@ public:
I = insert_copy(key, mapped_type()).first;
return (*I).second;
}
-};
-
+};
+
template <class C, class T, class HashFcn, class EqualTo>
class THashWithSegmentedPoolForKeys: protected THashMap<const C*, T, HashFcn, EqualTo>, TNonCopyable {
protected:
@@ -113,7 +113,7 @@ public:
using size_type = typename yh::size_type;
using key_type = typename yh::key_type;
using value_type = typename yh::value_type;
-
+
THashWithSegmentedPoolForKeys(size_type hash_size = HASH_SIZE_DEFAULT, size_t segsize = HASH_SIZE_DEFAULT * AVERAGEWORD_BUF, bool afs = false)
: yh(hash_size)
, pool(segsize)
@@ -177,7 +177,7 @@ public:
template <class T, class HashFcn, class EqualTo>
class segmented_string_hash: public THashWithSegmentedPoolForKeys<char, T, HashFcn, EqualTo> {
-public:
+public:
using Base = THashWithSegmentedPoolForKeys<char, T, HashFcn, EqualTo>;
using iterator = typename Base::iterator;
using const_iterator = typename Base::const_iterator;
@@ -189,17 +189,17 @@ public:
public:
segmented_string_hash(size_type hash_size = HASH_SIZE_DEFAULT, size_t segsize = HASH_SIZE_DEFAULT * AVERAGEWORD_BUF, bool afs = false)
: Base(hash_size, segsize, afs)
- {
- }
+ {
+ }
std::pair<iterator, bool> insert_copy(const char* key, const mapped_type& data) {
return Base::insert_copy(key, strlen(key) + 1, data);
- }
+ }
mapped_type& operator[](const char* key) {
iterator I = Base::find(key);
if (I == Base::end())
I = insert_copy(key, mapped_type()).first;
return (*I).second;
- }
-};
+ }
+};
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.cpp b/library/cpp/deprecated/mapped_file/mapped_file.cpp
index 3884310f7d..b0e4511299 100644
--- a/library/cpp/deprecated/mapped_file/mapped_file.cpp
+++ b/library/cpp/deprecated/mapped_file/mapped_file.cpp
@@ -4,7 +4,7 @@
#include <util/system/defaults.h>
#include <util/system/hi_lo.h>
#include <util/system/filemap.h>
-
+
TMappedFile::TMappedFile(TFileMap* map, const char* dbgName) {
Map_ = map;
i64 len = Map_->Length();
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h
index 5aca2ece4f..45859ed65a 100644
--- a/library/cpp/deprecated/mapped_file/mapped_file.h
+++ b/library/cpp/deprecated/mapped_file/mapped_file.h
@@ -1,5 +1,5 @@
#pragma once
-
+
#include <util/generic/flags.h>
#include <util/generic/ptr.h>
#include <util/generic/string.h>
diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp
index 40020680c2..744501765c 100644
--- a/library/cpp/getopt/small/opt.cpp
+++ b/library/cpp/getopt/small/opt.cpp
@@ -3,9 +3,9 @@
#include <util/system/progname.h>
#include <ctype.h>
-
+
using namespace NLastGetopt;
-
+
namespace {
struct TOptsNoDefault: public TOpts {
TOptsNoDefault(const TStringBuf& optstring = TStringBuf())
@@ -34,15 +34,15 @@ void Opt::Init(int argc, char* argv[], const char* optString, const Ion* longOpt
}
opt->HasArg_ = EHasArg(o->has_arg);
opt->UserValue(o);
- }
+ }
Opts_->AllowSingleDashForLong_ = longOnly;
Opts_->AllowPlusForLong_ = true;
Opts_->AllowUnknownCharOptions_ = isOpen;
Opts_->AllowUnknownLongOptions_ = false;
-
+
OptsParser_.Reset(new TOptsParser(Opts_.Get(), argc, argv));
-}
-
+}
+
Opt::Opt(int argc, char* argv[], const char* optString, const Ion* longOptions, bool longOnly, bool isOpen) {
Init(argc, argv, optString, longOptions, longOnly, isOpen);
}
@@ -65,7 +65,7 @@ int Opt::Get(int* longOptionIndex) {
bool r = OptsParser_->Next();
Ind = (int)OptsParser_->Pos_;
if (!r) {
- return EOF;
+ return EOF;
} else {
Arg = (char*)OptsParser_->CurVal();
if (!OptsParser_->CurOpt()) {
@@ -78,16 +78,16 @@ int Opt::Get(int* longOptionIndex) {
}
char c = OptsParser_->CurOpt()->GetCharOr0();
return c != 0 ? c : ion->val;
- }
- }
+ }
+ }
} catch (const NLastGetopt::TException&) {
GotError_ = true;
if (Err)
Cerr << CurrentExceptionMessage() << Endl;
return '?';
- }
-}
-
+ }
+}
+
void Opt::DummyHelp(IOutputStream& os) {
Opts_->PrintUsage(GetProgramName(), os);
}
diff --git a/library/cpp/http/misc/httpdate.cpp b/library/cpp/http/misc/httpdate.cpp
index cd80921828..4a3031bbf4 100644
--- a/library/cpp/http/misc/httpdate.cpp
+++ b/library/cpp/http/misc/httpdate.cpp
@@ -12,7 +12,7 @@
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
-*
+*
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -37,10 +37,10 @@
#include <util/system/compat.h> /* stricmp */
#include <util/system/yassert.h>
-#include "httpdate.h"
+#include "httpdate.h"
#include <util/datetime/base.h>
-static const char *wkdays[] = {
+static const char *wkdays[] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
@@ -73,8 +73,8 @@ char* format_http_date(time_t when, char* buf, size_t buflen) {
Y_ASSERT(len > 0 && size_t(len) < buflen);
- return buf;
-}
+ return buf;
+}
TString FormatHttpDate(time_t when) {
char str[64] = {0};
diff --git a/library/cpp/http/misc/httpdate.h b/library/cpp/http/misc/httpdate.h
index cf38ca307f..04876f38fe 100644
--- a/library/cpp/http/misc/httpdate.h
+++ b/library/cpp/http/misc/httpdate.h
@@ -4,9 +4,9 @@
#include <util/generic/string.h>
#include <ctime>
-
+
#define BAD_DATE ((time_t)-1)
-
+
inline time_t parse_http_date(const TStringBuf& datestring) {
try {
return TInstant::ParseHttpDeprecated(datestring).TimeT();
diff --git a/library/cpp/packedtypes/longs.h b/library/cpp/packedtypes/longs.h
index 9601e39c98..084098d705 100644
--- a/library/cpp/packedtypes/longs.h
+++ b/library/cpp/packedtypes/longs.h
@@ -6,7 +6,7 @@
#define PUT_8(x, buf, shift) WriteUnaligned<ui8>((buf)++, (x) >> (shift))
#define GET_8_OR(x, buf, type, shift) (x) |= (type) * (buf)++ << (shift)
-
+
#if defined(_big_endian_)
#define LO_SHIFT 1
#define HI_SHIFT 0
@@ -29,16 +29,16 @@
#else
#define PUT_32(x, buf, shift) PUT_16(x, buf, shift + 16 * LO_SHIFT), PUT_16(x, buf, shift + 16 * HI_SHIFT)
#define GET_32_OR(x, buf, type, shift) GET_16_OR(x, buf, type, shift + 16 * LO_SHIFT), GET_16_OR(x, buf, type, shift + 16 * HI_SHIFT)
-#endif
-
+#endif
+
#if !defined(_must_align8_)
#define PUT_64(x, buf, shift) WriteUnaligned<ui64>(buf, (x) >> (shift)), (buf) += 8
#define GET_64_OR(x, buf, type, shift) (x) |= (type)ReadUnaligned<ui64>(buf) << (shift), (buf) += 8
#else
#define PUT_64(x, buf, shift) PUT_32(x, buf, shift + 32 * LO_SHIFT), PUT_32(x, buf, shift + 32 * HI_SHIFT)
#define GET_64_OR(x, buf, type, shift) GET_32_OR(x, buf, type, shift + 32 * LO_SHIFT), GET_32_OR(x, buf, type, shift + 32 * HI_SHIFT)
-#endif
-
+#endif
+
struct mem_traits {
static ui8 get_8(const char*& mem) {
ui8 x = 0;
@@ -67,19 +67,19 @@ struct mem_traits {
static int is_good(char*&) {
return 1;
}
-};
-
-/*
-|____|____|____|____|____|____|____|____|____|____|____|____|____|____|8***|****
-|____|____|____|____|____|____|____|____|____|____|____|____|i4**|****|****|****
-|____|____|____|____|____|____|____|____|____|____|ii2*|****|****|****|****|****
-|____|____|____|____|____|____|____|____|iii1|****|****|****|****|****|****|****
-|____|____|____|____|____|____|iiii|8***|****|****|****|****|****|****|****|****
-|____|____|____|____|iiii|i4**|****|****|****|****|****|****|****|****|****|****
-|____|____|iiii|ii2*|****|****|****|****|****|****|****|****|****|****|****|****
-|iiii|iii1|****|****|****|****|****|****|****|****|****|****|****|****|****|****
-*/
-
+};
+
+/*
+|____|____|____|____|____|____|____|____|____|____|____|____|____|____|8***|****
+|____|____|____|____|____|____|____|____|____|____|____|____|i4**|****|****|****
+|____|____|____|____|____|____|____|____|____|____|ii2*|****|****|****|****|****
+|____|____|____|____|____|____|____|____|iii1|****|****|****|****|****|****|****
+|____|____|____|____|____|____|iiii|8***|****|****|****|****|****|****|****|****
+|____|____|____|____|iiii|i4**|****|****|****|****|****|****|****|****|****|****
+|____|____|iiii|ii2*|****|****|****|****|****|****|****|****|****|****|****|****
+|iiii|iii1|****|****|****|****|****|****|****|****|****|****|****|****|****|****
+*/
+
#define PACK1LIM 0x80u
#define PACK2LIM 0x4000u
#define PACK3LIM 0x200000u
@@ -88,7 +88,7 @@ struct mem_traits {
#define PACK6LIM 0x40000000000ull
#define PACK7LIM 0x2000000000000ull
#define PACK8LIM 0x100000000000000ull
-
+
#define MY_14(x) ((ui16)(x) < PACK1LIM ? 1 : 2)
#define MY_28(x) ((ui32)(x) < PACK2LIM ? MY_14(x) : ((ui32)(x) < PACK3LIM ? 3 : 4))
@@ -100,8 +100,8 @@ struct mem_traits {
#define MACRO_END \
} \
while (0)
-#endif
-
+#endif
+
#define PACK_14(x, buf, how, ret) \
MACRO_BEGIN \
if ((ui16)(x) < PACK1LIM) { \
@@ -113,7 +113,7 @@ struct mem_traits {
(ret) = 2; \
} \
MACRO_END
-
+
#define PACK_28(x, buf, how, ret) \
MACRO_BEGIN \
if ((ui32)(x) < PACK2LIM) { \
@@ -130,7 +130,7 @@ struct mem_traits {
how::put_16((ui16)(x), (buf)); \
} \
MACRO_END
-
+
#define PACK_32(x, buf, how, ret) \
MACRO_BEGIN \
if ((ui32)(x) < PACK4LIM) { \
@@ -176,7 +176,7 @@ struct mem_traits {
how::put_32((ui32)(x), buf); \
} \
MACRO_END
-
+
#define DO_UNPACK_14(firstByte, x, buf, how, ret) \
MACRO_BEGIN \
if (firstByte < 0x80) { \
@@ -188,13 +188,13 @@ struct mem_traits {
(ret) = 2; \
} \
MACRO_END
-
+
#define UNPACK_14(x, buf, how, ret) \
MACRO_BEGIN \
ui8 firstByte = how::get_8(buf); \
DO_UNPACK_14(firstByte, x, buf, how, ret); \
MACRO_END
-
+
#define DO_UNPACK_28(firstByte, x, buf, how, ret) \
MACRO_BEGIN \
if (firstByte < 0xC0) { \
@@ -211,13 +211,13 @@ struct mem_traits {
(x) |= how::get_16(buf); \
} \
MACRO_END
-
+
#define UNPACK_28(x, buf, how, ret) \
MACRO_BEGIN \
ui8 firstByte = how::get_8(buf); \
DO_UNPACK_28(firstByte, x, buf, how, ret); \
MACRO_END
-
+
#define DO_UNPACK_32(firstByte, x, buf, how, ret) \
MACRO_BEGIN \
if (firstByte < 0xF0) { \
@@ -267,44 +267,44 @@ struct mem_traits {
(x) |= how::get_32(buf); \
} \
MACRO_END
-
+
#define UNPACK_64(x, buf, how, ret) \
MACRO_BEGIN \
ui8 firstByte = how::get_8(buf); \
DO_UNPACK_64(firstByte, x, buf, how, ret); \
MACRO_END
-
+
inline int in_long(i64& longVal, const char* ptrBuf) {
- int ret;
- UNPACK_64(longVal, ptrBuf, mem_traits, ret);
- return ret;
-}
-
+ int ret;
+ UNPACK_64(longVal, ptrBuf, mem_traits, ret);
+ return ret;
+}
+
inline int out_long(const i64& longVal, char* ptrBuf) {
- int ret;
+ int ret;
PACK_64(longVal, ptrBuf, mem_traits, ret); /*7*/
- return ret;
-}
-
+ return ret;
+}
+
inline int len_long(const i64& longVal) {
- return MY_64(longVal);
-}
-
+ return MY_64(longVal);
+}
+
inline int in_long(i32& longVal, const char* ptrBuf) {
- int ret;
+ int ret;
UNPACK_32(longVal, ptrBuf, mem_traits, ret);
- return ret;
-}
-
+ return ret;
+}
+
inline int out_long(const i32& longVal, char* ptrBuf) {
- int ret;
+ int ret;
PACK_32(longVal, ptrBuf, mem_traits, ret);
- return ret;
-}
-
+ return ret;
+}
+
inline int len_long(const i32& longVal) {
- return MY_32(longVal);
-}
+ return MY_32(longVal);
+}
template <typename T, typename C>
inline const C* Unpack32(T& x, const C* src) {