blob: af418c5bfb9ddd78a5c6f78d02eec2f5292298cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include "delim_string_iter.h"
//
// TKeyValueDelimStringIter
//
void TKeyValueDelimStringIter::ReadKeyAndValue() {
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);
}
}
TKeyValueDelimStringIter::TKeyValueDelimStringIter(const TStringBuf str, const TStringBuf delim)
: DelimIter(str, delim)
{
if (DelimIter.Valid())
ReadKeyAndValue();
}
bool TKeyValueDelimStringIter::Valid() const {
return DelimIter.Valid();
}
TKeyValueDelimStringIter& TKeyValueDelimStringIter::operator++() {
++DelimIter;
if (DelimIter.Valid())
ReadKeyAndValue();
return *this;
}
const TStringBuf& TKeyValueDelimStringIter::Key() const {
return ChunkKey;
}
const TStringBuf& TKeyValueDelimStringIter::Value() const {
return ChunkValue;
}
|