Vcsn  2.2a
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/label.hh>
6 #include <vcsn/dyn/polynomial.hh>
7 #include <vcsn/dyn/weight.hh>
9 
10 namespace vcsn
11 {
12 
13  /*-------------.
14  | read_label. |
15  `-------------*/
16 
17  template <typename Context>
18  inline
19  auto
20  read_label(const Context& ctx, std::istream& is,
21  bool quoted = false)
23  {
24  return ctx.labelset()->conv(is, quoted);
25  }
26 
27  namespace dyn
28  {
29  namespace detail
30  {
32  template <typename Context, typename Istream, typename Bool>
33  label
34  read_label(const context& ctx, std::istream& is, bool quoted)
35  {
36  const auto& c = ctx->as<Context>();
37  auto res = ::vcsn::read_label(c, is, quoted);
38  return make_label(*c.labelset(), res);
39  }
40  }
41  }
42 
43 
44  /*------------------.
45  | read_polynomial. |
46  `------------------*/
47 
48  template <typename Context>
49  inline
50  auto
51  read_polynomial(const Context& ctx, std::istream& is)
53  {
55  }
56 
57  namespace dyn
58  {
59  namespace detail
60  {
62  template <typename Context, typename Istream>
64  read_polynomial(const context& ctx, std::istream& is)
65  {
66  const auto& c = ctx->as<Context>();
67  auto ps = polynomialset<Context>(c);
68  auto res = ::vcsn::read_polynomial(c, is);
69  return make_polynomial(ps, res);
70  }
71  }
72  }
73 
74 
75  /*--------------.
76  | read_weight. |
77  `--------------*/
78 
79  template <typename Context>
80  inline
81  auto
82  read_weight(const Context& ctx, std::istream& is)
84  {
85  return ctx.weightset()->conv(is);
86  }
87 
88  namespace dyn
89  {
90  namespace detail
91  {
93  template <typename Context, typename Istream>
94  weight
95  read_weight(const context& ctx, std::istream& is)
96  {
97  const auto& c = ctx->as<Context>();
98  auto res = ::vcsn::read_weight(c, is);
99  return make_weight(*c.weightset(), res);
100  }
101  }
102  }
103 } // namespace vcsn
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:380
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:54
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:53
weight read_weight(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:95
label make_label(const LabelSet &ls, const typename LabelSet::value_t &l)
Definition: label.hh:80
label read_label(const context &ctx, std::istream &is, bool quoted)
Bridge.
Definition: read.hh:34
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
Definition: read.hh:82
polynomial read_polynomial(const context &ctx, std::istream &is)
Bridge.
Definition: read.hh:64
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:28
std::shared_ptr< const detail::context_base > context
A dyn::context.
Definition: fwd.hh:26
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
Definition: read.hh:51
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
Definition: read.hh:20
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:71
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Definition: polynomial.hh:103
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
Definition: weight.hh:79
std::shared_ptr< const detail::label_base > label
Definition: fwd.hh:44
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Definition: traits.hh:58
Definition: a-star.hh:8