Qore Programming Language  0.8.11.1
QoreFloatNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreFloatNode.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2014 David Nichols
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QOREFLOATNODE_H
33 
34 #define _QORE_QOREFLOATNODE_H
35 
36 class LocalVar;
37 class QoreTypeInfo;
38 
41 private:
43  DLLLOCAL virtual bool getAsBoolImpl() const;
44 
46  DLLLOCAL virtual int getAsIntImpl() const;
47 
49  DLLLOCAL virtual int64 getAsBigIntImpl() const;
50 
52  DLLLOCAL virtual double getAsFloatImpl() const;
53 
54 protected:
56 
59  DLLEXPORT virtual ~QoreFloatNode();
60 
61 public:
63  double f;
64 
66 
69  DLLEXPORT QoreFloatNode(double n_f);
70 
72  DLLEXPORT QoreFloatNode();
73 
75 
80  DLLEXPORT virtual QoreString *getStringRepresentation(bool &del) const;
81 
83 
86  DLLEXPORT virtual void getStringRepresentation(QoreString &str) const;
87 
89 
95  DLLEXPORT virtual class DateTime *getDateTimeRepresentation(bool &del) const;
96 
98 
102  DLLEXPORT virtual void getDateTimeRepresentation(DateTime &dt) const;
103 
105 
111  DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
112 
114 
120  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
121 
123 
126  DLLEXPORT virtual class AbstractQoreNode *realCopy() const;
127 
129 
134  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
135 
137 
142  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
143 
145 
148  DLLEXPORT virtual const char *getTypeName() const;
149 
151  DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
152 
154 
157  DLLLOCAL static const char *getStaticTypeName() {
158  return "float";
159  }
160 
162  DLLLOCAL static qore_type_t getStaticTypeCode() {
163  return NT_FLOAT;
164  }
165 
167  DLLLOCAL static double getValue(AbstractQoreNode *v) {
168  return v->getAsFloat();
169  }
170 };
171 
172 #endif
virtual DLLEXPORT class DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this value and sets del to true
virtual DLLEXPORT ~QoreFloatNode()
the destructor is protected because it should not be called directly
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate the string representation of the floating-point value to an existing QoreString ...
DLLEXPORT QoreFloatNode()
creates a new floating-point value and assigns 0.0 to it
static DLLLOCAL double getValue(AbstractQoreNode *v)
returns the value of the argument (useful in templates)
Definition: QoreFloatNode.h:167
Qore's floating-point value type, dynamically-allocated only, reference counted.
Definition: QoreFloatNode.h:40
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
double f
the value of the type
Definition: QoreFloatNode.h:63
DLLEXPORT double getAsFloat() const
returns the float value of the object
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreFloatNode.h:162
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without type conversions (hard compare)
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:67
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:50
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreFloatNode.h:157
virtual DLLEXPORT class AbstractQoreNode * realCopy() const
returns a copy of the object; the caller owns the reference count
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
const qore_type_t NT_FLOAT
type value for QoreFloatNode
Definition: node_types.h:44
base class for simple value types
Definition: AbstractQoreNode.h:425
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with possible type conversion (soft compare)
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns the floating-point value converted to a string and sets del to true