OpendTect-6_4  6.4
od_ostream.h
Go to the documentation of this file.
1 #ifndef od_ostream_h
2 #define od_ostream_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Sep 2013
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "od_stream.h"
17 
18 class SeparString;
19 class CompoundKey;
20 class FixedString;
21 class uiString;
22 
23 
27 {
28 public:
29 
31  od_ostream( const char* fnm, bool useexist=false )
32  : od_stream(fnm,true,useexist) {}
33  od_ostream( const FilePath& fp, bool useexist=false )
34  : od_stream(fp,true,useexist) {}
35  od_ostream( std::ostream* s )
36  : od_stream(s) {}
37  od_ostream( std::ostream& s )
38  : od_stream(s) {}
39  od_ostream( const od_ostream& s )
40  : od_stream(s) {}
42  { od_stream::operator =(s); return *this; }
43  bool open(const char*,bool useexist=false);
44 
45  od_ostream& add(char);
46  od_ostream& add(unsigned char);
47  od_ostream& add(const char*);
48  od_ostream& add(od_int16);
49  od_ostream& add(od_uint16);
50  od_ostream& add(od_int32);
51  od_ostream& add(od_uint32);
52  od_ostream& add(od_int64);
53  od_ostream& add(od_uint64);
54 #ifdef __lux64__
55  od_ostream& add(long long);
56  od_ostream& add(unsigned long long);
57 #else
58  od_ostream& add(long);
59  od_ostream& add(unsigned long);
60 #endif
61  //add clean numbers to the string, no 1.50000001 but 1.5
62  od_ostream& add(float);
63  od_ostream& add(double);
64 
65  //add precise numbers to the string, 1.50000001 is left as is.
66  od_ostream& addPrecise(float);
67  od_ostream& addPrecise(double);
68 
69  od_ostream& add(const OD::String&);
70  od_ostream& add(const uiString&);
71  od_ostream& add(const IOPar&);
72  od_ostream& add(const SeparString&);
73  od_ostream& add(const CompoundKey&);
74 
75  od_ostream& add(const void*);
76  od_ostream& addPtr(const void*);
77  od_ostream& add(od_istream&);
78  od_ostream& add( od_ostream& ) { return *this; }
79 
80  bool addBin(const void*,Count nrbytes);
81  template <class T>
82  od_ostream& addBin(const T&);
83 
84  std::ostream& stdStream();
85  void flush();
86 
87  static od_ostream& nullStream();
88  static od_ostream& logStream();
89 
90  inline void setWritePosition( Pos p, Ref r=Abs )
91  { setPosition( p, r ); }
92  inline Pos lastWrittenPosition() const
93  { return endPosition(); }
94 
95 };
96 
97 
99 inline mGlobal(Basic) od_ostream& od_cout() { return od_ostream::logStream(); }
100 
102 mGlobal(Basic) od_ostream& od_cerr();
103 
104 
105 
106 template <class T>
107 inline od_ostream& operator <<( od_ostream& s, const T& t )
108 { return s.add( t ); }
109 
110 
111 inline od_ostream& od_endl( od_ostream& strm )
112 {
113  strm.add( od_newline ).flush();
114  return strm;
115 }
116 
117 
118 mGlobal(Basic) std::ostream& od_endl( std::ostream& strm );
119 //Just to give linker errors
120 
121 
122 typedef od_ostream& (*od_ostreamFunction)(od_ostream&);
124 { return (*fn)( s ); }
125 
126 template <class T>
127 inline od_ostream& od_ostream::addBin( const T& t )
128 {
129  addBin( &t, sizeof(T) );
130  return *this;
131 }
132 
133 
134 #endif
#define mExpClass(module)
Definition: commondefs.h:160
od_ostream(const od_ostream &s)
Definition: od_ostream.h:39
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
od_ostream(std::ostream *s)
Definition: od_ostream.h:35
#define mGlobal(module)
Definition: commondefs.h:163
OD::String that holds an existing text string.
Definition: fixedstring.h:29
od_ostream(const char *fnm, bool useexist=false)
Definition: od_ostream.h:31
#define od_int64
Definition: plftypes.h:36
od_ostream & od_endl(od_ostream &strm)
Definition: od_ostream.h:111
bool addBin(const void *, Count nrbytes)
od_ostream & add(char)
List encoded in a string.
Definition: separstr.h:33
Definition: uistring.h:89
OD base class for stream read/write.
Definition: od_stream.h:53
od_ostream & od_cout()
Never redirected.
Definition: od_ostream.h:99
uiString & operator=(const uiString &)
no copy, ref counted
unsigned int Abs(unsigned int i)
Definition: math2.h:80
OD class for stream read.
Definition: od_istream.h:24
void flush()
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
#define od_uint32
Definition: plftypes.h:32
static od_ostream & logStream()
used by ErrMsg and UsrMsg
Pos lastWrittenPosition() const
Definition: od_ostream.h:92
void setWritePosition(Pos p, Ref r=Abs)
Definition: od_ostream.h:90
od_ostream(const FilePath &fp, bool useexist=false)
Definition: od_ostream.h:33
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
od_ostream & operator<<(od_ostream &s, const T &t)
Definition: od_ostream.h:107
od_stream_Count Count
Definition: od_stream.h:54
Position.
Definition: commontypes.h:42
od_ostream &(* od_ostreamFunction)(od_ostream &)
Definition: od_ostream.h:122
#define od_int16
Definition: plftypes.h:27
#define od_uint64
Definition: plftypes.h:37
File pathname tools.
Definition: filepath.h:34
#define od_int32
Definition: plftypes.h:31
Concatenated short keys separated by dots. Used for Object identifiers in the Object Manager...
Definition: compoundkey.h:23
od_ostream & od_cerr()
od_ostream()
Definition: od_ostream.h:30
od_ostream & add(od_ostream &)
Definition: od_ostream.h:78
#define od_uint16
Definition: plftypes.h:28
od_stream & operator=(const od_stream &)
Ref
Definition: od_stream.h:70
od_ostream(std::ostream &s)
Definition: od_ostream.h:37
#define od_newline
Definition: od_iosfwd.h:25

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019