All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNullNode.h
Go to the documentation of this file.
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreNullNode.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_QORENULLNODE_H
#define _QORE_QORENULLNODE_H
#include <qore/AbstractQoreNode.h>
class QoreNullNode : public UniqueValueQoreNode {
private:
DLLLOCAL virtual bool getAsBoolImpl() const;
DLLLOCAL virtual int getAsIntImpl() const;
DLLLOCAL virtual int64 getAsBigIntImpl() const;
DLLLOCAL virtual double getAsFloatImpl() const;
protected:
using SimpleValueQoreNode::evalImpl;
DLLLOCAL AbstractQoreNode *evalImpl(class ExceptionSink *xsink) const;
public:
DLLEXPORT QoreNullNode();
DLLEXPORT virtual ~QoreNullNode();
DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLEXPORT virtual const char *getTypeName() const;
DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
DLLLOCAL static const char *getStaticTypeName() {
return "NULL";
}
DLLLOCAL static qore_type_t getStaticTypeCode() {
return NT_NULL;
}
};
static inline bool is_null(const AbstractQoreNode *n)
{
// this is faster than a dynamic_cast<const QoreNullNode *> operation
return n && n->getType() == NT_NULL;
}
DLLEXPORT extern QoreNullNode Null;
static inline QoreNullNode *null()
{
return &Null;
}
#endif
QoreNullNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without type conversions (hard compare)
QoreNullNode::is_equal_soft
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with possible type conversion (soft compare)
QoreNullNode::getTypeName
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
QoreNullNode::getStaticTypeCode
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreNullNode.h:113
QoreNullNode::evalImpl
DLLLOCAL AbstractQoreNode * evalImpl(class ExceptionSink *xsink) const
should never be called for value types
Null
DLLEXPORT QoreNullNode Null
the global and unique NULL value in Qore
is_null
static bool is_null(const AbstractQoreNode *n)
use this function to test for NULL
Definition: QoreNullNode.h:119
QoreNullNode::getStaticTypeName
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNullNode.h:108
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
null
static QoreNullNode * null()
returns a pointer to Null
Definition: QoreNullNode.h:129
NT_NULL
const qore_type_t NT_NULL
type value for QoreNullNode
Definition: node_types.h:40
qore_type_t
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
SimpleValueQoreNode::evalImpl
virtual DLLEXPORT AbstractQoreNode * evalImpl(ExceptionSink *xsink) const
should never be called for value types
QoreNullNode::parseInit
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
UniqueValueQoreNode
this class is for value types that will exists only once in the Qore library, reference counting is d...
Definition: AbstractQoreNode.h:461
QoreNullNode
Qore&#39;s SQL &quot;NULL&quot; parse tree/value type, not-referenced counted, not dynamically allocated.
Definition: QoreNullNode.h:42
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
AbstractQoreNode::getType
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:286
QoreNullNode::getAsString
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate &quot;&lt;NULL&gt;&quot; to an existing QoreString