Vcsn  2.4
Be Rational
read.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/dyn/context.hh>
4 #include <vcsn/dyn/fwd.hh>
5 #include <vcsn/dyn/value.hh>
7 
8 namespace vcsn
9 {
10 
11  /*-------------.
12  | read_label. |
13  `-------------*/
14 
15  template <typename Context>
16  auto
17  read_label(const Context& ctx, std::istream& is,
18  bool quoted = false)
20  {
21  return ctx.labelset()->conv(is, quoted);
22  }
23 
24  namespace dyn
25  {
26  namespace detail
27  {
29  template <typename Context, typename Istream, typename Bool>
30  label
31  read_label(const context& ctx, std::istream& is, bool quoted)
32  {
33  const auto& c = ctx->as<Context>();
34  auto res = ::vcsn::read_label(c, is, quoted);
35  return {*c.labelset(), res};
36  }
37  }
38  }
39 
40 
41  /*------------------.
42  | read_polynomial. |
43  `------------------*/
44 
45  template <typename Context>
46  auto
47  read_polynomial(const Context& ctx, std::istream& is)
49  {
50  return polynomialset<Context>(ctx).conv(is);
51  }
52 
53  namespace dyn
54  {
55  namespace detail
56  {
58  template <typename Context, typename Istream>
60  read_polynomial(const context& ctx, std::istream& is)
61  {
62  const auto& c = ctx->as<Context>();
63  auto ps = polynomialset<Context>(c);
64  auto res = ::vcsn::read_polynomial(c, is);
65  return {ps, res};
66  }
67  }
68  }
69 
70 
71  /*--------------.
72  | read_weight. |
73  `--------------*/
74 
75  template <typename Context>
76  auto
77  read_weight(const Context& ctx, std::istream& is)
79  {
80  return ctx.weightset()->conv(is);
81  }
82 
83  namespace dyn
84  {
85  namespace detail
86  {
88  template <typename Context, typename Istream>
89  weight
90  read_weight(const context& ctx, std::istream& is)
91  {
92  const auto& c = ctx->as<Context>();
93  auto res = ::vcsn::read_weight(c, is);
94  return {*c.weightset(), res};
95  }
96  }
97  }
98 } // namespace vcsn
return res
Definition: multiply.hh:398
value_impl< detail::weight_tag > weight
Definition: fwd.hh:28
polynomial read_polynomial(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:60
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
Definition: traits.hh:62
auto & as()
Downcast to the exact type.
Definition: context.hh:36
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
Definition: read.hh:47
weight read_weight(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:90
Definition: a-star.hh:8
Template-less root for contexts.
Definition: context.hh:16
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Definition: traits.hh:66
auto conv(const ValueSet &vs, const std::string &str, Args &&...args) -> decltype(vs.conv(std::declval< std::istream & >(), std::forward< Args >(args)...))
Parse str via vs.conv.
Definition: stream.hh:29
value_impl< detail::label_tag > label
Definition: fwd.hh:26
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
Definition: read.hh:17
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
Definition: read.hh:77
value_impl< detail::polynomial_tag > polynomial
Definition: fwd.hh:27
label read_label(const context &ctx, std::istream &is, bool quoted)
Bridge.
Definition: read.hh:31