rheolef  7.0
catchmark.h
Go to the documentation of this file.
1 # ifndef _RHEO_CATCHMARK_H
2 # define _RHEO_CATCHMARK_H
3 #include "rheolef/iorheo.h"
4 #include "rheolef/rheostream.h"
5 
6 namespace rheolef {
7 #ifdef TO_CLEAN
8 bool scatch (std::istream& in, const std::string& ch, bool full_match=true);
9 #endif // TO_CLEAN
10 
30 class catchmark {
31  public:
32  catchmark(const std::string& x);
33  const std::string& mark() const { return _mark; }
34  friend std::istream& operator >> (std::istream& is, const catchmark& m);
35  friend std::ostream& operator << (std::ostream& os, const catchmark& m);
36  protected:
37  std::string _mark;
38 };
39 @endcode
40 
41 inline
42 catchmark::catchmark(const std::string& x)
43 : _mark(x)
44 {
45 }
46 inline
47 std::istream&
48 operator >> (std::istream& is, const catchmark& m)
49 {
50  is >> setmark(m._mark);
51  std::string label = "#"+m._mark;
52  if (!scatch(is,label)) {
53  warning_macro ("catchmark: label `"<< label <<"' not found on input");
54  }
55  return is;
56 }
57 inline
58 std::ostream&
59 operator << (std::ostream& os, const catchmark& m)
60 {
61  os << setmark(m._mark);
62  os << "#" << m._mark << std::endl;
63  return os;
64 }
65 }// namespace rheolef
66 # endif // _RHEO_CATCHMARK_H
irheostream, orheostream - large data streams
Definition: compiler.h:7
#define warning_macro(message)
Definition: compiler.h:102
friend std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:59
friend std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:48
const std::string & mark() const
Definition: catchmark.h:33
bool scatch(std::istream &in, const std::string &ch, bool full_match=true)
catchmark - iostream manipulator
Definition: catchmark.h:30
std::string _mark
Definition: catchmark.h:37
catchmark(const std::string &x)
Definition: catchmark.h:42