Qore Programming Language  0.8.11.1
QoreBigIntNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreBigIntNode.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_BIGINTNODE_H
33 
34 #define _QORE_BIGINTNODE_H
35 
36 #include <qore/AbstractQoreNode.h>
37 
38 class LocalVar;
39 
42 private:
44  DLLLOCAL virtual bool getAsBoolImpl() const;
45 
47  DLLLOCAL virtual int getAsIntImpl() const;
48 
50  DLLLOCAL virtual int64 getAsBigIntImpl() const;
51 
53  DLLLOCAL virtual double getAsFloatImpl() const;
54 
55 protected:
56  DLLEXPORT virtual ~QoreBigIntNode();
57 
58  // protected constructor for subclasses only
59  DLLEXPORT QoreBigIntNode(qore_type_t t, int64 v);
60 
61 public:
63  int64 val;
64 
66  DLLEXPORT QoreBigIntNode();
67 
69 
72  DLLEXPORT QoreBigIntNode(int64 v);
73 
75 
79  DLLEXPORT virtual QoreString *getStringRepresentation(bool &del) const;
80 
82 
85  DLLEXPORT virtual void getStringRepresentation(QoreString &str) const;
86 
88 
92  DLLEXPORT virtual DateTime *getDateTimeRepresentation(bool &del) const;
93 
95 
98  DLLEXPORT virtual void getDateTimeRepresentation(DateTime &dt) const;
99 
101 
107  DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
108 
110 
117  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
118 
119  DLLEXPORT virtual AbstractQoreNode *realCopy() const;
120 
122 
126  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
127 
129 
133  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
134 
136  DLLEXPORT virtual const char *getTypeName() const;
137 
139  DLLEXPORT virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
140 
142  DLLLOCAL static const char *getStaticTypeName() {
143  return "integer";
144  }
145 
147  DLLLOCAL static qore_type_t getStaticTypeCode() {
148  return NT_INT;
149  }
150 
152  DLLLOCAL static int64 getValue(AbstractQoreNode *v) {
153  return v->getAsBigInt();
154  }
155 };
156 
157 #endif
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality with the possibility of type conversion (soft compare)
virtual DLLEXPORT int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const
concatenates the value of the integer to an existing QoreString
virtual DLLEXPORT DateTime * getDateTimeRepresentation(bool &del) const
returns the DateTime representation of this integer (interpreted as an offset in seconds from January...
static DLLLOCAL const char * getStaticTypeName()
returns the type code (useful in templates)
Definition: QoreBigIntNode.h:142
static DLLLOCAL int64 getValue(AbstractQoreNode *v)
returns the integer value (useful in templates)
Definition: QoreBigIntNode.h:152
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality without the possibility of type conversion (hard compare)
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
virtual DLLEXPORT AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
DLLEXPORT int64 getAsBigInt() const
returns the 64-bit integer value of the object
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:67
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:50
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
virtual DLLEXPORT QoreString * getStringRepresentation(bool &del) const
returns a string representing the integer and sets del to true
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreBigIntNode.h:147
DLLEXPORT QoreBigIntNode()
creates a new integer with the value 0
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
const qore_type_t NT_INT
type value for QoreBigIntNode
Definition: node_types.h:43
virtual DLLEXPORT AbstractQoreNode * realCopy() const
returns a copy of the object; the caller owns the reference count
int64 val
value of the integer
Definition: QoreBigIntNode.h:63
base class for simple value types
Definition: AbstractQoreNode.h:425
this class implements Qore's 64-bit integer data type, reference-counted, dynamically-allocated only ...
Definition: QoreBigIntNode.h:41