Browse Source

Restoring authorship annotation for <yuliy@yandex-team.ru>. Commit 2 of 2.

yuliy 3 years ago
parent
commit
9991a6195d

+ 36 - 36
library/cpp/deprecated/split/delim_string_iter.cpp

@@ -1,45 +1,45 @@
 #include "delim_string_iter.h"
- 
-// 
+
+//
 // TKeyValueDelimStringIter
-// 
- 
+//
+
 void TKeyValueDelimStringIter::ReadKeyAndValue() {
-    TStringBuf currentToken(*DelimIter); 
- 
-    size_t pos = currentToken.find('='); 
+    TStringBuf currentToken(*DelimIter);
+
+    size_t pos = currentToken.find('=');
     if (pos == TString::npos) {
-        ChunkValue.Clear(); 
-        ChunkKey = currentToken; 
-    } else { 
-        ChunkKey = currentToken.SubStr(0, pos); 
-        ChunkValue = currentToken.SubStr(pos + 1); 
-    } 
-} 
- 
+        ChunkValue.Clear();
+        ChunkKey = currentToken;
+    } else {
+        ChunkKey = currentToken.SubStr(0, pos);
+        ChunkValue = currentToken.SubStr(pos + 1);
+    }
+}
+
 TKeyValueDelimStringIter::TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim)
-    : DelimIter(str, delim) 
-{ 
-    if (DelimIter.Valid()) 
-        ReadKeyAndValue(); 
-} 
- 
+    : DelimIter(str, delim)
+{
+    if (DelimIter.Valid())
+        ReadKeyAndValue();
+}
+
 bool TKeyValueDelimStringIter::Valid() const {
-    return DelimIter.Valid(); 
-} 
- 
+    return DelimIter.Valid();
+}
+
 TKeyValueDelimStringIter& TKeyValueDelimStringIter::operator++() {
-    ++DelimIter; 
-    if (DelimIter.Valid()) 
-        ReadKeyAndValue(); 
- 
-    return *this; 
-} 
- 
+    ++DelimIter;
+    if (DelimIter.Valid())
+        ReadKeyAndValue();
+
+    return *this;
+}
+
 const TStringBuf& TKeyValueDelimStringIter::Key() const {
-    return ChunkKey; 
-} 
- 
+    return ChunkKey;
+}
+
 const TStringBuf& TKeyValueDelimStringIter::Value() const {
-    return ChunkValue; 
-} 
+    return ChunkValue;
+}

+ 10 - 10
library/cpp/deprecated/split/delim_string_iter.h

@@ -167,19 +167,19 @@ inline TDelimStringIter begin_delim(TStringBuf str, TStringBuf delim) {
 inline TDelimStringIter end_delim(const TString& /*str*/, TStringBuf /*delim*/) {
     return TDelimStringIter();
 }
- 
+
 class TKeyValueDelimStringIter {
-public: 
+public:
     TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim);
-    bool Valid() const; 
+    bool Valid() const;
     TKeyValueDelimStringIter& operator++();
     const TStringBuf& Key() const;
     const TStringBuf& Value() const;
- 
-private: 
+
+private:
     TDelimStringIter DelimIter;
-    TStringBuf ChunkKey, ChunkValue; 
- 
-private: 
-    void ReadKeyAndValue(); 
-}; 
+    TStringBuf ChunkKey, ChunkValue;
+
+private:
+    void ReadKeyAndValue();
+};

+ 28 - 28
library/cpp/deprecated/split/delim_string_iter_ut.cpp

@@ -50,50 +50,50 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) {
         UNIT_ASSERT_EQUAL(got, expected);
     }
 }
- 
-static void AssertKeyValueStringSplit( 
+
+static void AssertKeyValueStringSplit(
     const TStringBuf str,
     const TStringBuf delim,
     const TVector<std::pair<TStringBuf, TStringBuf>>& expected) {
     TKeyValueDelimStringIter it(str, delim);
- 
-    for (const auto& expectedKeyValue : expected) { 
-        UNIT_ASSERT(it.Valid()); 
-        UNIT_ASSERT_STRINGS_EQUAL(it.Key(), expectedKeyValue.first); 
-        UNIT_ASSERT_STRINGS_EQUAL(it.Value(), expectedKeyValue.second); 
-        ++it; 
-    } 
-    UNIT_ASSERT(!it.Valid()); 
-} 
- 
+
+    for (const auto& expectedKeyValue : expected) {
+        UNIT_ASSERT(it.Valid());
+        UNIT_ASSERT_STRINGS_EQUAL(it.Key(), expectedKeyValue.first);
+        UNIT_ASSERT_STRINGS_EQUAL(it.Value(), expectedKeyValue.second);
+        ++it;
+    }
+    UNIT_ASSERT(!it.Valid());
+}
+
 Y_UNIT_TEST_SUITE(TKeyValueDelimStringIterTestSuite) {
     Y_UNIT_TEST(SingleCharacterAsDelimiter) {
-        AssertKeyValueStringSplit( 
-            "abc=123,cde=qwer", ",", 
+        AssertKeyValueStringSplit(
+            "abc=123,cde=qwer", ",",
             {{"abc", "123"},
              {"cde", "qwer"}});
-    } 
- 
+    }
+
     Y_UNIT_TEST(MultipleCharactersAsDelimiter) {
-        AssertKeyValueStringSplit( 
-            "abc=xyz@@qwerty=zxcv", "@@", 
+        AssertKeyValueStringSplit(
+            "abc=xyz@@qwerty=zxcv", "@@",
             {{"abc", "xyz"},
              {"qwerty", "zxcv"}});
-    } 
- 
+    }
+
     Y_UNIT_TEST(NoDelimiters) {
-        AssertKeyValueStringSplit( 
-            "abc=zz", ",", 
+        AssertKeyValueStringSplit(
+            "abc=zz", ",",
             {{"abc", "zz"}});
-    } 
- 
+    }
+
     Y_UNIT_TEST(EmptyElements) {
-        AssertKeyValueStringSplit( 
-            "@@abc=zxy@@@@qwerty=y@@", "@@", 
+        AssertKeyValueStringSplit(
+            "@@abc=zxy@@@@qwerty=y@@", "@@",
             {{"", ""},
              {"abc", "zxy"},
              {"", ""},
              {"qwerty", "y"},
              {"", ""}});
-    } 
-} 
+    }
+}