]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/ANTLRFileStream.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / ANTLRFileStream.h
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #pragma once
7
8 #include "ANTLRInputStream.h"
9
10 namespace antlr4 {
11
12   /// This is an ANTLRInputStream that is loaded from a file all at once
13   /// when you construct the object (or call load()).
14   // TODO: this class needs testing.
15   class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream {
16   public:
17     ANTLRFileStream() = default;
18     ANTLRFileStream(const std::string &) = delete;
19     ANTLRFileStream(const char *data, size_t length) = delete;
20     ANTLRFileStream(std::istream &stream) = delete;
21
22     // Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM).
23     virtual void loadFromFile(const std::string &fileName);
24     virtual std::string getSourceName() const override;
25
26   private:
27     std::string _fileName; // UTF-8 encoded file name.
28   };
29
30 } // namespace antlr4