Xerces-C++ 3.2.4

XMLBigDecimal.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP)
23#define XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP
24
25#include <xercesc/util/XMLNumber.hpp>
26#include <xercesc/util/XMLString.hpp>
27#include <xercesc/util/PlatformUtils.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
30
31 class XMLUTIL_EXPORT XMLBigDecimal : public XMLNumber
32{
33 public:
34
47 XMLBigDecimal
48 (
49 const XMLCh* const strValue
50 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
51 );
52
53 ~XMLBigDecimal();
54
55 static int compareValues(const XMLBigDecimal* const lValue
56 , const XMLBigDecimal* const rValue
57 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
58
59 static XMLCh* getCanonicalRepresentation
60 (
61 const XMLCh* const rawData
62 , MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
63 );
64
65 static void parseDecimal
66 (
67 const XMLCh* const toParse
68 , XMLCh* const retBuffer
69 , int& sign
70 , int& totalDigits
71 , int& fractDigits
72 , MemoryManager* const manager
73 );
74
75 static void parseDecimal
76 (
77 const XMLCh* const toParse
78 , MemoryManager* const manager
79 );
80
81 virtual XMLCh* getRawData() const;
82
83 virtual const XMLCh* getFormattedString() const;
84
85 virtual int getSign() const;
86
87 const XMLCh* getValue() const;
88
89 unsigned int getScale() const;
90
91 unsigned int getTotalDigit() const;
92
93 inline XMLCh* getIntVal() const;
94
103 int toCompare(const XMLBigDecimal& other) const;
104
105 /*
106 * Sets the value to be converted
107 *
108 * @param strValue the value to convert
109 */
110 void setDecimalValue(const XMLCh* const strValue);
111
112 MemoryManager* getMemoryManager() const;
113
114 /***
115 * Support for Serialization/De-serialization
116 ***/
117 DECL_XSERIALIZABLE(XMLBigDecimal)
118
119 XMLBigDecimal(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
120
121private:
122
123 void cleanUp();
124
125 // -----------------------------------------------------------------------
126 // Unimplemented constructors and operators
127 // -----------------------------------------------------------------------
128 XMLBigDecimal(const XMLBigDecimal& other);
129 XMLBigDecimal& operator=(const XMLBigDecimal& other);
130
131 // -----------------------------------------------------------------------
132 // Private data members
133 //
134 // fSign
135 // sign
136 //
137 // fTotalDigits
138 // the total number of digits
139 //
140 // fScale
141 // the number of digits to the right of the decimal point
142 //
143 // fIntVal
144 // The value of this BigDecimal, w/o
145 // leading whitespace, leading zero
146 // decimal point
147 // trailing zero, trailing whitespace
148 //
149 // fRawData
150 // to preserve the original string used to construct this object,
151 // needed for pattern matching.
152 //
153 // -----------------------------------------------------------------------
154 int fSign;
155 unsigned int fTotalDigits;
156 unsigned int fScale;
157 XMLSize_t fRawDataLen;
158 XMLCh* fRawData;
159 XMLCh* fIntVal;
160 MemoryManager* fMemoryManager;
161
162};
163
164inline int XMLBigDecimal::getSign() const
165{
166 return fSign;
167}
168
169 inline const XMLCh* XMLBigDecimal::getValue() const
170{
171 return fIntVal;
172}
173
174 inline unsigned int XMLBigDecimal::getScale() const
175{
176 return fScale;
177}
178
179 inline unsigned int XMLBigDecimal::getTotalDigit() const
180{
181 return fTotalDigits;
182}
183
184 inline XMLCh* XMLBigDecimal::getRawData() const
185{
186 return fRawData;
187}
188
189 inline const XMLCh* XMLBigDecimal::getFormattedString() const
190{
191 return fRawData;
192}
193
194 inline MemoryManager* XMLBigDecimal::getMemoryManager() const
195{
196 return fMemoryManager;
197}
198
199 inline XMLCh* XMLBigDecimal::getIntVal() const
200{
201 return fIntVal;
202}
203
204 XERCES_CPP_NAMESPACE_END
205
206#endif
PlatformUtils.hpp
XMLNumber.hpp
XMLString.hpp
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLUTIL_EXPORT
#define XMLUTIL_EXPORT
Definition: XercesDefs.hpp:162
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:40
XMLBigDecimal
Definition: XMLBigDecimal.hpp:32
XMLBigDecimal::compareValues
static int compareValues(const XMLBigDecimal *const lValue, const XMLBigDecimal *const rValue, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
XMLBigDecimal::toCompare
int toCompare(const XMLBigDecimal &other) const
Compares this object to the specified object.
XMLBigDecimal::getValue
const XMLCh * getValue() const
Definition: XMLBigDecimal.hpp:169
XMLBigDecimal::~XMLBigDecimal
~XMLBigDecimal()
XMLBigDecimal::getIntVal
XMLCh * getIntVal() const
Definition: XMLBigDecimal.hpp:199
XMLBigDecimal::parseDecimal
static void parseDecimal(const XMLCh *const toParse, XMLCh *const retBuffer, int &sign, int &totalDigits, int &fractDigits, MemoryManager *const manager)
XMLBigDecimal::XMLBigDecimal
XMLBigDecimal(const XMLCh *const strValue, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructs a newly allocated XMLBigDecimal object that represents the value represented by the string...
XMLBigDecimal::getFormattedString
virtual const XMLCh * getFormattedString() const
Return the original and converted value of the original data.
Definition: XMLBigDecimal.hpp:189
XMLBigDecimal::setDecimalValue
void setDecimalValue(const XMLCh *const strValue)
XMLBigDecimal::getMemoryManager
MemoryManager * getMemoryManager() const
Definition: XMLBigDecimal.hpp:194
XMLBigDecimal::getScale
unsigned int getScale() const
Definition: XMLBigDecimal.hpp:174
XMLBigDecimal::getTotalDigit
unsigned int getTotalDigit() const
Definition: XMLBigDecimal.hpp:179
XMLBigDecimal::parseDecimal
static void parseDecimal(const XMLCh *const toParse, MemoryManager *const manager)
XMLBigDecimal::getCanonicalRepresentation
static XMLCh * getCanonicalRepresentation(const XMLCh *const rawData, MemoryManager *const memMgr=XMLPlatformUtils::fgMemoryManager)
XMLBigDecimal::getRawData
virtual XMLCh * getRawData() const
Return string representation of the decimal value.
Definition: XMLBigDecimal.hpp:184
XMLNumber
Definition: XMLNumber.hpp:31
XMLNumber::getSign
virtual int getSign() const =0
Returns the sign of this number.
XMLNumber::getFormattedString
virtual const XMLCh * getFormattedString() const =0
Return the original and converted value of the original data.
XMLNumber::getRawData
virtual XMLCh * getRawData() const =0
Return string representation of the decimal value.
XMLPlatformUtils
Utilities that must be implemented in a platform-specific way.
Definition: PlatformUtils.hpp:69
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121