Xalan-C++ API Reference  1.12.0
XalanNumberFormat.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XALANNUMBERFORMAT_HEADER_GUARD_1357924680)
19 #define XALANNUMBERFORMAT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 namespace XALAN_CPP_NAMESPACE {
33 
34 
35 
37 {
38 public:
39 
40  explicit
41  XalanNumberFormat(MemoryManager& theManager);
42 
43  static XalanNumberFormat*
44  create(MemoryManager& theManager)
45  {
46  XalanNumberFormat* theInstance;
47 
48  return XalanConstruct(
49  theManager,
50  theInstance,
51  theManager);
52  }
53 
54  virtual
56 
57  MemoryManager&
59  {
60  return m_groupingSeparator.getMemoryManager();
61  }
62 
63  /**
64  * Format a number into a string.
65  *
66  * @param theValue number to format
67  * @return string representation of number
68  */
69  virtual XalanDOMString&
70  format(double theValue,
71  XalanDOMString& theResult);
72 
73 
74 
75  /**
76  * Format a number into a string.
77  *
78  * @param theValue number to format
79  * @return string representation of number
80  */
81  virtual XalanDOMString&
82  format( XMLInt16 theValue,
83  XalanDOMString& theResult);
84 
85 
86 
87  /**
88  * Format a number into a string.
89  *
90  * @param theValue number to format
91  * @param theResult the string result
92  */
93  virtual XalanDOMString&
94  format(
95  XMLUInt16 theValue,
96  XalanDOMString& theResult);
97 
98  /**
99  * Format a number into a string.
100  *
101  * @param theValue number to format
102  * @return string representation of number
103  */
104  virtual XalanDOMString&
105  format( XMLInt32 theValue,
106  XalanDOMString& theResult);
107 
108 
109  /**
110  * Format a number into a string.
111  *
112  * @param theValue number to format
113  * @param theResult the string result
114  */
115  virtual XalanDOMString&
116  format(
117  XMLUInt32 theValue,
118  XalanDOMString& theResult);
119 
120  /**
121  * Format a number into a string.
122  *
123  * @param theValue number to format
124  * @param theResult the string result
125  */
126  virtual XalanDOMString&
127  format(
128  XMLInt64 theValue,
129  XalanDOMString& theResult);
130 
131  /**
132  * Format a number into a string.
133  *
134  * @param theValue number to format
135  * @param theResult the string result
136  */
137  virtual XalanDOMString&
138  format(
139  XMLUInt64 theValue,
140  XalanDOMString& theResult);
141 
142  /**
143  * Whether groupings are used for numbers, for example, "234,678"
144  *
145  * @return true if grouping used
146  */
147  virtual bool
148  isGroupingUsed() const;
149 
150  /**
151  * Change whether groupings are used for numbers, for example, "234,678"
152  *
153  * @param bUsed true to use grouping
154  */
155  virtual void
156  setGroupingUsed(bool bUsed);
157 
158  /**
159  * Change the size of groupings, for example, "234,678" uses a size of "3"
160  *
161  * @param size the grouping size
162  */
163  virtual void
164  setGroupingSize(unsigned long size);
165 
166  /**
167  * Change the separator string used for groupings, for example, "234,678"
168  * uses the separator ","
169  *
170  * @param s grouping separator string
171  */
172  virtual void
173  setGroupingSeparator(const XalanDOMString& s);
174 
175 protected:
176 
177  void
178  applyGrouping(
179  const XalanDOMString& value,
180  XalanDOMString& result);
181 
182 private:
183 
184  // Not implemented...
186 
188  operator=(const XalanNumberFormat&);
189 
190  bool
192 
193  // Data members...
194  bool m_isGroupingUsed;
195 
196  XalanDOMString m_groupingSeparator;
197 
198  unsigned long m_groupingSize;
199 
200  static const XalanDOMChar s_defaultGroupingSeparator[];
201 };
202 
203 
204 
205 }
206 
207 
208 
209 #endif // XALANNUMBERFORMAT_HEADER_GUARD_1357924680
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanNumberFormat
Definition: XalanNumberFormat.hpp:36
XalanDOMString.hpp
xalanc::XalanConstruct
Type * XalanConstruct(MemoryManager &theMemoryManager, Type *&theInstance)
Definition: XalanMemoryManagement.hpp:200
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:35
PlatformSupportDefinitions.hpp
xalanc::XalanNumberFormat::create
static XalanNumberFormat * create(MemoryManager &theManager)
Definition: XalanNumberFormat.hpp:44
xalanc::XalanNumberFormat::getMemoryManager
MemoryManager & getMemoryManager()
Definition: XalanNumberFormat.hpp:58
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45