aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/regex/pire/extraencodings.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/regex/pire/extraencodings.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/regex/pire/extraencodings.cpp')
-rw-r--r--library/cpp/regex/pire/extraencodings.cpp116
1 files changed, 58 insertions, 58 deletions
diff --git a/library/cpp/regex/pire/extraencodings.cpp b/library/cpp/regex/pire/extraencodings.cpp
index 8645d6cd4f..2e507e4b67 100644
--- a/library/cpp/regex/pire/extraencodings.cpp
+++ b/library/cpp/regex/pire/extraencodings.cpp
@@ -8,73 +8,73 @@
#include "pire.h"
namespace NPire {
- namespace {
- // A one-byte encoding which is capable of transforming upper half of the character
- // table to/from Unicode chars.
- class TOneByte: public TEncoding {
- public:
- TOneByte(ECharset doccode) {
- Table_ = CodePageByCharset(doccode)->unicode;
- for (size_t i = 0; i < 256; ++i)
- Reverse_.insert(std::make_pair(Table_[i], static_cast<char>(i)));
- }
+ namespace {
+ // A one-byte encoding which is capable of transforming upper half of the character
+ // table to/from Unicode chars.
+ class TOneByte: public TEncoding {
+ public:
+ TOneByte(ECharset doccode) {
+ Table_ = CodePageByCharset(doccode)->unicode;
+ for (size_t i = 0; i < 256; ++i)
+ Reverse_.insert(std::make_pair(Table_[i], static_cast<char>(i)));
+ }
- wchar32 FromLocal(const char*& begin, const char* end) const override {
- if (begin != end)
- return Table_[static_cast<unsigned char>(*begin++)];
- else
- ythrow yexception() << "EOF reached in Pire::OneByte::fromLocal()";
- }
+ wchar32 FromLocal(const char*& begin, const char* end) const override {
+ if (begin != end)
+ return Table_[static_cast<unsigned char>(*begin++)];
+ else
+ ythrow yexception() << "EOF reached in Pire::OneByte::fromLocal()";
+ }
- TString ToLocal(wchar32 c) const override {
- THashMap<wchar32, char>::const_iterator i = Reverse_.find(c);
- if (i != Reverse_.end())
- return TString(1, i->second);
- else
- return TString();
- }
+ TString ToLocal(wchar32 c) const override {
+ THashMap<wchar32, char>::const_iterator i = Reverse_.find(c);
+ if (i != Reverse_.end())
+ return TString(1, i->second);
+ else
+ return TString();
+ }
- void AppendDot(TFsm& fsm) const override {
- fsm.AppendDot();
- }
+ void AppendDot(TFsm& fsm) const override {
+ fsm.AppendDot();
+ }
- private:
- const wchar32* Table_;
- THashMap<wchar32, char> Reverse_;
- };
+ private:
+ const wchar32* Table_;
+ THashMap<wchar32, char> Reverse_;
+ };
- template <unsigned N>
- struct TOneByteHelper: public TOneByte {
- inline TOneByteHelper()
- : TOneByte((ECharset)N)
- {
- }
- };
- }
+ template <unsigned N>
+ struct TOneByteHelper: public TOneByte {
+ inline TOneByteHelper()
+ : TOneByte((ECharset)N)
+ {
+ }
+ };
+ }
- namespace NEncodings {
- const NPire::TEncoding& Koi8r() {
- return *Singleton<TOneByteHelper<CODES_KOI8>>();
- }
+ namespace NEncodings {
+ const NPire::TEncoding& Koi8r() {
+ return *Singleton<TOneByteHelper<CODES_KOI8>>();
+ }
- const NPire::TEncoding& Cp1251() {
- return *Singleton<TOneByteHelper<CODES_WIN>>();
+ const NPire::TEncoding& Cp1251() {
+ return *Singleton<TOneByteHelper<CODES_WIN>>();
}
- const NPire::TEncoding& Get(ECharset encoding) {
- switch (encoding) {
- case CODES_WIN:
- return Cp1251();
- case CODES_KOI8:
- return Koi8r();
- case CODES_ASCII:
- return NPire::NEncodings::Latin1();
- case CODES_UTF8:
- return NPire::NEncodings::Utf8();
- default:
- ythrow yexception() << "Pire::Encodings::get(ECharset): unknown encoding " << (int)encoding;
- }
- }
+ const NPire::TEncoding& Get(ECharset encoding) {
+ switch (encoding) {
+ case CODES_WIN:
+ return Cp1251();
+ case CODES_KOI8:
+ return Koi8r();
+ case CODES_ASCII:
+ return NPire::NEncodings::Latin1();
+ case CODES_UTF8:
+ return NPire::NEncodings::Utf8();
+ default:
+ ythrow yexception() << "Pire::Encodings::get(ECharset): unknown encoding " << (int)encoding;
+ }
+ }
}