1//
2// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#ifndef COMPILER_PREPROCESSOR_INPUT_H_
8#define COMPILER_PREPROCESSOR_INPUT_H_
9
10#include <cstddef>
11#include <vector>
12
13namespace angle
14{
15
16namespace pp
17{
18
19// Holds and reads input for Lexer.
20class Input
21{
22 public:
23 Input();
24 ~Input();
25 Input(size_t count, const char *const string[], const int length[]);
26
27 size_t count() const { return mCount; }
28 const char *string(size_t index) const { return mString[index]; }
29 size_t length(size_t index) const { return mLength[index]; }
30
31 size_t read(char *buf, size_t maxSize, int *lineNo);
32
33 struct Location
34 {
35 size_t sIndex; // String index;
36 size_t cIndex; // Char index.
37
38 Location() : sIndex(0), cIndex(0) {}
39 };
40 const Location &readLoc() const { return mReadLoc; }
41
42 private:
43 // Skip a character and return the next character after the one that was skipped.
44 // Return nullptr if data runs out.
45 const char *skipChar();
46
47 // Input.
48 size_t mCount;
49 const char *const *mString;
50 std::vector<size_t> mLength;
51
52 Location mReadLoc;
53};
54
55} // namespace pp
56
57} // namespace angle
58
59#endif // COMPILER_PREPROCESSOR_INPUT_H_
60