32#ifndef _QORE_QORENUMBERNODE_H
34#define _QORE_QORENUMBERNODE_H
43#define QORE_NF_DEFAULT 0
45#define QORE_NF_SCIENTIFIC (1 << 0)
47#define QORE_NF_RAW (1 << 1)
52 friend hashdecl qore_number_private;
56 DLLLOCAL
virtual bool getAsBoolImpl()
const;
59 DLLLOCAL
virtual int getAsIntImpl()
const;
62 DLLLOCAL
virtual int64 getAsBigIntImpl()
const;
65 DLLLOCAL
virtual double getAsFloatImpl()
const;
69 hashdecl qore_number_private*
priv;
276 DLLEXPORT
bool nan()
const;
279 DLLEXPORT
bool inf()
const;
317 DLLLOCAL
void*
operator new(size_t);
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
manages conversions of a QoreValue to a QoreNumberNode
Definition: QoreNumberNode.h:310
DLLEXPORT QoreNumberNode * getReferencedValue()
returns a referenced value and leaves the current object empty; the caller will own the reference
DLLLOCAL bool is_temp() const
returns true if the referenced being managed is temporary
Definition: QoreNumberNode.h:346
DLLLOCAL ~QoreNumberNodeHelper()
destroys the object and dereferences the pointer being managed if it was a temporary object
DLLLOCAL QoreNumberNodeHelper(const QoreValue n)
converts the argument to a QoreNumberNode if necessary
DLLLOCAL const QoreNumberNode * operator*()
returns the object being managed
Definition: QoreNumberNode.h:336
DLLLOCAL const QoreNumberNode * operator->()
returns the object being managed
Definition: QoreNumberNode.h:330
Qore's arbitrary-precision number value type, dynamically-allocated only, reference counted.
Definition: QoreNumberNode.h:51
static DLLEXPORT QoreNumberNode * toNumber(const QoreValue v)
returns the representation of the value as a number if possible (otherwise returns 0),...
DLLEXPORT QoreNumberNode * negate() const
returns the negative of the current object (this)
DLLEXPORT bool lessThanOrEqual(double n) const
returns true if the current object is less than or equal to the argument
DLLEXPORT QoreNumberNode(int64 i)
creates a new number value and assigns the initial value to it
virtual DLLEXPORT class DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this value and sets del to true
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without type conversions (hard compare)
DLLEXPORT int sign() const
returns -1 if the number is negative, 0 if zero, or 1 if the number is positive
DLLEXPORT bool lessThanOrEqual(int64 n) const
returns true if the current object is less than or equal to the argument
DLLEXPORT QoreNumberNode * numberRefSelf() const
returns a pointer to this with the reference count incremented
DLLEXPORT bool greaterThan(int64 n) const
returns true if the current object is greater than the argument
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns a copy of the object; the caller owns the reference count
virtual DLLLOCAL int parseInit(QoreValue &val, QoreParseContext &parse_context)
returns the type information
hashdecl qore_number_private * priv
the private implementation of the type
Definition: QoreNumberNode.h:69
DLLEXPORT bool equals(const QoreNumberNode &n) const
returns true if the current object is equal to the argument
DLLEXPORT QoreNumberNode * doMinus(const QoreNumberNode &n) const
subtract the argument from this value and return the result
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreNumberNode.h:302
DLLEXPORT bool greaterThanOrEqual(const QoreNumberNode &n) const
returns true if the current object is greater than or equal to the argument
DLLEXPORT bool lessThan(int64 n) const
returns true if the current object is less than the argument
DLLEXPORT QoreNumberNode * doDivideBy(double d, ExceptionSink *xsink) const
divide this value by the argument return the result (can throw a division-by-zero exception)
DLLEXPORT bool inf() const
returns true if the number is +/-inf
static DLLEXPORT QoreNumberNode * toNumber(const AbstractQoreNode *v)
returns the representation of the value as a number if possible (otherwise returns 0),...
DLLEXPORT QoreNumberNode * doMultiply(const QoreNumberNode &n) const
multiply the argument to this value and return the result
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
DLLEXPORT bool ordinary() const
returns true if the number is an ordinary number (neither NaN nor an infinity)
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns the number value converted to a string and sets del to true
DLLEXPORT QoreNumberNode(const char *str)
creates a new number value and assigns the initial value to it
DLLEXPORT void toString(QoreString &str, int fmt=QORE_NF_DEFAULT) const
concatenates the string value corresponding to the number to the string given
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate the string representation of the number value to an existing QoreString
DLLEXPORT QoreNumberNode * doDivideBy(int64 i, ExceptionSink *xsink) const
divide this value by the argument return the result (can throw a division-by-zero exception)
DLLEXPORT QoreNumberNode * doDivideBy(const QoreNumberNode &n, ExceptionSink *xsink) const
divide this value by the argument return the result (can throw a division-by-zero exception)
DLLEXPORT unsigned getPrec() const
returns the precision of the number
virtual DLLEXPORT void getDateTimeRepresentation(DateTime &dt) const
assigns the date representation of the value to the DateTime reference passed
DLLEXPORT bool greaterThanOrEqual(double n) const
returns true if the current object is greater than or equal to the argument
DLLEXPORT bool equals(int64 n) const
returns true if the current object is equal to the argument
DLLEXPORT bool lessThan(double n) const
returns true if the current object is less than the argument
DLLEXPORT bool lessThan(const QoreNumberNode &n) const
returns true if the current object is less than the argument
DLLEXPORT bool greaterThan(double n) const
returns true if the current object is greater than the argument
DLLEXPORT bool greaterThanOrEqual(int64 n) const
returns true if the current object is greater than or equal to the argument
DLLEXPORT bool nan() const
returns true if the number is NaN
DLLEXPORT QoreNumberNode()
creates a new numbering-point value and assigns it to 0
DLLEXPORT bool zero() const
returns true if the number is zero
virtual DLLEXPORT QoreString * getAsString(bool &del, int foff, class ExceptionSink *xsink) const
returns a QoreString giving the string representation of the number value, sets del to true
DLLEXPORT bool equals(double n) const
returns true if the current object is equal to the argument
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNumberNode.h:297
DLLEXPORT bool greaterThan(const QoreNumberNode &n) const
returns true if the current object is greater than the argument
DLLEXPORT QoreNumberNode(const QoreNumberNode &old)
creates a copy of the object
DLLEXPORT QoreNumberNode * doPlus(const QoreNumberNode &n) const
add the argument to this value and return the result
virtual DLLEXPORT ~QoreNumberNode()
the destructor is protected because it should not be called directly
virtual DLLEXPORT void getStringRepresentation(QoreString &str) const
concatentates the number value to an existing QoreString reference, default implementation does nothi...
DLLEXPORT QoreNumberNode(const char *str, unsigned prec)
creates a new number value and assigns the initial value to it
DLLEXPORT QoreNumberNode(const QoreValue n)
creates a new number value from the node, if not possible then the new number will be assigned 0
DLLEXPORT bool lessThanOrEqual(const QoreNumberNode &n) const
returns true if the current object is less than or equal to the argument
DLLEXPORT QoreNumberNode(double f)
creates a new number value and assigns the initial value to it
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with possible type conversion (soft compare)
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
base class for simple value types
Definition: AbstractQoreNode.h:372
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
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:260
const qore_type_t NT_NUMBER
type value for QoreNumberNode
Definition: node_types.h:53
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:276