OpendTect  6.3
databuf.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: A.H.Bril
8  Date: 1-9-95
9 ________________________________________________________________________
10 
11 */
12 
13 #include "generalmod.h"
14 #include "bufstring.h"
15 
16 
20 {
21 public:
22 
23  typedef int size_type;
24  typedef int obj_size_type;
25  typedef unsigned char buf_type;
26 
27  DataBuffer(size_type nrelem,int bytsperelem=4,
28  bool setnull=false);
29  ~DataBuffer();
30  DataBuffer( const DataBuffer& b )
31  : nelem_(0), data_(0) { *this = b; }
32  DataBuffer& operator=(const DataBuffer&);
33 
34  inline bool isOk() const { return data_ ? true : false; }
35  inline bool isEmpty() const { return !data_ || !nelem_; }
36 
37  inline size_type size() const { return nelem_; }
38  inline obj_size_type bytesPerElement() const { return elembytes_; }
39  bool isZero() const;
40  inline od_int64 totalBytes() const
41  { return ((od_int64)nelem_)*elembytes_; }
42 
43  inline buf_type* data() { return data_; }
44  inline const buf_type* data() const { return data_; }
45 
46  void reSize(size_type,bool copydata=true);
47  void reByte(obj_size_type,bool copydata=true);
48  void zero();
49 
50  bool fitsInString() const;
51  BufferString getString() const;
52 
53 protected:
54 
55  size_type nelem_;
56  obj_size_type elembytes_;
57  buf_type* data_;
58 
59 };
#define mExpClass(module)
Definition: commondefs.h:157
int size_type
Definition: databuf.h:23
#define od_int64
Definition: plftypes.h:34
unsigned char buf_type
Definition: databuf.h:25
bool isOk() const
Definition: databuf.h:34
DataBuffer(const DataBuffer &b)
Definition: databuf.h:30
const buf_type * data() const
Definition: databuf.h:44
buf_type * data()
Definition: databuf.h:43
obj_size_type bytesPerElement() const
Definition: databuf.h:38
od_int64 totalBytes() const
Definition: databuf.h:40
Resizable buffer of elements.
Definition: databuf.h:19
bool isEmpty() const
Definition: databuf.h:35
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
size_type size() const
Definition: databuf.h:37
buf_type * data_
Definition: databuf.h:57
size_type nelem_
Definition: databuf.h:55
int obj_size_type
Definition: databuf.h:24
obj_size_type elembytes_
Definition: databuf.h:56

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