Qore Programming Language: include/qore/QoreBoolNode.h (6585) Source File

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreBoolNode.h
Go to the documentation of this file.
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 QoreBoolNode.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_QOREBOOLNODE_H
25
26 #define _QORE_QOREBOOLNODE_H
27
28 #include <qore/AbstractQoreNode.h>
29
34
37 class QoreBoolNode : public UniqueValueQoreNode {
38 private:
40 DLLLOCAL virtual bool getAsBoolImpl() const;
41
43 DLLLOCAL virtual int getAsIntImpl() const;
44
46 DLLLOCAL virtual int64 getAsBigIntImpl() const;
47
49 DLLLOCAL virtual double getAsFloatImpl() const;
50
51 protected:
53 bool b;
54
56 DLLLOCAL QoreBoolNode(bool n_b);
57
58 public:
59 DLLEXPORT virtual ~QoreBoolNode();
60
61 // get the value of the type in a string context (default implementation = del = false and returns NullString)
62 // if del is true, then the returned QoreString * should be deleted, if false, then it must not be
63 // use the QoreStringValueHelper class (defined in QoreStringNode.h) instead of using this function directly
64 DLLEXPORT virtual QoreString *getStringRepresentation(bool &del) const;
65
66 // concatenate string representation to a QoreString (no action for complex types = default implementation)
67 DLLEXPORT virtual void getStringRepresentation(QoreString &str) const;
68
69 // if del is true, then the returned DateTime * should be deleted, if false, then it should not
70 DLLEXPORT virtual DateTime *getDateTimeRepresentation(bool &del) const;
71
72 // assign date representation to a DateTime (no action for complex types = default implementation)
73 DLLEXPORT virtual void getDateTimeRepresentation(DateTime &dt) const;
74
75 // get string representation (for %n and %N), foff is for multi-line formatting offset, -1 = no line breaks
76 // the ExceptionSink is only needed for QoreObject where a method may be executed
77 // use the QoreNodeAsStringHelper class (defined in QoreStringNode.h) instead of using these functions directly
78 // returns -1 for exception raised, 0 = OK
79 DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
80
81 // if del is true, then the returned QoreString * should be deleted, if false, then it must not be
82 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
83
84 // the type passed must always be equal to the current type
85 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
86 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
87
88 // returns the type name as a c string
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 bool getValue() const {
96 return b;
97 }
98
100 DLLLOCAL static const char *getStaticTypeName() {
101 return "bool";
102 }
103
105 DLLLOCAL static qore_type_t getStaticTypeCode() {
106 return NT_BOOLEAN;
107 }
108
110 DLLLOCAL static bool getValue(QoreBoolNode *v) {
111 return v->b;
112 }
113 };
114
116
119 class QoreBoolTrueNode : public QoreBoolNode {
120 public:
121 DLLLOCAL QoreBoolTrueNode();
122 };
123
125
128 class QoreBoolFalseNode : public QoreBoolNode {
129 public:
130 DLLLOCAL QoreBoolFalseNode();
131 };
132
134 DLLEXPORT extern QoreBoolFalseNode False;
135
137 DLLEXPORT extern QoreBoolTrueNode True;
138
140 static inline QoreBoolNode *get_bool_node(bool v) {
141 return v ? (QoreBoolNode *)&True : (QoreBoolNode *)&False;
142 }
143
144 #endif
QoreBoolNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality ("deep compare" including all contained values for container types) without type c...
False
DLLEXPORT QoreBoolFalseNode False
Qore'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's boolean "true" 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's 2 boolean classes: QoreBoolTrueNode and QoreBoolFalseNode
Definition: QoreBoolNode.h:37
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:42
True
DLLEXPORT QoreBoolTrueNode True
Qore'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's boolean "false" 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 "thread_exit" 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 ("deep compare" 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...