All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreBoolNode.h
Go to the documentation of this file.
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreBoolNode.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_QOREBOOLNODE_H
#define _QORE_QOREBOOLNODE_H
#include <qore/AbstractQoreNode.h>
class QoreBoolNode : public UniqueValueQoreNode {
private:
DLLLOCAL virtual bool getAsBoolImpl() const;
DLLLOCAL virtual int getAsIntImpl() const;
DLLLOCAL virtual int64 getAsBigIntImpl() const;
DLLLOCAL virtual double getAsFloatImpl() const;
protected:
bool b;
DLLLOCAL QoreBoolNode(bool n_b);
public:
DLLEXPORT virtual ~QoreBoolNode();
// get the value of the type in a string context (default implementation = del = false and returns NullString)
// if del is true, then the returned QoreString * should be deleted, if false, then it must not be
// use the QoreStringValueHelper class (defined in QoreStringNode.h) instead of using this function directly
DLLEXPORT virtual QoreString *getStringRepresentation(bool &del) const;
// concatenate string representation to a QoreString (no action for complex types = default implementation)
DLLEXPORT virtual void getStringRepresentation(QoreString &str) const;
// if del is true, then the returned DateTime * should be deleted, if false, then it should not
DLLEXPORT virtual DateTime *getDateTimeRepresentation(bool &del) const;
// assign date representation to a DateTime (no action for complex types = default implementation)
DLLEXPORT virtual void getDateTimeRepresentation(DateTime &dt) const;
// get string representation (for %n and %N), foff is for multi-line formatting offset, -1 = no line breaks
// the ExceptionSink is only needed for QoreObject where a method may be executed
// use the QoreNodeAsStringHelper class (defined in QoreStringNode.h) instead of using these functions directly
// returns -1 for exception raised, 0 = OK
DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
// if del is true, then the returned QoreString * should be deleted, if false, then it must not be
DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
// the type passed must always be equal to the current type
DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
// returns the type name as a c string
DLLEXPORT virtual const char *getTypeName() const;
DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
DLLLOCAL bool getValue() const {
return b;
}
DLLLOCAL static const char *getStaticTypeName() {
return "bool";
}
DLLLOCAL static qore_type_t getStaticTypeCode() {
return NT_BOOLEAN;
}
DLLLOCAL static bool getValue(QoreBoolNode *v) {
return v->b;
}
};
class QoreBoolTrueNode : public QoreBoolNode {
public:
DLLLOCAL QoreBoolTrueNode();
};
class QoreBoolFalseNode : public QoreBoolNode {
public:
DLLLOCAL QoreBoolFalseNode();
};
DLLEXPORT extern QoreBoolFalseNode False;
DLLEXPORT extern QoreBoolTrueNode True;
static inline QoreBoolNode *get_bool_node(bool v) {
return v ? (QoreBoolNode *)&True : (QoreBoolNode *)&False;
}
#endif
QoreBoolNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality (&quot;deep compare&quot; including all contained values for container types) without type c...
False
DLLEXPORT QoreBoolFalseNode False
Qore&#39;s boolean false value.
DateTime
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:85
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreBoolNode::getStaticTypeName
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreBoolNode.h:100
QoreBoolTrueNode
Qore&#39;s boolean &quot;true&quot; node, unique, not dynamically-allocated, not reference-counted.
Definition: QoreBoolNode.h:119
QoreBoolNode::b
bool b
boolean value for the object
Definition: QoreBoolNode.h:53
QoreBoolNode::getAsString
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate the verbose string representation of the value (including all contained values for contai...
QoreBoolNode::QoreBoolNode
DLLLOCAL QoreBoolNode(bool n_b)
the constructor can only be called by a subclass
qore_type_t
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
get_bool_node
static QoreBoolNode * get_bool_node(bool v)
a little inline helper function for getting a boolean node
Definition: QoreBoolNode.h:140
QoreBoolNode
base class for Qore&#39;s 2 boolean classes: QoreBoolTrueNode and QoreBoolFalseNode
Definition: QoreBoolNode.h:37
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
True
DLLEXPORT QoreBoolTrueNode True
Qore&#39;s boolean true value.
UniqueValueQoreNode
this class is for value types that will exists only once in the Qore library, reference counting is d...
Definition: AbstractQoreNode.h:461
QoreBoolNode::getTypeName
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
QoreBoolNode::getValue
DLLLOCAL bool getValue() const
returns the boolean value of the object
Definition: QoreBoolNode.h:95
QoreBoolNode::getDateTimeRepresentation
virtual DLLEXPORT DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this type (default implementation: returns ZeroDate...
QoreBoolFalseNode
Qore&#39;s boolean &quot;false&quot; node, unique, not dynamically-allocated, not reference-counted.
Definition: QoreBoolNode.h:128
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
QoreBoolNode::parseInit
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
QoreBoolNode::is_equal_soft
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality (&quot;deep compare&quot; including all contained values for container types) with possible ...
NT_BOOLEAN
const qore_type_t NT_BOOLEAN
type value for QoreBoolNode
Definition: node_types.h:39
QoreBoolNode::getValue
static DLLLOCAL bool getValue(QoreBoolNode *v)
returns the value of the argument (useful in templates)
Definition: QoreBoolNode.h:110
QoreBoolNode::getStaticTypeCode
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreBoolNode.h:105
QoreBoolNode::getStringRepresentation
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns the value of the type converted to a string, default implementation: returns the empty string...