blob: 9ebfaca5ba5895a89fa7de4c33a9618a83d8572a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
#ifndef TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP
#define TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP
#include <string>
#include "config.hpp"
#include "eol.hpp"
#include "string_input.hpp"
#include "tracking_mode.hpp"
#include "internal/file_reader.hpp"
namespace tao
{
namespace TAOCPP_PEGTL_NAMESPACE
{
namespace internal
{
struct filename_holder
{
const std::string filename;
template< typename T >
explicit filename_holder( T&& in_filename )
: filename( std::forward< T >( in_filename ) )
{
}
};
} // namespace internal
template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
struct read_input
: private internal::filename_holder,
public string_input< P, Eol, const char* >
{
template< typename T >
explicit read_input( T&& in_filename )
: internal::filename_holder( std::forward< T >( in_filename ) ),
string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() )
{
}
};
} // namespace TAOCPP_PEGTL_NAMESPACE
} // namespace tao
#endif
|