]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/ANTLRFileStream.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / ANTLRFileStream.cpp
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 #include "support/StringUtils.h"
7
8 #include "ANTLRFileStream.h"
9
10 using namespace antlr4;
11
12 void ANTLRFileStream::loadFromFile(const std::string &fileName) {
13   _fileName = fileName;
14   if (_fileName.empty()) {
15     return;
16   }
17
18 #ifdef _MSC_VER
19   std::ifstream stream(antlrcpp::s2ws(fileName), std::ios::binary);
20 #else
21   std::ifstream stream(fileName, std::ios::binary);
22 #endif
23
24   ANTLRInputStream::load(stream);
25 }
26
27 std::string ANTLRFileStream::getSourceName() const {
28   return _fileName;
29 }