Qore Programming Language  0.8.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNullNode.h
Go to the documentation of this file.
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreNullNode.h
4 
5  Qore Programming Language
6 
7  Copyright 2003 - 2013 David Nichols
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef _QORE_QORENULLNODE_H
25 
26 #define _QORE_QORENULLNODE_H
27 
28 #include <qore/AbstractQoreNode.h>
29 
34 
43 private:
45  DLLLOCAL virtual bool getAsBoolImpl() const;
46 
48  DLLLOCAL virtual int getAsIntImpl() const;
49 
51  DLLLOCAL virtual int64 getAsBigIntImpl() const;
52 
54  DLLLOCAL virtual double getAsFloatImpl() const;
55 
56 protected:
58 
61  DLLLOCAL AbstractQoreNode *evalImpl(class ExceptionSink *xsink) const;
62 
63 public:
64  DLLEXPORT QoreNullNode();
65 
66  DLLEXPORT virtual ~QoreNullNode();
67 
69 
75  DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
76 
78 
85  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
86 
88 
92  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
93 
95 
99  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
100 
102  DLLEXPORT virtual const char *getTypeName() const;
103 
105  DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
106 
108  DLLLOCAL static const char *getStaticTypeName() {
109  return "NULL";
110  }
111 
113  DLLLOCAL static qore_type_t getStaticTypeCode() {
114  return NT_NULL;
115  }
116 };
117 
119 static inline bool is_null(const AbstractQoreNode *n)
120 {
121  // this is faster than a dynamic_cast<const QoreNullNode *> operation
122  return n && n->getType() == NT_NULL;
123 }
124 
126 DLLEXPORT extern QoreNullNode Null;
127 
129 static inline QoreNullNode *null()
130 {
131  return &Null;
132 }
133 
134 #endif
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without type conversions (hard compare)
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with possible type conversion (soft compare)
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreNullNode.h:113
DLLLOCAL AbstractQoreNode * evalImpl(class ExceptionSink *xsink) const
should never be called for value types
DLLEXPORT QoreNullNode Null
the global and unique NULL value in Qore
static bool is_null(const AbstractQoreNode *n)
use this function to test for NULL
Definition: QoreNullNode.h:119
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNullNode.h:108
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
static QoreNullNode * null()
returns a pointer to Null
Definition: QoreNullNode.h:129
const qore_type_t NT_NULL
type value for QoreNullNode
Definition: node_types.h:40
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
virtual DLLEXPORT AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
should never be called for value types
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
this class is for value types that will exists only once in the Qore library, reference counting is d...
Definition: AbstractQoreNode.h:461
Qore&#39;s SQL &quot;NULL&quot; parse tree/value type, not-referenced counted, not dynamically allocated.
Definition: QoreNullNode.h:42
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:286
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate &quot;&lt;NULL&gt;&quot; to an existing QoreString