Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
print.hh
Go to the documentation of this file.
1 #ifndef VCSN_ALGOS_PRINT_HH
2 # define VCSN_ALGOS_PRINT_HH
3 
4 # include <iosfwd>
5 
6 # include <vcsn/ctx/context.hh>
7 # include <vcsn/dyn/context.hh>
8 # include <vcsn/dyn/expansion.hh>
9 # include <vcsn/dyn/label.hh>
10 # include <vcsn/dyn/fwd.hh>
11 # include <vcsn/dyn/polynomial.hh>
12 # include <vcsn/dyn/ratexp.hh>
13 # include <vcsn/dyn/weight.hh>
14 # include <vcsn/misc/raise.hh>
15 
16 namespace vcsn
17 {
18 
19  /*-------------------------.
20  | print(context, stream). |
21  `-------------------------*/
22 
23  namespace dyn
24  {
25  namespace detail
26  {
28  template <typename Context, typename Ostream, typename String>
29  std::ostream& print_ctx(const context& ctx, std::ostream& o,
30  const std::string& format)
31  {
32  const auto& c = ctx->as<Context>();
33  return c.print_set(o, format);
34  }
35 
37  (const context& c, std::ostream& o,
38  const std::string& format) -> std::ostream&);
39  }
40  }
41 
42  /*---------------------------.
43  | print(expansion, stream). |
44  `---------------------------*/
45 
48  template <typename ValueSet>
49  inline
50  std::ostream&
51  print(const ValueSet& vs, const typename ValueSet::value_t& v,
52  std::ostream& o, const std::string& format)
53  {
54  return vs.print(v, o, format);
55  }
56 
57  namespace dyn
58  {
59  namespace detail
60  {
62  template <typename ExpansionSet, typename Ostream, typename String>
63  std::ostream& print_expansion(const expansion& expansion, std::ostream& o,
64  const std::string& format)
65  {
66  const auto& e = expansion->as<ExpansionSet>();
67  return vcsn::print(e.expansionset(), e.expansion(), o, format);
68  }
69 
71  (const expansion& l, std::ostream& o,
72  const std::string& format) -> std::ostream&);
73  }
74  }
75 
76  /*-----------------------.
77  | print(stream, label). |
78  `-----------------------*/
79 
80  namespace dyn
81  {
82  namespace detail
83  {
85  template <typename LabelSet, typename Ostream, typename String>
86  std::ostream& print_label(const label& label, std::ostream& o,
87  const std::string& format)
88  {
89  const auto& l = label->as<LabelSet>();
90  return vcsn::print(l.labelset(), l.label(), o, format);
91  }
92 
94  (const label& l, std::ostream& o,
95  const std::string& format) -> std::ostream&);
96  }
97  }
98 
99  /*---------------------------.
100  | list(polynomial, stream). |
101  `---------------------------*/
102 
103  template <typename PolynomialSet>
104  inline
105  std::ostream&
106  list(const PolynomialSet& ps, const typename PolynomialSet::value_t& p,
107  std::ostream& o)
108  {
109  bool first = true;
110  for (const auto& m: p)
111  {
112  if (!first)
113  o << std::endl;
114  first = false;
115  ps.print(m, o);
116  }
117  return o;
118  }
119 
120  namespace dyn
121  {
122  namespace detail
123  {
125  template <typename PolynomialSet, typename Ostream>
126  std::ostream& list_polynomial(const polynomial& polynomial,
127  std::ostream& o)
128  {
129  const auto& p = polynomial->as<PolynomialSet>();
130  return vcsn::list(p.polynomialset(), p.polynomial(), o);
131  }
132 
134  (const polynomial& p, std::ostream& o) -> std::ostream&);
135  }
136  }
137 
138  /*----------------------------.
139  | print(polynomial, stream). |
140  `----------------------------*/
141 
142  namespace dyn
143  {
144  namespace detail
145  {
147  template <typename PolynomialSet, typename Ostream, typename String>
148  std::ostream& print_polynomial(const polynomial& polynomial,
149  std::ostream& o, const std::string& format)
150  {
151  const auto& p = polynomial->as<PolynomialSet>();
152  return vcsn::print(p.polynomialset(), p.polynomial(), o, format);
153  }
154 
156  (const polynomial& p, std::ostream& o,
157  const std::string& format) -> std::ostream&);
158  }
159  }
160 
161 
162  /*------------------------.
163  | print(ratexp, stream). |
164  `------------------------*/
165 
166 #if 0
167  template <typename RatExpSet>
169  inline
170  std::ostream&
171  print(const RatExpSet& rs, const typename RatExpSet::value_t& e,
172  std::ostream& o, const std::string& format)
173  {
174  return rs.print(e, o, format);
175  }
176 #endif
177 
178  namespace dyn
179  {
180  namespace detail
181  {
183  template <typename RatExpSet, typename Ostream, typename String>
184  std::ostream& print_ratexp(const ratexp& exp, std::ostream& o,
185  const std::string& format)
186  {
187  const auto& e = exp->as<RatExpSet>();
188  return vcsn::print(e.ratexpset(), e.ratexp(), o, format);
189  }
190 
192  (const ratexp& aut, std::ostream& o,
193  const std::string& format) -> std::ostream&);
194  }
195  }
196 
197  /*------------------------.
198  | print(weight, stream). |
199  `------------------------*/
200 
201 #if 0
202  template <typename WeightSet>
204  inline
205  std::ostream&
206  print(const WeightSet& ws, const typename WeightSet::value_t& w,
207  std::ostream& o)
208  {
209  return ws.print(w, o);
210  }
211 #endif
212 
213  namespace dyn
214  {
215  namespace detail
216  {
218  template <typename WeightSet, typename Ostream, typename String>
219  std::ostream& print_weight(const weight& weight, std::ostream& o,
220  const std::string& format)
221  {
222  const auto& w = weight->as<WeightSet>();
223  return vcsn::print(w.weightset(), w.weight(), o, format);
224  }
225 
227  (const weight& aut, std::ostream& o,
228  const std::string& format) -> std::ostream&);
229  }
230  }
231 
232 }
233 
234 #endif // !VCSN_ALGOS_PRINT_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::ostream & list_polynomial(const polynomial &polynomial, std::ostream &o)
Bridge.
Definition: print.hh:126
std::ostream & print_polynomial(const polynomial &polynomial, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:148
std::ostream & print_ctx(const context &ctx, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:29
std::ostream & list(const PolynomialSet &ps, const typename PolynomialSet::value_t &p, std::ostream &o)
Definition: print.hh:106
std::ostream & print_weight(const weight &weight, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:219
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:82
std::shared_ptr< detail::ratexp_base > ratexp
Definition: fwd.hh:64
std::ostream & print_expansion(const expansion &expansion, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:63
std::ostream & print(const ValueSet &vs, const typename ValueSet::value_t &v, std::ostream &o, const std::string &format)
Applies to (ValueSet, Value, ostream, string): for expansionset, polynomialset, ratexpset, and weightset.
Definition: print.hh:51
std::shared_ptr< const detail::expansion_base > expansion
Definition: expansion.hh:74
std::ostream & print_ratexp(const ratexp &exp, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:184
std::ostream & print_label(const label &label, std::ostream &o, const std::string &format)
Bridge.
Definition: print.hh:86
std::shared_ptr< const detail::label_base > label
Definition: fwd.hh:46
std::shared_ptr< const detail::context_base > context
Definition: context.hh:71
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:55