#pragma once #include #include namespace NYsonPull { namespace NDetail { template class stream_counter; template <> class stream_counter { private: size_t offset_ = 0; size_t line_ = 1; size_t column_ = 1; public: TPositionInfo info() const { return {offset_, line_, column_}; } void update(const ui8* begin, const ui8* end) { offset_ += end - begin; for (auto current = begin; current != end; ++current) { ++column_; if (*current == '\n') { //TODO: memchr ++line_; column_ = 1; } } } }; template <> class stream_counter { private: size_t offset_ = 0; public: TPositionInfo info() const { return {offset_, {}, {}}; } void update(const ui8* begin, const ui8* end) { offset_ += end - begin; } }; } }