OpendTect  6.6
od_istream.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Sep 2013
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "basicmod.h"
15 #include "od_stream.h"
16 class SeparString;
17 class CompoundKey;
18 class FixedString;
19 
20 
24 {
25 public:
26 
28  od_istream( const char* fnm )
29  : od_stream(fnm,false) {}
30  od_istream( const FilePath& fp )
31  : od_stream(fp,false) {}
33  const char* workdir=nullptr )
34  : od_stream(mc,workdir,false) {}
35  od_istream( std::istream* s )
36  : od_stream(s) {}
37  od_istream( std::istream& s )
38  : od_stream(s) {}
39 
40  od_istream(const od_istream&) = delete;
42  od_istream& operator=(const od_istream&) = delete;
44 
45  bool open(const char*);
46  bool reOpen();
47 
48  od_istream& get(char&);
49  /*<!Use this function to get regular text inputs.
50  If you want to analyse an alien stream char-by-char,
51  use peek()-ignore(1) call pairs.*/
52 
53  od_istream& get(unsigned char&);
60 #ifdef __lux64__
61  od_istream& get(long long&);
62  od_istream& get(unsigned long long&);
63 #else
64  od_istream& get(long&);
65  od_istream& get(unsigned long&);
66 #endif
67  od_istream& get(float&);
68  od_istream& get(double&);
69 
70  od_istream& get( BufferString& bs, bool allowgotonextline=true )
71  { getWord(bs,allowgotonextline); return *this; }
72 
76 
77  od_istream& getC(char*,int sz,int maxnrchar);
78  mDeprecated("Provide the size of the write buffer")
79  od_istream& getC(char*,int maxnrchar);
81  od_istream& get(char*);
85  od_istream& get(void*);
86 
87  bool getWord(BufferString&,bool allowgotonextline=true);
88  bool getLine(BufferString&,bool* newline_found=0);
89  bool getAll(BufferString&);
90 
91  bool getBin(void*,Count nrbytes);
92  template <class T>
93  od_istream& getBin(T&);
94 
95  char peek() const;
96  void ignore(Count);
97  bool skipUntil(char);
98  bool skipWord();
99  bool skipLine();
100  void setReadPosition(Pos,Ref r=Abs);
101  Pos endPosition() const;
102 
104  std::istream& stdStream();
105  bool atEOF() const;
108 
109  static od_istream& nullStream();
110 
111 };
112 
113 
114 
117 
118 
119 template <class T> inline od_istream& operator >>( od_istream& s, T& t )
120 { return s.get( t ); }
121 
122 template <class T>
124 {
125  getBin( &t, sizeof(T) );
126  return *this;
127 }
128 
129 
od_uint64
#define od_uint64
Definition: plftypes.h:36
od_istream::reOpen
bool reOpen()
od_istream::getBin
bool getBin(void *, Count nrbytes)
od_istream::od_istream
od_istream(std::istream &s)
Definition: od_istream.h:37
Pos
Position.
Definition: commontypes.h:78
mGlobal
#define mGlobal(module)
Definition: commondefs.h:180
od_istream::get
od_istream & get(float &)
od_stream::Count
od_stream_Count Count
Definition: od_stream.h:56
od_int64
#define od_int64
Definition: plftypes.h:35
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
od_istream
OD class for stream read common access to the std::cin.
Definition: od_istream.h:24
FilePath
File pathname tools.
Definition: filepath.h:34
StrmOper::lastNrBytesRead
int64_t lastNrBytesRead(std::istream &)
od_istream::get
od_istream & get(SeparString &)
od_stream::Ref
Ref
Definition: od_stream.h:73
od_istream::get
od_istream & get(unsigned int &)
Math::Abs
unsigned int Abs(unsigned int i)
Definition: math2.h:79
od_cin
od_istream & od_cin()
od_istream::od_istream
od_istream(const char *fnm)
Definition: od_istream.h:28
od_istream::get
od_istream & get(CompoundKey &)
od_istream::get
od_istream & get(double &)
od_stream.h
od_istream::od_istream
od_istream(const FilePath &fp)
Definition: od_istream.h:30
od_istream::get
od_istream & get(short &)
od_istream::od_istream
od_istream()
Definition: od_istream.h:27
od_istream::get
od_istream & get(unsigned char &)
od_istream::getC
od_istream & getC(char *, int sz, int maxnrchar)
mDeprecated
#define mDeprecated(msg)
Definition: plfdefs.h:215
od_int16
#define od_int16
Definition: plftypes.h:26
od_istream::get
od_istream & get(BufferString &bs, bool allowgotonextline=true)
Definition: od_istream.h:70
SeparString
Definition: separstr.h:136
FixedString
OD::String that holds an existing text string.
Definition: fixedstring.h:29
od_istream::od_istream
od_istream(od_istream &&)
od_istream::get
od_istream & get(unsigned long &)
od_uint16
#define od_uint16
Definition: plftypes.h:27
od_stream
OD base class for stream read/write.
Definition: od_stream.h:56
od_istream::get
od_istream & get(long &)
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
od_istream::get
od_istream & get(int64_t &)
od_istream::get
od_istream & get(IOPar &)
od_int32
#define od_int32
Definition: plftypes.h:30
std
Definition: fixedstreambuf.h:20
OS::MachineCommand
Encapsulates an actual command to execute + the machine to run it on.
Definition: oscommand.h:94
od_istream::get
od_istream & get(uint64_t &)
od_istream::get
od_istream & get(unsigned short &)
od_istream::operator=
od_istream & operator=(const od_istream &)=delete
od_istream::get
od_istream & get(int &)
CompoundKey
Concatenated short keys separated by dots. Used for Object identifiers in the Object Manager,...
Definition: compoundkey.h:23
od_istream::od_istream
od_istream(std::istream *s)
Definition: od_istream.h:35
od_istream::operator=
od_istream & operator=(od_istream &&)
mDeprecatedDef
#define mDeprecatedDef
Definition: plfdefs.h:216
od_uint32
#define od_uint32
Definition: plftypes.h:31
od_istream::od_istream
od_istream(const od_istream &)=delete
od_istream::get
od_istream & get(char &)
od_istream::od_istream
od_istream(const OS::MachineCommand &mc, const char *workdir=nullptr)
Definition: od_istream.h:32
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
od_istream::open
bool open(const char *)

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