activemq-cpp-3.9.5
Character.h
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#ifndef _DECAF_LANG_CHARACTER_H_
19#define _DECAF_LANG_CHARACTER_H_
20
21#include <decaf/util/Config.h>
22#include <decaf/lang/Number.h>
24#include <string>
25
26namespace decaf{
27namespace lang{
28
29 class DECAF_API Character : public Number,
30 public Comparable<Character>,
31 public Comparable<char> {
32 private:
33
34 // The primitive Char value
35 char value;
36
37 public:
38
40 static const int MIN_RADIX;
41
43 static const int MAX_RADIX;
44
46 static const char MIN_VALUE;
47
49 static const char MAX_VALUE;
50
52 static const int SIZE;
53
54 public:
55
59 Character(char value);
60
72 virtual int compareTo(const Character& c) const {
73 return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
74 }
75
84 virtual bool operator==(const Character& c) const {
85 return this->value == c.value;
86 }
87
97 virtual bool operator<(const Character& c) const {
98 return this->value < c.value;
99 }
100
112 virtual int compareTo(const char& c) const {
113 return this->value < c ? -1 : (this->value > c) ? 1 : 0;
114 }
115
124 virtual bool operator==(const char& c) const {
125 return this->value == c;
126 }
127
137 virtual bool operator<(const char& c) const {
138 return this->value < c;
139 }
140
144 bool equals(const Character& c) const {
145 return this->value == c.value;
146 }
147
151 bool equals(const char& c) const {
152 return this->value == c;
153 }
154
158 std::string toString() const;
159
165 virtual double doubleValue() const {
166 return (double) this->value;
167 }
168
174 virtual float floatValue() const {
175 return (float) this->value;
176 }
177
183 virtual unsigned char byteValue() const {
184 return (unsigned char) this->value;
185 }
186
192 virtual short shortValue() const {
193 return (short) this->value;
194 }
195
201 virtual int intValue() const {
202 return (int) this->value;
203 }
204
210 virtual long long longValue() const {
211 return (long long) this->value;
212 }
213
214 public:
215
224 static Character valueOf(char value) {
225 return Character(value);
226 }
227
237 static bool isWhitespace(char c) {
238 switch (c) {
239 case '\n':
240 case '\t':
241 case '\r':
242 case '\f':
243 case ' ':
244 return true;
245 }
246
247 return false;
248 }
249
258 static bool isDigit(char c) {
259 return c >= '0' && c <= '9';
260 }
261
270 static bool isLowerCase(char c) {
271 return c >= 'a' && c <= 'z';
272 }
273
283 static bool isUpperCase(char c) {
284 return c >= 'A' && c <= 'Z';
285 }
286
295 static bool isLetter(char c) {
296 return isUpperCase(c) || isLowerCase(c);
297 }
298
308 static bool isLetterOrDigit(char c) {
309 return isLetter(c) || isDigit(c);
310 }
311
320 static bool isISOControl(char c) {
321 return (c >= 0 && c <= 0x1f) || ((unsigned char) c >= 0x7f && (unsigned char) c <= 0x9f);
322 }
323
349 static int digit(char c, int radix);
350
362 static char toLowerCase(char value) {
363 if ('A' <= value && value <= 'Z') {
364 return (char) (value + ('a' - 'A'));
365 }
366
367 return value;
368 }
369
381 static char toUpperCase(char value) {
382 if ('a' <= value && value <= 'z') {
383 return (char) (value - ('a' - 'A'));
384 }
385
386 return value;
387 }
388 };
389
390}}
391
392#endif /*_DECAF_LANG_CHARACTER_H_*/
virtual bool operator==(const char &c) const
Compares equality between this object and the one passed.
Definition Character.h:124
static bool isISOControl(char c)
Answers whether the character is an ISO control character, which is a char that lays in the range of ...
Definition Character.h:320
static bool isLowerCase(char c)
Indicates whether or not the given character is a lower case character.
Definition Character.h:270
static const int SIZE
The size of the primitive character in bits.
Definition Character.h:52
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Character.h:201
static const char MIN_VALUE
The minimum value that a signed char can take on.
Definition Character.h:46
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Character.h:165
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Character.h:192
static const int MIN_RADIX
The minimum radix available for conversion to and from strings.
Definition Character.h:40
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Character.h:174
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Character.h:183
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Character.h:210
static bool isLetter(char c)
Indicates whether or not the given character is a letter.
Definition Character.h:295
virtual bool operator<(const char &c) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Character.h:137
static bool isDigit(char c)
Indicates whether or not the given character is a digit.
Definition Character.h:258
static bool isLetterOrDigit(char c)
Indicates whether or not the given character is either a letter or a digit.
Definition Character.h:308
static bool isUpperCase(char c)
Indicates whether or not the given character is a upper case character.
Definition Character.h:283
bool equals(const char &c) const
Definition Character.h:151
static bool isWhitespace(char c)
Indicates whether or not the given character is considered whitespace.
Definition Character.h:237
std::string toString() const
static int digit(char c, int radix)
Returns the numeric value of the character ch in the specified radix.
virtual bool operator==(const Character &c) const
Compares equality between this object and the one passed.
Definition Character.h:84
static char toUpperCase(char value)
Returns the upper case equivalent for the specified character if the character is a lower case letter...
Definition Character.h:381
static Character valueOf(char value)
Returns a Character instance representing the specified char value.
Definition Character.h:224
static const char MAX_VALUE
The maximum value that a signed char can take on.
Definition Character.h:49
virtual int compareTo(const char &c) const
Compares this Character instance with a char type.
Definition Character.h:112
virtual int compareTo(const Character &c) const
Compares this Character instance with another.
Definition Character.h:72
virtual bool operator<(const Character &c) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Character.h:97
static char toLowerCase(char value)
Returns the lower case equivalent for the specified character if the character is an upper case lette...
Definition Character.h:362
static const int MAX_RADIX
The maximum radix available for conversion to and from strings.
Definition Character.h:43
bool equals(const Character &c) const
Definition Character.h:144
This interface imposes a total ordering on the objects of each class that implements it.
Definition Comparable.h:33
The abstract class Number is the superclass of classes Byte, Double, Float, Integer,...
Definition Number.h:35
#define DECAF_API
Definition Config.h:29
Definition ThreadingTypes.h:31
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25