OpendTect  6.3
fixedstring.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 ________________________________________________________________________
4 
5  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
6  Author: Kristofer
7  Date: April 2009
8 ________________________________________________________________________
9 
10 */
11 
12 #include "basicmod.h"
13 #include "odstring.h"
14 
15 
16 
27 mExpClass(Basic) FixedString : public OD::String
28 {
29 public:
30 
31  inline FixedString( const char* p = 0 )
32  : str_(p) {}
33  inline FixedString& operator=( const FixedString& fs )
34  { str_ = fs.str_; return *this;}
35  inline FixedString& operator=( const char* p )
36  { str_ = p; return *this; }
37  FixedString& operator=(const OD::String&) = delete;
39  inline operator const char*() const { return buf(); }
40 
41  inline bool operator==( const FixedString& fs ) const
42  { return isEqual(fs.str_);}
43  inline bool operator!=( const FixedString& fs ) const
44  { return !isEqual(fs.str_);}
45  inline bool operator==( const char* s ) const
46  { return isEqual(s);}
47  inline bool operator!=( const char* s ) const
48  { return !isEqual(s);}
49  inline bool operator==( const OD::String& s ) const
50  { return isEqual(s.str()); }
51  inline bool operator!=( const OD::String& s ) const
52  { return !isEqual(s.str()); }
53  bool operator==(const BufferString&) const;
54  bool operator!=(const BufferString&) const;
55 
56  inline operator bool() const { return !isNull(); }
57  inline bool operator !() const { return isNull(); }
58  inline bool isNull() const { return !str_; }
59  inline char firstChar() const { return str_ ? *str_ : '\0'; }
60 
61  static const FixedString& empty();
62 
63 
64 protected:
65 
66  inline const char* gtBuf() const { return str_ ? str_ : ""; }
67  inline const char* gtStr() const { return !str_ || !*str_ ? 0 : str_; }
68 
69  const char* str_;
70 
71 };
72 
73 
74 namespace Values
75 {
76 
77 template<>
79 {
80 public:
81 
82  static FixedString val() { return FixedString();}
83  static bool hasUdf() { return true; }
84  static bool isUdf( const FixedString& s ) { return s.isEmpty(); }
85  static void setUdf( FixedString& s ) { s = FixedString(); }
86 
87 };
88 
89 }
#define mExpClass(module)
Definition: commondefs.h:157
FixedString & operator=(const char *p)
Definition: fixedstring.h:35
const char * gtBuf() const
Definition: fixedstring.h:66
const char * str() const
Definition: odstring.h:46
static void setUdf(FixedString &s)
Definition: fixedstring.h:85
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
Templatized undefined and initialisation (i.e. null) values.
Definition: color.h:113
OD::String that holds an existing text string.
Definition: fixedstring.h:27
static bool isUdf(const FixedString &s)
Definition: fixedstring.h:84
static FixedString val()
Definition: fixedstring.h:82
static bool hasUdf()
Definition: fixedstring.h:83
const char * str_
Definition: fixedstring.h:69
bool isNull() const
Definition: fixedstring.h:58
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
char firstChar() const
Definition: fixedstring.h:59
bool operator!=(const FixedString &fs) const
Definition: fixedstring.h:43
const char * gtStr() const
Definition: fixedstring.h:67
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
bool operator==(const FixedString &fs) const
Definition: fixedstring.h:41
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
bool isEmpty() const
Definition: odstring.h:49
bool operator!=(const OD::String &s) const
Definition: fixedstring.h:51
OpendTect.
Definition: commontypes.h:25
bool operator==(const OD::String &s) const
Definition: fixedstring.h:49
#define mClass(module)
Definition: commondefs.h:161
FixedString(const char *p=0)
Definition: fixedstring.h:31
FixedString & operator=(const FixedString &fs)
Definition: fixedstring.h:33
bool operator==(const char *s) const
Definition: fixedstring.h:45
Templatized undefined values.
Definition: undefval.h:49
bool operator!=(const char *s) const
Definition: fixedstring.h:47

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