1 #ifndef CAFFE2_OPERATORS_TEXT_FILE_READER_UTILS_H 2 #define CAFFE2_OPERATORS_TEXT_FILE_READER_UTILS_H 8 #include "caffe2/core/common.h" 20 std::vector<std::shared_ptr<std::string>> modifiedStrings_;
21 std::vector<Token> tokens_;
25 const std::vector<Token>& tokens()
const {
28 int lastDelim()
const {
38 std::string leftover_;
46 Tokenizer(
const std::vector<char>& delimiters,
char escape);
58 virtual void reset() = 0;
65 : provider_(p), tokenizer_(t), tokenIndex_(0), numPasses_(numPasses) {}
67 bool next(
Token& token) {
69 while (tokenIndex_ >= tokenized_.tokens().size()) {
70 range.start =
nullptr;
71 while (range.start ==
nullptr && pass_ < numPasses_) {
73 if (range.start ==
nullptr) {
75 if (pass_ < numPasses_) {
81 if (range.start ==
nullptr) {
84 tokenizer_.next(range.start, range.end, tokenized_);
87 token = tokenized_.tokens()[tokenIndex_++];
91 int endDelim()
const {
92 if (tokenIndex_ + 1 < tokenized_.tokens().size()) {
93 return tokenized_.tokens()[tokenIndex_ + 1].startDelimId;
95 return tokenized_.lastDelim();
109 explicit FileReader(
const std::string& path,
size_t bufferSize = 65536);
111 void operator()(
CharRange& range)
override;
112 void reset()
override;
115 const size_t bufferSize_;
117 std::unique_ptr<char[]> buffer_;
122 #endif // CAFFE2_OPERATORS_TEXT_FILE_READER_UTILS_H
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...