Vcsn  2.5.dev
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  | read_label. |
12  `-------------*/
13 
14  template <typename Context>
15  auto
16  read_label(const Context& ctx, std::istream& is,
17  bool quoted = false)
19  {
20  return ctx.labelset()->conv(is, quoted);
21  }
22 
23  namespace dyn
24  {
25  namespace detail
26  {
28  template <typename Context, typename Istream, typename Bool>
29  label
30  read_label(const context& ctx, std::istream& is, bool quoted)
31  {
32  const auto& c = ctx->as<Context>();
33  auto res = ::vcsn::read_label(c, is, quoted);
34  return {*c.labelset(), res};
35  }
36  }
37  }
38 
39 
40  /*------------------.
41  | read_polynomial. |
42  `------------------*/
43 
44  template <typename Context>
45  auto
46  read_polynomial(const Context& ctx, std::istream& is)
48  {
49  return polynomialset<Context>(ctx).conv(is);
50  }
51 
52  namespace dyn
53  {
54  namespace detail
55  {
57  template <typename Context, typename Istream>
59  read_polynomial(const context& ctx, std::istream& is)
60  {
61  const auto& c = ctx->as<Context>();
62  auto ps = polynomialset<Context>(c);
63  auto res = ::vcsn::read_polynomial(c, is);
64  return {ps, res};
65  }
66  }
67  }
68 
69 
70  /*--------------.
71  | read_weight. |
72  `--------------*/
73 
74  template <typename Context>
75  auto
76  read_weight(const Context& ctx, std::istream& is)
78  {
79  return ctx.weightset()->conv(is);
80  }
81 
82  namespace dyn
83  {
84  namespace detail
85  {
87  template <typename Context, typename Istream>
88  weight
89  read_weight(const context& ctx, std::istream& is)
90  {
91  const auto& c = ctx->as<Context>();
92  auto res = ::vcsn::read_weight(c, is);
93  return {*c.weightset(), res};
94  }
95  }
96  }
97 } // namespace vcsn
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
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
Definition: traits.hh:62
return res
Definition: multiply.hh:399
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
Definition: read.hh:16
polynomial read_polynomial(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:59
Template-less root for contexts.
Definition: context.hh:16
auto & as()
Downcast to the exact type.
Definition: context.hh:36
value_impl< detail::weight_tag > weight
Definition: fwd.hh:34
Definition: a-star.hh:8
value_impl< detail::label_tag > label
Definition: fwd.hh:32
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
Definition: traits.hh:66
weight read_weight(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:89
value_impl< detail::polynomial_tag > polynomial
Definition: fwd.hh:33
label read_label(const context &ctx, std::istream &is, bool quoted)
Bridge.
Definition: read.hh:30