All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNumberNode.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreNumberNode.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_QORENUMBERNODE_H
#define _QORE_QORENUMBERNODE_H
class LocalVar;
class QoreTypeInfo;
#define QORE_NF_DEFAULT 0
#define QORE_NF_SCIENTIFIC (1 << 0)
#define QORE_NF_RAW (1 << 1)
class QoreNumberNode : public SimpleValueQoreNode {
friend struct qore_number_private;
private:
DLLLOCAL virtual bool getAsBoolImpl() const;
DLLLOCAL virtual int getAsIntImpl() const;
DLLLOCAL virtual int64 getAsBigIntImpl() const;
DLLLOCAL virtual double getAsFloatImpl() const;
protected:
struct qore_number_private* priv;
DLLEXPORT virtual ~QoreNumberNode();
// private
DLLLOCAL QoreNumberNode(struct qore_number_private* p);
public:
DLLEXPORT QoreNumberNode(const AbstractQoreNode* n);
DLLEXPORT QoreNumberNode(double f);
DLLEXPORT QoreNumberNode(int64 i);
DLLEXPORT QoreNumberNode(const char* str);
DLLEXPORT QoreNumberNode(const char* str, unsigned prec);
DLLEXPORT QoreNumberNode();
DLLEXPORT QoreNumberNode(const QoreNumberNode& old);
DLLEXPORT virtual QoreString* getStringRepresentation(bool& del) const;
DLLEXPORT virtual void getStringRepresentation(QoreString& str) const;
DLLEXPORT virtual class DateTime *getDateTimeRepresentation(bool& del) const;
DLLEXPORT virtual void getDateTimeRepresentation(DateTime& dt) const;
DLLEXPORT virtual int getAsString(QoreString& str, int foff, class ExceptionSink* xsink) const;
DLLEXPORT virtual QoreString *getAsString(bool& del, int foff, class ExceptionSink* xsink) const;
DLLEXPORT virtual AbstractQoreNode* realCopy() const;
DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode* v, ExceptionSink* xsink) const;
DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode* v, ExceptionSink* xsink) const;
DLLEXPORT virtual const char* getTypeName() const;
DLLEXPORT QoreNumberNode* doPlus(const QoreNumberNode& n) const;
DLLEXPORT QoreNumberNode* doMinus(const QoreNumberNode& n) const;
DLLEXPORT QoreNumberNode* doMultiply(const QoreNumberNode& n) const;
DLLEXPORT QoreNumberNode* doDivideBy(const QoreNumberNode& n, ExceptionSink* xsink) const;
DLLEXPORT QoreNumberNode* negate() const;
DLLEXPORT bool zero() const;
DLLEXPORT int sign() const;
DLLEXPORT int compare(const QoreNumberNode& n) const;
DLLEXPORT int compare(int64 n) const;
DLLEXPORT int compare(double n) const;
DLLEXPORT QoreNumberNode* numberRefSelf() const;
DLLEXPORT void toString(QoreString& str, int fmt = QORE_NF_DEFAULT) const;
DLLEXPORT unsigned getPrec() const;
DLLLOCAL virtual AbstractQoreNode* parseInit(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo);
DLLEXPORT static QoreNumberNode* toNumber(const AbstractQoreNode* v);
DLLLOCAL static const char* getStaticTypeName() {
return "number";
}
DLLLOCAL static qore_type_t getStaticTypeCode() {
return NT_NUMBER;
}
};
#endif
QoreNumberNode::getDateTimeRepresentation
virtual DLLEXPORT class DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this value and sets del to true
QoreNumberNode
Qore&#39;s arbitrary-precision number value type, dynamically-allocated only, reference counted...
Definition: QoreNumberNode.h:44
QoreNumberNode::toString
DLLEXPORT void toString(QoreString &str, int fmt=QORE_NF_DEFAULT) const
concatenates the string value corresponding to the number to the string given
QoreNumberNode::getStringRepresentation
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns the number value converted to a string and sets del to true
QoreNumberNode::toNumber
static DLLEXPORT QoreNumberNode * toNumber(const AbstractQoreNode *v)
returns the representation of the value as a number if possible (otherwise returns 0)...
DateTime
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:85
QoreNumberNode::getPrec
DLLEXPORT unsigned getPrec() const
returns the precision of the number
QoreNumberNode::negate
DLLEXPORT QoreNumberNode * negate() const
returns the negative of the current object (this)
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreNumberNode::getStaticTypeName
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreNumberNode.h:235
QoreNumberNode::doPlus
DLLEXPORT QoreNumberNode * doPlus(const QoreNumberNode &n) const
add the argument to this value and return the result
qore_type_t
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreNumberNode::doDivideBy
DLLEXPORT QoreNumberNode * doDivideBy(const QoreNumberNode &n, ExceptionSink *xsink) const
add the argument to this value and return the result
QoreNumberNode::priv
struct qore_number_private * priv
the private implementation of the type
Definition: QoreNumberNode.h:61
QoreNumberNode::QoreNumberNode
DLLEXPORT QoreNumberNode()
creates a new numbering-point value and assigns it to 0
QoreNumberNode::parseInit
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
QoreNumberNode::getStaticTypeCode
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreNumberNode.h:240
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
QoreNumberNode::getAsString
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate the string representation of the number value to an existing QoreString ...
QoreNumberNode::numberRefSelf
DLLEXPORT QoreNumberNode * numberRefSelf() const
returns a pointer to this with the reference count incremented
QoreNumberNode::doMinus
DLLEXPORT QoreNumberNode * doMinus(const QoreNumberNode &n) const
add the argument to this value and return the result
QoreNumberNode::realCopy
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns a copy of the object; the caller owns the reference count
QoreNumberNode::getTypeName
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
QoreNumberNode::~QoreNumberNode
virtual DLLEXPORT ~QoreNumberNode()
the destructor is protected because it should not be called directly
SimpleValueQoreNode
base class for simple value types
Definition: AbstractQoreNode.h:417
NT_NUMBER
const qore_type_t NT_NUMBER
type value for QoreNumberNode
Definition: node_types.h:45
QORE_NF_DEFAULT
#define QORE_NF_DEFAULT
number format bitfield: default
Definition: QoreNumberNode.h:36
QoreNumberNode::doMultiply
DLLEXPORT QoreNumberNode * doMultiply(const QoreNumberNode &n) const
add the argument to this value and return the result
QoreNumberNode::sign
DLLEXPORT int sign() const
returns -1 if the number is negative, 0 if zero, or 1 if the number is positive
QoreNumberNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without type conversions (hard compare)
QoreNumberNode::compare
DLLEXPORT int compare(const QoreNumberNode &n) const
compares the argument to the current object, returns -1 if the current object is less than the argume...
QoreNumberNode::zero
DLLEXPORT bool zero() const
returns true if the number is zero
QoreNumberNode::is_equal_soft
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with possible type conversion (soft compare)