blob: dac734b68db952dd3f391a65d4288449ec173e4a [file] [log] [blame]
alokp@chromium.org4e4b8072011-08-07 05:36:04 +00001//
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
alokp@chromium.org30a487c2012-05-02 17:30:46 +000010#include <vector>
alokp@chromium.org98eec912012-05-01 10:04:08 +000011
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000012namespace pp
13{
14
alokp@chromium.org98eec912012-05-01 10:04:08 +000015// Holds and reads input for Lexer.
16class Input
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000017{
alokp@chromium.org98eec912012-05-01 10:04:08 +000018 public:
alokp@chromium.org28182482012-04-24 23:07:34 +000019 Input();
alokp@chromium.org98eec912012-05-01 10:04:08 +000020 Input(int count, const char* const string[], const int length[]);
alokp@chromium.org98eec912012-05-01 10:04:08 +000021
22 int count() const { return mCount; }
23 const char* string(int index) const { return mString[index]; }
24 int length(int index) const { return mLength[index]; }
25
26 int read(char* buf, int maxSize);
27
28 struct Location
29 {
30 int sIndex; // String index;
31 int cIndex; // Char index.
32
33 Location() : sIndex(0), cIndex(0) { }
34 };
35 const Location& readLoc() const { return mReadLoc; }
36
37 private:
alokp@chromium.org98eec912012-05-01 10:04:08 +000038 // Input.
39 int mCount;
40 const char* const* mString;
alokp@chromium.org30a487c2012-05-02 17:30:46 +000041 std::vector<int> mLength;
alokp@chromium.org98eec912012-05-01 10:04:08 +000042
43 Location mReadLoc;
alokp@chromium.org4e4b8072011-08-07 05:36:04 +000044};
45
46} // namespace pp
47#endif // COMPILER_PREPROCESSOR_INPUT_H_
48