Home | History | Annotate | Download | only in preprocessor
      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 <stddef.h>
     11 #include <vector>
     12 
     13 namespace pp
     14 {
     15 
     16 // Holds and reads input for Lexer.
     17 class Input
     18 {
     19   public:
     20     Input();
     21     Input(size_t count, const char *const string[], const int length[]);
     22 
     23     size_t count() const
     24     {
     25         return mCount;
     26     }
     27     const char *string(size_t index) const
     28     {
     29         return mString[index];
     30     }
     31     size_t length(size_t index) const
     32     {
     33         return mLength[index];
     34     }
     35 
     36     size_t read(char *buf, size_t maxSize);
     37 
     38     struct Location
     39     {
     40         size_t sIndex;  // String index;
     41         size_t cIndex;  // Char index.
     42 
     43         Location()
     44             : sIndex(0),
     45               cIndex(0)
     46         {
     47         }
     48     };
     49     const Location &readLoc() const { return mReadLoc; }
     50 
     51   private:
     52     // Input.
     53     size_t mCount;
     54     const char * const *mString;
     55     std::vector<size_t> mLength;
     56 
     57     Location mReadLoc;
     58 };
     59 
     60 }  // namespace pp
     61 #endif  // COMPILER_PREPROCESSOR_INPUT_H_
     62 
     63