activemq-cpp-3.9.5
Byte.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_BYTE_H_
19#define _DECAF_LANG_BYTE_H_
20
21#include <decaf/util/Config.h>
22#include <decaf/lang/Number.h>
23#include <decaf/lang/String.h>
26#include <string>
27
28namespace decaf {
29namespace lang {
30
31 class DECAF_API Byte : public Number,
32 public Comparable<Byte>,
33 public Comparable<unsigned char> {
34 private:
35
36 unsigned char value;
37
38 public:
39
41 static const unsigned char MIN_VALUE;
42
44 static const unsigned char MAX_VALUE;
45
47 static const int SIZE;
48
49 public:
50
54 Byte(unsigned char value);
55
64 Byte(const String& value);
65
66 virtual ~Byte() {}
67
76 virtual int compareTo(const Byte& c) const {
77 return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
78 }
79
85 virtual bool operator==(const Byte& c) const {
86 return this->value == c.value;
87 }
88
95 virtual bool operator<(const Byte& c) const {
96 return this->value < c.value;
97 }
98
107 virtual int compareTo(const unsigned char& c) const {
108 return this->value < c ? -1 : (this->value > c) ? 1 : 0;
109 }
110
116 virtual bool operator==(const unsigned char& c) const {
117 return this->value == c;
118 }
119
126 virtual bool operator<(const unsigned char& c) const {
127 return this->value < c;
128 }
129
133 bool equals(const Byte& c) const {
134 return this->value == c.value;
135 }
136
140 bool equals(const unsigned char& c) const {
141 return this->value == c;
142 }
143
147 std::string toString() const;
148
153 virtual double doubleValue() const {
154 return (double) this->value;
155 }
156
161 virtual float floatValue() const {
162 return (float) this->value;
163 }
164
169 virtual unsigned char byteValue() const {
170 return this->value;
171 }
172
177 virtual short shortValue() const {
178 return (short) this->value;
179 }
180
185 virtual int intValue() const {
186 return (int) this->value;
187 }
188
193 virtual long long longValue() const {
194 return (long long) this->value;
195 }
196
197 public:
198
202 static std::string toString(unsigned char value);
203
223 static Byte decode(const String& value);
224
253 static unsigned char parseByte(const String& s, int radix);
254
270 static unsigned char parseByte(const String& s);
271
280 static Byte valueOf(unsigned char value) {
281 return Byte(value);
282 }
283
297 static Byte valueOf(const String& value);
298
316 static Byte valueOf(const String& value, int radix);
317
318 };
319
320}}
321
322#endif /*_DECAF_LANG_BYTE_H_*/
virtual bool operator==(const unsigned char &c) const
Compares equality between this object and the one passed.
Definition Byte.h:116
static Byte decode(const String &value)
Decodes a String into a Byte.
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Byte.h:185
static const int SIZE
The size of the primitive character in bits.
Definition Byte.h:47
static Byte valueOf(unsigned char value)
Returns a Character instance representing the specified char value.
Definition Byte.h:280
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Byte.h:153
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Byte.h:193
bool equals(const unsigned char &c) const
Definition Byte.h:140
std::string toString() const
virtual bool operator==(const Byte &c) const
Compares equality between this object and the one passed.
Definition Byte.h:85
Byte(unsigned char value)
static unsigned char parseByte(const String &s, int radix)
Parses the string argument as a signed unsigned char in the radix specified by the second argument.
static const unsigned char MAX_VALUE
The maximum value that a unsigned char can take on.
Definition Byte.h:44
static unsigned char parseByte(const String &s)
Parses the string argument as a signed decimal unsigned char.
static std::string toString(unsigned char value)
virtual ~Byte()
Definition Byte.h:66
virtual bool operator<(const unsigned char &c) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Byte.h:126
static const unsigned char MIN_VALUE
The minimum value that a unsigned char can take on.
Definition Byte.h:41
bool equals(const Byte &c) const
Definition Byte.h:133
static Byte valueOf(const String &value)
Returns a Byte object holding the value given by the specified std::string.
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Byte.h:177
Byte(const String &value)
Creates a new Byte instance from the given string.
static Byte valueOf(const String &value, int radix)
Returns a Byte object holding the value extracted from the specified std::string when parsed with the...
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Byte.h:169
virtual int compareTo(const unsigned char &c) const
Compares this Byte instance with a char type.
Definition Byte.h:107
virtual int compareTo(const Byte &c) const
Compares this Byte instance with another.
Definition Byte.h:76
virtual bool operator<(const Byte &c) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Byte.h:95
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Byte.h:161
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
An immutable sequence of characters.
Definition String.h:57
#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
unsigned char Byte
Definition zconf.h:335