scnlib  0.1.2
FormattedinputformodernC++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
vscan.h
Go to the documentation of this file.
1 
2 // Copyright 2017-2019 Elias Kosunen
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 // This file is a part of scnlib:
17 // https://github.com/eliaskosunen/scnlib
18 
19 #ifndef SCN_DETAIL_VSCAN_H
20 #define SCN_DETAIL_VSCAN_H
21 
22 #include "erased_stream.h"
23 #include "visitor.h"
24 
25 namespace scn {
27 
28  namespace detail {
29  struct default_t {
30  };
31  } // namespace detail
32  namespace {
33  SCN_CONSTEXPR auto&& default_tag =
35  }
36 
37  template <typename Context>
38  scan_result vscan(Context& ctx)
39  {
40  return visit(ctx);
41  }
42 
43 #if SCN_PREDEFINE_VSCAN_OVERLOADS
44 
45 #define SCN_DECLARE_VSCAN(stream, ch) \
46  scan_result vscan(basic_context<stream>&); \
47  scan_result vscan(basic_context<stream, basic_locale_ref<ch>>&); \
48  scan_result vscan(basic_empty_context<stream>&); \
49  scan_result vscan(basic_empty_context<stream, basic_locale_ref<ch>>&); \
50  scan_result vscan(basic_scanf_context<stream>&); \
51  scan_result vscan(basic_scanf_context<stream, basic_locale_ref<ch>>&)
52 
53 #define SCN_DECLARE_VSCAN_TEMPLATE(stream) \
54  SCN_DECLARE_VSCAN(stream<char>, char); \
55  SCN_DECLARE_VSCAN(stream<wchar_t>, wchar_t)
56 
57  SCN_DECLARE_VSCAN_TEMPLATE(basic_null_stream);
58  SCN_DECLARE_VSCAN_TEMPLATE(basic_cstdio_stream);
59 
60  SCN_DECLARE_VSCAN(basic_bidirectional_iterator_stream<const char*>, char);
61  SCN_DECLARE_VSCAN(basic_bidirectional_iterator_stream<const wchar_t*>,
62  wchar_t);
63 
64  namespace detail {
65  template <typename CharT>
66  using string_stream =
67  basic_static_container_stream<CharT, std::basic_string<CharT>>;
68  template <typename CharT>
69  using span_stream =
70  basic_static_container_stream<CharT, span<const CharT>>;
71  } // namespace detail
72  SCN_DECLARE_VSCAN(detail::string_stream<char>, char);
73  SCN_DECLARE_VSCAN(detail::string_stream<wchar_t>, wchar_t);
74  SCN_DECLARE_VSCAN(detail::span_stream<char>, char);
75  SCN_DECLARE_VSCAN(detail::span_stream<wchar_t>, wchar_t);
76 
77 #endif // SCN_PREDEFINE_SCN_OVERLOADS
78 
79  template <typename CharT>
81  template <typename CharT>
84 
90 
95 
96  template <typename Stream, bool Empty = false>
98  using char_type = typename Stream::char_type;
99  using type = typename std::conditional<
103  };
104 
105  template <typename CharT>
108  template <typename CharT>
111 
119 
124 
125  template <typename Stream>
126  struct erased_stream_context_type<Stream, true> {
127  using char_type = typename Stream::char_type;
128  using type = typename std::conditional<
132  };
133 
135 } // namespace scn
136 
137 #if defined(SCN_HEADER_ONLY) && SCN_HEADER_ONLY && \
138  !defined(SCN_DETAIL_VSCAN_CPP)
139 #include "vscan.cpp"
140 #endif
141 
142 #endif // SCN_DETAIL_VSCAN_H
143 
#define SCN_END_NAMESPACE
Definition: config.h:376
typename Stream::char_type char_type
Definition: vscan.h:98
scan_result vscan(Context &ctx)
Definition: vscan.h:38
typename Stream::char_type char_type
Definition: vscan.h:127
scan_result visit(Context &ctx)
Definition: visitor.h:1435
#define SCN_BEGIN_NAMESPACE
Definition: config.h:375
#define SCN_CONSTEXPR
Definition: config.h:226
typename std::conditional< is_sized_stream< Stream >::value, basic_erased_empty_sized_stream_context< char_type >, basic_erased_empty_stream_context< char_type >>::type type
Definition: vscan.h:131
typename std::conditional< is_sized_stream< Stream >::value, basic_erased_sized_stream_context< char_type >, basic_erased_stream_context< char_type >>::type type
Definition: vscan.h:102