Main Page
Namespaces
Classes
Files
Examples
File List
File Members
include
xqilla
items
Numeric.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2001, 2008,
3
* DecisionSoft Limited. All rights reserved.
4
* Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
5
*
6
*
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
10
*
11
* http://www.apache.org/licenses/LICENSE-2.0
12
*
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
18
*/
19
20
#ifndef __NUMERIC_HPP
21
#define __NUMERIC_HPP
22
23
#include <xercesc/util/XercesDefs.hpp>
24
#include <xqilla/framework/XQillaExport.hpp>
25
#include <
xqilla/items/AnyAtomicType.hpp
>
26
27
class
DynamicContext
;
28
class
StaticContext
;
29
class
MAPM;
30
31
class
XQILLA_API
Numeric
:
public
AnyAtomicType
32
{
33
public
:
34
typedef
RefCountPointer<const Numeric>
Ptr
;
35
36
/* is this type numeric? Return true */
37
virtual
bool
isNumericValue
()
const
{
return
true
; };
38
39
/* Get the name of the primitive type (basic type) of this type
40
* (ie "decimal" for xs:decimal) */
41
virtual
const
XMLCh*
getPrimitiveTypeName
()
const
= 0;
42
43
/* Get the namespace URI for this type */
44
virtual
const
XMLCh*
getTypeURI
()
const
= 0;
45
46
/* Get the name of this type (ie "integer" for xs:integer) */
47
virtual
const
XMLCh*
getTypeName
()
const
= 0;
48
49
/* returns the XMLCh* (canonical) representation of this type */
50
virtual
const
XMLCh*
asString
(
const
DynamicContext
* context)
const
= 0;
51
52
/* Promote this to the given type, if possible */
53
virtual
Numeric::Ptr
promoteTypeIfApplicable(
AnyAtomicType::AtomicObjectType
typeIndex,
54
const
DynamicContext
* context)
const
= 0;
55
56
/* returns true if the two Numeric values are equal
57
* false otherwise */
58
virtual
bool
equals
(
const
AnyAtomicType::Ptr
&target,
const
DynamicContext
* context)
const
;
59
61
virtual
bool
lessThan(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
;
62
64
virtual
bool
greaterThan(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
;
65
68
virtual
int
compare(
const
Numeric::Ptr
&other,
const
DynamicContext
*context)
const
;
69
71
virtual
Numeric::Ptr
add(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
72
75
virtual
Numeric::Ptr
subtract(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
76
78
virtual
Numeric::Ptr
multiply(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
79
81
virtual
Numeric::Ptr
divide(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
82
84
virtual
Numeric::Ptr
mod(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
85
87
virtual
Numeric::Ptr
floor(
const
DynamicContext
* context)
const
= 0;
88
90
virtual
Numeric::Ptr
ceiling(
const
DynamicContext
* context)
const
= 0;
91
93
virtual
Numeric::Ptr
round(
const
DynamicContext
* context)
const
= 0;
94
96
virtual
Numeric::Ptr
roundHalfToEven(
const
Numeric::Ptr
&precision,
const
DynamicContext
* context)
const
= 0;
97
99
virtual
Numeric::Ptr
invert(
const
DynamicContext
* context)
const
= 0;
100
102
virtual
Numeric::Ptr
abs(
const
DynamicContext
* context)
const
= 0;
103
105
virtual
Numeric::Ptr
sqrt(
const
DynamicContext
* context)
const
= 0;
106
108
virtual
Numeric::Ptr
sin(
const
DynamicContext
* context)
const
= 0;
109
111
virtual
Numeric::Ptr
cos(
const
DynamicContext
* context)
const
= 0;
112
114
virtual
Numeric::Ptr
tan(
const
DynamicContext
* context)
const
= 0;
115
117
virtual
Numeric::Ptr
asin(
const
DynamicContext
* context)
const
= 0;
118
120
virtual
Numeric::Ptr
acos(
const
DynamicContext
* context)
const
= 0;
121
123
virtual
Numeric::Ptr
atan(
const
DynamicContext
* context)
const
= 0;
124
126
virtual
Numeric::Ptr
log(
const
DynamicContext
* context)
const
= 0;
127
129
virtual
Numeric::Ptr
exp(
const
DynamicContext
* context)
const
= 0;
130
132
virtual
Numeric::Ptr
power(
const
Numeric::Ptr
&other,
const
DynamicContext
* context)
const
= 0;
133
134
136
virtual
bool
isZero()
const
= 0;
137
139
virtual
bool
isPositive()
const
= 0;
140
142
virtual
bool
isNegative()
const
= 0;
143
144
/* Is this floating point value not a number? */
145
virtual
bool
isNaN()
const
= 0;
146
147
/* Is this floating point value infinite? */
148
virtual
bool
isInfinite()
const
= 0;
149
150
/* Is this floating point value infinite? */
151
virtual
bool
isInteger()
const
;
152
153
virtual
AnyAtomicType::AtomicObjectType
getPrimitiveTypeIndex
()
const
= 0;
154
155
virtual
const
MAPM &asMAPM()
const
= 0;
156
virtual
double
asDouble()
const
;
157
virtual
int
asInt()
const
;
158
159
enum
State
{
160
NEG_INF = 0,
161
NEG_NUM = 1,
162
NUM = 2,
163
INF = 3,
164
NaN = 4
165
};
166
167
virtual
State getState()
const
= 0;
168
169
static
const
XMLCh NaN_string[];
170
static
const
XMLCh NAN_string[];
171
static
const
XMLCh INF_string[];
172
static
const
XMLCh NegINF_string[];
173
static
const
XMLCh NegZero_string[];
174
static
const
XMLCh PosZero_string[];
175
176
static
void
checkFloatLimits(
Numeric::State
&state, MAPM &value);
177
static
void
checkDoubleLimits(
Numeric::State
&state, MAPM &value);
178
179
static
const
XMLCh *asDecimalString(
const
MAPM &value,
int
significantDigits,
const
StaticContext
* context);
180
static
const
XMLCh *asDoubleString(
State
state,
const
MAPM &value,
int
significantDigits,
const
StaticContext
* context);
181
182
protected
:
183
virtual
AnyAtomicType::Ptr
castAsInternal
(
AtomicObjectType
targetIndex,
const
XMLCh* targetURI,
184
const
XMLCh* targetType,
const
DynamicContext
* context)
const
;
185
186
const
XMLCh *asDecimalString(
int
significantDigits,
const
StaticContext
* context)
const
;
187
const
XMLCh *asDoubleString(
int
significantDigits,
const
StaticContext
* context)
const
;
188
189
};
190
191
#endif // __NUMERIC_HPP
RefCountPointer
Super class of all the reference counted wrappers for Items.
Definition:
ReferenceCounted.hpp:61
Numeric
Definition:
Numeric.hpp:31
AnyAtomicType::castAsInternal
virtual AnyAtomicType::Ptr castAsInternal(AtomicObjectType targetIndex, const XMLCh *targetURI, const XMLCh *targetType, const DynamicContext *context) const
AnyAtomicType::equals
virtual bool equals(const AnyAtomicType::Ptr &target, const DynamicContext *context) const =0
StaticContext
The parse time static context interface.
Definition:
StaticContext.hpp:57
AnyAtomicType::AtomicObjectType
AtomicObjectType
Definition:
AnyAtomicType.hpp:34
AnyAtomicType::getTypeName
virtual const XMLCh * getTypeName() const =0
AnyAtomicType
Definition:
AnyAtomicType.hpp:30
AnyAtomicType::asString
virtual const XMLCh * asString(const DynamicContext *context) const =0
AnyAtomicType::getPrimitiveTypeName
virtual const XMLCh * getPrimitiveTypeName() const =0
Numeric::Ptr
RefCountPointer< const Numeric > Ptr
Definition:
Numeric.hpp:34
AnyAtomicType::getTypeURI
virtual const XMLCh * getTypeURI() const =0
DynamicContext
The execution time dynamic context interface.
Definition:
DynamicContext.hpp:38
Numeric::isNumericValue
virtual bool isNumericValue() const
Definition:
Numeric.hpp:37
AnyAtomicType::getPrimitiveTypeIndex
virtual AtomicObjectType getPrimitiveTypeIndex() const =0
Numeric::State
State
Definition:
Numeric.hpp:159
AnyAtomicType.hpp
Generated by
1.8.5