Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
read.hh
Go to the documentation of this file.
1 #ifndef VCSN_ALGOS_READ_HH
2 # define VCSN_ALGOS_READ_HH
3 
4 # include <vcsn/dyn/context.hh>
5 # include <vcsn/dyn/fwd.hh>
6 # include <vcsn/dyn/label.hh>
7 # include <vcsn/dyn/polynomial.hh>
8 # include <vcsn/dyn/weight.hh>
10 
11 namespace vcsn
12 {
13 
14  /*-------------.
15  | read_label. |
16  `-------------*/
17 
18  template <typename Context>
19  inline
20  auto
21  read_label(std::istream& is, const Context& ctx)
23  {
24  return ctx.labelset()->conv(is);
25  }
26 
27  namespace dyn
28  {
29  namespace detail
30  {
32  template <typename Istream, typename Context>
33  auto
34  read_label(std::istream& is, const context& ctx)
35  -> label
36  {
37  const auto& c = ctx->as<Context>();
38  auto res = ::vcsn::read_label(is, c);
39  return make_label(*c.labelset(), res);
40  }
41 
43  (std::istream& is, const context& ctx) -> label);
44  }
45  }
46 
47 
48  /*------------------.
49  | read_polynomial. |
50  `------------------*/
51 
52  template <typename Context>
53  inline
54  auto
55  read_polynomial(const Context& ctx, std::istream& is)
57  {
58  return polynomialset<Context>(ctx).conv(is);
59  }
60 
61  namespace dyn
62  {
63  namespace detail
64  {
66  template <typename Context, typename Istream>
67  auto
68  read_polynomial(const context& ctx, std::istream& is)
69  -> polynomial
70  {
71  const auto& c = ctx->as<Context>();
72  auto ps = polynomialset<Context>(c);
73  auto res = ::vcsn::read_polynomial(c, is);
74  return make_polynomial(ps, res);
75  }
76 
78  (const context& ctx, std::istream& is) -> polynomial);
79  }
80  }
81 
82 
83  /*--------------.
84  | read_weight. |
85  `--------------*/
86 
87  template <typename Context>
88  inline
89  auto
90  read_weight(const Context& ctx, std::istream& is)
92  {
93  return ctx.weightset()->conv(is);
94  }
95 
96  namespace dyn
97  {
98  namespace detail
99  {
101  template <typename Context, typename Istream>
102  auto
103  read_weight(const context& ctx, std::istream& is)
104  -> weight
105  {
106  const auto& c = ctx->as<Context>();
107  auto res = ::vcsn::read_weight(c, is);
108  return make_weight(*c.weightset(), res);
109  }
110 
112  (const context& ctx, std::istream& is) -> weight);
113  }
114  }
115 
116 
117 } // namespace vcsn
118 
119 #endif // !VCSN_ALGOS_READ_HH
Linear combination of labels: map labels to weights.
Definition: fwd.hh:32
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &polynomial)
Definition: polynomial.hh:91
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:82
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
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
Definition: read.hh:90
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
Definition: traits.hh:33
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:329
std::shared_ptr< const detail::label_base > label
Definition: fwd.hh:46
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
Definition: weight.hh:82
auto read_label(std::istream &is, const context &ctx) -> label
Bridge.
Definition: read.hh:34
std::shared_ptr< const detail::context_base > context
Definition: context.hh:71
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
Definition: read.hh:55
std::map< label_t, weight_t, vcsn::less< labelset_t >> value_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Definition: traits.hh:37
label make_label(const LabelSet &ls, const typename LabelSet::value_t &l)
Definition: label.hh:82
auto read_weight(const context &ctx, std::istream &is) -> weight
Bridge.
Definition: read.hh:103
auto read_label(std::istream &is, const Context &ctx) -> label_t_of< Context >
Definition: read.hh:21
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:55
auto read_polynomial(const context &ctx, std::istream &is) -> polynomial
Bridge.
Definition: read.hh:68