Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/lexer-source-line-finder.h
1 /* 2 * Copyright 2017 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_LEXER_SOURCE_LINE_FINDER_H_ 18 #define WABT_LEXER_SOURCE_LINE_FINDER_H_ 19 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "wabt/common.h" 25 #include "wabt/lexer-source.h" 26 #include "wabt/range.h" 27 28 namespace wabt { 29 30 class LexerSourceLineFinder { 31 public: 32 struct SourceLine { 33 std::string line; 34 int column_offset; 35 }; 36 37 explicit LexerSourceLineFinder(std::unique_ptr<LexerSource>); 38 39 Result GetSourceLine(const Location& loc, 40 Offset max_line_length, 41 SourceLine* out_source_line); 42 Result GetLineOffsets(int line, OffsetRange* out_offsets); 43 44 private: 45 static OffsetRange ClampSourceLineOffsets(OffsetRange line_offset_range, 46 ColumnRange column_range, 47 Offset max_line_length); 48 49 bool IsLineCached(int line) const; 50 OffsetRange GetCachedLine(int line) const; 51 52 std::unique_ptr<LexerSource> source_; 53 std::vector<OffsetRange> line_ranges_; 54 Offset next_line_start_; 55 bool last_cr_; // Last read character was a '\r' (carriage return). 56 bool eof_; 57 }; 58 59 } // namespace wabt 60 61 #endif // WABT_LEXER_SOURCE_LINE_FINDER_H_