| 68 | } |
| 69 | |
| 70 | TString NCsvFormat::TLinesSplitter::ConsumeLine() { |
| 71 | bool Escape = false; |
| 72 | TString result; |
| 73 | TString line; |
| 74 | while (Input.ReadLine(line)) { |
| 75 | const size_t quoteCount = std::count(line.cbegin(), line.cend(), Quote); |
| 76 | // A theoretically faster version of "if (quoteCount %2 == 1)" |
| 77 | if (quoteCount & 1) { |
| 78 | Escape = !Escape; |
| 79 | } |
| 80 | if (!result) { |
| 81 | result = line; |
| 82 | } else { |
| 83 | result += line; |
| 84 | } |
| 85 | if (!Escape) { |
| 86 | break; |
| 87 | } else { |
| 88 | result += "\n"; |
| 89 | } |
| 90 | } |
| 91 | return result; |
| 92 | } |