MCPcopy Create free account
hub / github.com/catboost/catboost / CsvSplitter

Class CsvSplitter

library/cpp/string_utils/csv/csv.h:27–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 };
26
27 class CsvSplitter {
28 public:
29 CsvSplitter(const TString& data, const char delimeter = ',', const char quote = '"')
30 // quote = '\0' ignores quoting in values and words like simple split
31 : Delimeter(delimeter)
32 , Quote(quote)
33 , Begin(data.begin())
34 , End(data.end())
35 {
36 }
37
38 bool Step() {
39 if (Begin == End) {
40 return false;
41 }
42 ++Begin;
43 return true;
44 }
45
46 TStringBuf Consume();
47 explicit operator TVector<TString>() {
48 TVector<TString> ret;
49
50 do {
51 TStringBuf buf = Consume();
52 ret.push_back(TString{buf});
53 } while (Step());
54
55 return ret;
56 }
57
58 private:
59 const char Delimeter;
60 const char Quote;
61 TString::const_iterator Begin;
62 const TString::const_iterator End;
63 std::vector<std::unique_ptr<TString>> TempResults; // CsvSplitter lifetime
64 std::vector<TStringBuf> TempResultParts; // Single Consume() method call lifetime
65 };
66}

Callers 5

TCBDsvDataLoaderMethod · 0.85
ProcessBlockMethod · 0.85
GetDsvColumnCountFunction · 0.85
NextLineMethod · 0.85

Calls 3

StepFunction · 0.85
ConsumeFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected