Bayeux  3.4.1
Core Foundation library for SuperNEMO
ioutils.h
Go to the documentation of this file.
1 
3 #ifndef MYGSL_IOUTILS_H
4 #define MYGSL_IOUTILS_H 1
5 
6 // Standard library:
7 #include <iostream>
8 
9 namespace mygsl {
10 
11  template <class Type>
13  {
14  private:
15 
16  std::ostream & (*_function_) (std::ostream &, const Type & );
17 
18  Type _value_;
19 
20  public:
21  OstreamManipulator(std::ostream & (*function_) (std::ostream &,
22  const Type & ),
23  const Type & value_)
24  : _function_(function_),_value_(value_)
25  {
26  }
27 
28  friend std::ostream & operator<< (std::ostream & os_,
29  const OstreamManipulator & os_manip_)
30  {
31  return os_manip_._function_ (os_, os_manip_._value_);
32  }
33  };
34 
35  template <class Type>
37  {
38  private:
39 
40  std::istream & (*_function_) (std::istream &, Type &);
41 
42  Type & _value_;
43 
44  public:
45 
46  IstreamManipulatorRef (std::istream & (*function_) (std::istream &, Type &),
47  Type & value_)
48  : _function_ (function_), _value_ (value_)
49  {
50  }
51 
52  friend std::istream & operator>> (std::istream & is_,
53  const IstreamManipulatorRef & is_manip_)
54  {
55  return is_manip_._function_ (is_, is_manip_._value_);
56  }
57  };
58 
59 
60  std::ostream & ostream_odouble (std::ostream & os_, const double & x_);
61 
62  OstreamManipulator<double> odouble (const double & x_);
63 
64  std::istream & istream_idouble (std::istream & is_, double & x_);
65 
66  IstreamManipulatorRef<double> idouble (double & x_);
67 
68  class ioutils
69  {
70  public:
71 
72  static const std::string NAN_STRING;
73  static const std::string INF_POS_STRING;
74  static const std::string INF_NEG_STRING;
75 
76  };
77 
78 }
79 
80 #endif // MYGSL_IOUTILS_H
81 
82 /* Local Variables: */
83 /* mode: c++ */
84 /* coding: utf-8 */
85 /* End: */
IstreamManipulatorRef(std::istream &(*function_)(std::istream &, Type &), Type &value_)
Definition: ioutils.h:46
static const std::string INF_POS_STRING
Definition: ioutils.h:73
IstreamManipulatorRef< double > idouble(double &x_)
std::ostream & ostream_odouble(std::ostream &os_, const double &x_)
static const std::string NAN_STRING
Definition: ioutils.h:72
Definition: ioutils.h:36
friend std::ostream & operator<<(std::ostream &os_, const OstreamManipulator &os_manip_)
Definition: ioutils.h:28
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
friend std::istream & operator>>(std::istream &is_, const IstreamManipulatorRef &is_manip_)
Definition: ioutils.h:52
Definition: ioutils.h:12
Definition: ioutils.h:68
static const std::string INF_NEG_STRING
Definition: ioutils.h:74
OstreamManipulator< double > odouble(const double &x_)
std::istream & istream_idouble(std::istream &is_, double &x_)
OstreamManipulator(std::ostream &(*function_)(std::ostream &, const Type &), const Type &value_)
Definition: ioutils.h:21