Qore Programming Language  0.8.7
 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 
35 
43  protected:
45 
48  DLLLOCAL AbstractQoreNode *evalImpl(class ExceptionSink *xsink) const;
49 
50  public:
51  DLLEXPORT QoreNullNode();
52 
53  DLLEXPORT virtual ~QoreNullNode();
54 
56 
62  DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
63 
65 
72  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
73 
75 
79  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
80 
82 
86  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
87 
89  DLLEXPORT virtual const char *getTypeName() const;
90 
92  DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
93 
95  DLLLOCAL static const char *getStaticTypeName() {
96  return "NULL";
97  }
98 
100  DLLLOCAL static qore_type_t getStaticTypeCode() {
101  return NT_NULL;
102  }
103 };
104 
106 static inline bool is_null(const AbstractQoreNode *n)
107 {
108  // this is faster than a dynamic_cast<const QoreNullNode *> operation
109  return n && n->getType() == NT_NULL;
110 }
111 
113 DLLEXPORT extern QoreNullNode Null;
114 
116 static inline QoreNullNode *null()
117 {
118  return &Null;
119 }
120 
121 #endif