diff options
author | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
---|---|---|
committer | vvvv <vvvv@ydb.tech> | 2023-07-31 18:21:04 +0300 |
commit | dec41c40e51aa407edef81a3c566a5a15780fc49 (patch) | |
tree | 4f197b596b32f35eca368121f0dff913419da9af /library/cpp/robots_txt/robots_txt_parser.h | |
parent | 3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff) | |
download | ydb-dec41c40e51aa407edef81a3c566a5a15780fc49.tar.gz |
YQL-16239 Move purecalc to public
Diffstat (limited to 'library/cpp/robots_txt/robots_txt_parser.h')
-rw-r--r-- | library/cpp/robots_txt/robots_txt_parser.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/library/cpp/robots_txt/robots_txt_parser.h b/library/cpp/robots_txt/robots_txt_parser.h new file mode 100644 index 0000000000..8032d0d20b --- /dev/null +++ b/library/cpp/robots_txt/robots_txt_parser.h @@ -0,0 +1,38 @@ +#pragma once + +#include <algorithm> +#include <util/generic/string.h> +#include <util/generic/vector.h> +#include <util/stream/input.h> + +class TRobotsTxtParser; + +class TRobotsTxtRulesRecord { +private: + TRobotsTxtParser& Parser; + +public: + TRobotsTxtRulesRecord(TRobotsTxtParser& parser); + bool NextPair(TString& field, TString& value, bool handleErrors, TVector<int>& nonRobotsLines, bool* wasBlank = nullptr); +}; + +class TRobotsTxtParser { + friend class TRobotsTxtRulesRecord; + +private: + IInputStream& InputStream; + TString Line; + int LineNumber; + bool IsLastSymbolCR; + + const char* ReadLine(); + static bool IsBlankLine(const char*); + static bool IsRobotsLine(const char*); + +public: + static char* Trim(char*); + TRobotsTxtParser(IInputStream& inputStream); + bool HasRecord(); + TRobotsTxtRulesRecord NextRecord(); + int GetLineNumber(); +}; |