Qore Programming Language  0.8.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNumberNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreNumberNode.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_QORENUMBERNODE_H
25 
26 #define _QORE_QORENUMBERNODE_H
27 
28 class LocalVar;
29 class QoreTypeInfo;
30 
35 
36 #define QORE_NF_DEFAULT 0
37 
38 #define QORE_NF_SCIENTIFIC (1 << 0)
39 
40 #define QORE_NF_RAW (1 << 1)
41 
42 
45  friend struct qore_number_private;
46 private:
48  DLLLOCAL virtual bool getAsBoolImpl() const;
49 
51  DLLLOCAL virtual int getAsIntImpl() const;
52 
54  DLLLOCAL virtual int64 getAsBigIntImpl() const;
55 
57  DLLLOCAL virtual double getAsFloatImpl() const;
58 
59 protected:
61  struct qore_number_private* priv;
62 
64 
67  DLLEXPORT virtual ~QoreNumberNode();
68 
69  // private
70  DLLLOCAL QoreNumberNode(struct qore_number_private* p);
71 
72 public:
74  DLLEXPORT QoreNumberNode(const AbstractQoreNode* n);
75 
77 
80  DLLEXPORT QoreNumberNode(double f);
81 
83 
86  DLLEXPORT QoreNumberNode(int64 i);
87 
89 
92  DLLEXPORT QoreNumberNode(const char* str);
93 
95 
99  DLLEXPORT QoreNumberNode(const char* str, unsigned prec);
100 
102  DLLEXPORT QoreNumberNode();
103 
105  DLLEXPORT QoreNumberNode(const QoreNumberNode& old);
106 
108 
113  DLLEXPORT virtual QoreString* getStringRepresentation(bool& del) const;
114 
116 
119  DLLEXPORT virtual void getStringRepresentation(QoreString& str) const;
120 
122 
128  DLLEXPORT virtual class DateTime *getDateTimeRepresentation(bool& del) const;
129 
131 
135  DLLEXPORT virtual void getDateTimeRepresentation(DateTime& dt) const;
136 
138 
144  DLLEXPORT virtual int getAsString(QoreString& str, int foff, class ExceptionSink* xsink) const;
145 
147 
153  DLLEXPORT virtual QoreString *getAsString(bool& del, int foff, class ExceptionSink* xsink) const;
154 
156 
159  DLLEXPORT virtual AbstractQoreNode* realCopy() const;
160 
162 
167  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode* v, ExceptionSink* xsink) const;
168 
170 
175  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode* v, ExceptionSink* xsink) const;
176 
178 
181  DLLEXPORT virtual const char* getTypeName() const;
182 
184  DLLEXPORT QoreNumberNode* doPlus(const QoreNumberNode& n) const;
185 
187  DLLEXPORT QoreNumberNode* doMinus(const QoreNumberNode& n) const;
188 
190  DLLEXPORT QoreNumberNode* doMultiply(const QoreNumberNode& n) const;
191 
193  DLLEXPORT QoreNumberNode* doDivideBy(const QoreNumberNode& n, ExceptionSink* xsink) const;
194 
196  DLLEXPORT QoreNumberNode* negate() const;
197 
199  DLLEXPORT bool zero() const;
200 
202  DLLEXPORT int sign() const;
203 
205  DLLEXPORT int compare(const QoreNumberNode& n) const;
206 
208  DLLEXPORT QoreNumberNode* numberRefSelf() const;
209 
211 
214  DLLEXPORT void toString(QoreString& str, int fmt = QORE_NF_DEFAULT) const;
215 
217  DLLEXPORT unsigned getPrec() const;
218 
220  DLLLOCAL virtual AbstractQoreNode* parseInit(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo);
221 
223 
226  DLLLOCAL static const char* getStaticTypeName() {
227  return "number";
228  }
229 
231  DLLLOCAL static qore_type_t getStaticTypeCode() {
232  return NT_NUMBER;
233  }
234 };
235 
236 #endif