All Classes Namespaces 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 (C) 2003 - 2015 David Nichols
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#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 const qore_type_t TYPE = 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:121
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:129
QoreNullNode::getStaticTypeName
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNullNode.h:116
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:54
null
static QoreNullNode * null()
returns a pointer to Null
Definition: QoreNullNode.h:139
NT_NULL
const qore_type_t NT_NULL
type value for QoreNullNode
Definition: node_types.h:48
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:82
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:478
QoreNullNode
Qore&#39;s SQL &quot;NULL&quot; parse tree/value type, not-referenced counted, not dynamically allocated.
Definition: QoreNullNode.h:50
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:47
int64
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:241
AbstractQoreNode::getType
DLLLOCAL qore_type_t getType() const
returns the data type
Definition: AbstractQoreNode.h:296
qore_type_t
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:71
QoreNullNode::getAsString
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate &quot;&lt;NULL&gt;&quot; to an existing QoreString