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

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