OpendTect-6_4  6.4
ascstream.h
Go to the documentation of this file.
1 #ifndef ascstream_h
2 #define ascstream_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H.Bril
9  Date: 2-5-1995
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "bufstring.h"
17 #include "plftypes.h"
18 #include "od_iostream.h"
19 
20 #define mAscStrmParagraphMarker "!"
21 #define mAscStrmKeyValSep ':'
22 
23 
33 {
34 
35 public:
36 
37  ascostream(od_ostream&);
38  ascostream(od_ostream*); // becomes mine
39  virtual ~ascostream();
40 
41  bool isOK() const;
42 
43  bool putHeader(const char* filetype);
44  bool put(const char*,const char* val=0);
45  bool put(const char*,const OD::String&);
46 
47 #define mAscStreamDefFns(fn,typ) \
48  bool fn(const char*,typ); \
49  bool fn(const char*,typ,typ); \
50  bool fn(const char*,typ,typ,typ); \
51  bool fn(const char*,typ,typ,typ,typ)
52  mAscStreamDefFns(put,int);
56  mAscStreamDefFns(put,float);
57  mAscStreamDefFns(put,double);
58  mAscStreamDefFns(putYN,bool);
59 #undef mAscStreamDefFns
60 
61  void newParagraph();
62 
63  inline od_ostream& stream() { return strm_; }
64 
65 protected:
66 
68  bool strmmine_;
69 
70  void putKeyword(const char*,bool wsep=true);
71 
72 };
73 
74 
84 {
85 public:
86  ascistream(od_istream&,bool rdhead=true);
87  ascistream(od_istream*,bool rdhead=true);
88  virtual ~ascistream();
89 
90  ascistream& next();
91  bool isOK() const;
92 
93  const char* headerStartLine() const { return header_.buf(); }
94  bool hasStandardHeader() const;
95  const char* fileType() const { return filetype_.buf(); }
96  bool isOfFileType(const char*) const;
97  const char* version() const;
98  const char* timeStamp() const { return timestamp_.buf(); }
99  int majorVersion() const;
100  int minorVersion() const;
101 
102  enum EntryType { Empty, Keyword, KeyVal, ParagraphMark, EndOfFile };
103  EntryType type() const;
104  bool atEOS() const { return type() > KeyVal; }
106 
107  const char* keyWord() const { return keybuf_.buf(); }
108  const char* value() const { return valbuf_.buf(); }
109  bool hasKeyword(const char*) const;
110  bool hasValue(const char*) const;
111  int getIValue(int i=0) const;
112  od_uint32 getUIValue(int i=0) const;
113  od_int64 getI64Value(int i=0) const;
114  od_uint64 getUI64Value(int i=0) const;
115  float getFValue(int i=0) const;
116  double getDValue(int i=0) const;
117  bool getYN(int i=0) const;
118 
119  inline od_istream& stream() { return strm_; }
120 
121  // This is for overriding what's in the file
122  void setKeyWord( const char* s ) { keybuf_ = s; }
123  void setValue( const char* s ) { valbuf_ = s; }
124 
125 protected:
126 
128  bool strmmine_;
131 
135 
136 private:
137 
138  void init(bool);
139 
140 };
141 
142 
143 inline bool atEndOfSection( const ascistream& strm )
144 { return strm.atEOS(); }
145 
146 
147 #endif
#define mExpClass(module)
Definition: commondefs.h:160
void setKeyWord(const char *s)
Definition: ascstream.h:122
bool atEOS() const
returns true if at end of segment (='paragraph')
Definition: ascstream.h:104
od_istream & stream()
Definition: ascstream.h:119
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
const char * keyWord() const
Definition: ascstream.h:107
void setValue(const char *s)
Definition: ascstream.h:123
#define od_int64
Definition: plftypes.h:36
OpendTect standard ascii format file writing.
Definition: ascstream.h:32
bool init()
BufferString header_
Definition: ascstream.h:132
OD class for stream read.
Definition: od_istream.h:24
od_ostream & stream()
Definition: ascstream.h:63
bool atEndOfSection(const ascistream &strm)
Definition: ascstream.h:143
#define od_uint32
Definition: plftypes.h:32
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
bool strmmine_
Definition: ascstream.h:128
bool strmmine_
Definition: ascstream.h:68
OpendTect standard ascii format file reading.
Definition: ascstream.h:83
BufferString valbuf_
Definition: ascstream.h:130
Definition: ascstream.h:102
#define od_uint64
Definition: plftypes.h:37
BufferString filetype_
Definition: ascstream.h:133
const char * fileType() const
Definition: ascstream.h:95
od_istream & strm_
Definition: ascstream.h:127
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
#define mAscStreamDefFns(fn, typ)
Definition: ascstream.h:47
const char * value() const
Definition: ascstream.h:108
od_ostream & strm_
Definition: ascstream.h:67
BufferString timestamp_
Definition: ascstream.h:134
EntryType
Definition: ascstream.h:102
const char * timeStamp() const
Definition: ascstream.h:98
BufferString keybuf_
Definition: ascstream.h:129
const char * headerStartLine() const
Definition: ascstream.h:93

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