Qore Programming Language
0.8.7
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
qore
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
35
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