Qore Programming Language  0.8.11.1
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 (C) 2003 - 2014 David Nichols
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QORENULLNODE_H
33 
34 #define _QORE_QORENULLNODE_H
35 
36 #include <qore/AbstractQoreNode.h>
37 
42 
51 private:
53  DLLLOCAL virtual bool getAsBoolImpl() const;
54 
56  DLLLOCAL virtual int getAsIntImpl() const;
57 
59  DLLLOCAL virtual int64 getAsBigIntImpl() const;
60 
62  DLLLOCAL virtual double getAsFloatImpl() const;
63 
64 protected:
66 
69  DLLLOCAL AbstractQoreNode *evalImpl(class ExceptionSink *xsink) const;
70 
71 public:
72  DLLEXPORT QoreNullNode();
73 
74  DLLEXPORT virtual ~QoreNullNode();
75 
77 
83  DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
84 
86 
93  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
94 
96 
100  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
101 
103 
107  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
108 
110  DLLEXPORT virtual const char *getTypeName() const;
111 
113  DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
114 
116  DLLLOCAL static const char *getStaticTypeName() {
117  return "NULL";
118  }
119 
121  DLLLOCAL static qore_type_t getStaticTypeCode() {
122  return NT_NULL;
123  }
124 };
125 
127 static inline bool is_null(const AbstractQoreNode *n)
128 {
129  // this is faster than a dynamic_cast<const QoreNullNode *> operation
130  return n && n->getType() == NT_NULL;
131 }
132 
134 DLLEXPORT extern QoreNullNode Null;
135 
137 static inline QoreNullNode *null()
138 {
139  return &Null;
140 }
141 
142 #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:121
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:127
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNullNode.h:116
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
static QoreNullNode * null()
returns a pointer to Null
Definition: QoreNullNode.h:137
const qore_type_t NT_NULL
type value for QoreNullNode
Definition: node_types.h:48
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:67
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:50
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:469
Qore's SQL "NULL" parse tree/value type, not-referenced counted, not dynamically allocated.
Definition: QoreNullNode.h:50
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:294
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate "" to an existing QoreString