diff options
author | akhropov <akhropov@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
commit | 00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch) | |
tree | cb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /library/cpp/deprecated | |
parent | 83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff) | |
download | ydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz |
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/deprecated')
-rw-r--r-- | library/cpp/deprecated/mapped_file/mapped_file.h | 2 | ||||
-rw-r--r-- | library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp | 12 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 104 |
3 files changed, 59 insertions, 59 deletions
diff --git a/library/cpp/deprecated/mapped_file/mapped_file.h b/library/cpp/deprecated/mapped_file/mapped_file.h index 45859ed65a..445d070c69 100644 --- a/library/cpp/deprecated/mapped_file/mapped_file.h +++ b/library/cpp/deprecated/mapped_file/mapped_file.h @@ -59,7 +59,7 @@ public: return (Map_ ? Map_->MappedSize() : 0); } - void* getData(size_t pos = 0) const { + void* getData(size_t pos = 0) const { Y_ASSERT(!Map_ || (pos <= getSize())); return (Map_ ? (void*)((unsigned char*)Map_->Ptr() + pos) : nullptr); } diff --git a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp index afbd5b3358..d62d0bb18c 100644 --- a/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp +++ b/library/cpp/deprecated/mapped_file/ut/mapped_file_ut.cpp @@ -6,13 +6,13 @@ Y_UNIT_TEST_SUITE(TMappedFileTest) { static const char* FileName_("./mappped_file"); Y_UNIT_TEST(TestFileMapEmpty) { - TFile file(FileName_, CreateAlways | WrOnly); - file.Close(); + TFile file(FileName_, CreateAlways | WrOnly); + file.Close(); - TMappedFile map; - map.init(FileName_); + TMappedFile map; + map.init(FileName_); map.getData(0); - + NFs::Remove(FileName_); - } + } }; diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 8e4ca171a0..3d47d23ad9 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -1,13 +1,13 @@ #pragma once - + #include <util/generic/algorithm.h> #include <util/generic/strbuf.h> #include <util/generic/yexception.h> #include <util/string/cast.h> #include <util/system/yassert.h> - + #include <iterator> - + class TDelimStringIter { public: using value_type = TStringBuf; @@ -20,7 +20,7 @@ public: : TDelimStringIter(TStringBuf(begin, strEnd), delim) { } - + inline TDelimStringIter(TStringBuf str, TStringBuf delim) : IsValid(true) , Str(str) @@ -33,7 +33,7 @@ public: : IsValid(false) { } - + inline explicit operator bool() const { return IsValid; } @@ -43,32 +43,32 @@ public: if (Current.end() != Str.end()) { Str.Skip(Current.length() + Delim.length()); UpdateCurrent(); - } else { + } else { Str.Clear(); Current.Clear(); - IsValid = false; - } - return *this; - } - + IsValid = false; + } + return *this; + } + inline void operator+=(size_t n) { for (; n > 0; --n) { - ++(*this); - } - } - + ++(*this); + } + } + inline bool operator==(const TDelimStringIter& rhs) const { return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); - } - + } + inline bool operator!=(const TDelimStringIter& rhs) const { return !(*this == rhs); - } - + } + inline TStringBuf operator*() const { return Current; - } - + } + inline const TStringBuf* operator->() const { return &Current; } @@ -76,23 +76,23 @@ public: // Get & advance template <class T> inline bool TryNext(T& t) { - if (IsValid) { + if (IsValid) { t = FromString<T>(Current); - operator++(); - return true; - } else { - return false; - } - } - + operator++(); + return true; + } else { + return false; + } + } + template <class T> inline TDelimStringIter& Next(T& t) // Get & advance - { - if (!TryNext(t)) - ythrow yexception() << "No valid field"; - return *this; - } - + { + if (!TryNext(t)) + ythrow yexception() << "No valid field"; + return *this; + } + template <class T> inline T GetNext() { T res; @@ -102,24 +102,24 @@ public: inline const char* GetBegin() const { return Current.begin(); - } - + } + inline const char* GetEnd() const { return Current.end(); - } - + } + inline bool Valid() const { - return IsValid; - } - + return IsValid; + } + // contents from next token to the end of string inline TStringBuf Cdr() const { return Str.SubStr(Current.length() + Delim.length()); - } - + } + inline TDelimStringIter IterEnd() const { return TDelimStringIter(); - } + } private: inline void UpdateCurrent() { @@ -134,8 +134,8 @@ private: TStringBuf Str; TStringBuf Current; TStringBuf Delim; -}; - +}; + //example: for (TStringBuf field: TDelimStroka(line, "@@")) { ... } struct TDelimStroka { TStringBuf S; @@ -158,15 +158,15 @@ struct TDelimStroka { inline TDelimStringIter begin_delim(const TString& str, TStringBuf delim) { return TDelimStringIter(str, delim); -} - +} + inline TDelimStringIter begin_delim(TStringBuf str, TStringBuf delim) { return TDelimStringIter(str.begin(), str.end(), delim); -} - +} + inline TDelimStringIter end_delim(const TString& /*str*/, TStringBuf /*delim*/) { return TDelimStringIter(); -} +} class TKeyValueDelimStringIter { public: |