activemq-cpp-3.8.2
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/Comparable.h>
25 #include <string>
26 
27 namespace decaf{
28 namespace lang{
29 
30  class DECAF_API Byte : public Number,
31  public Comparable<Byte>,
32  public Comparable<unsigned char> {
33  private:
34 
35  unsigned char value;
36 
37  public:
38 
40  static const unsigned char MIN_VALUE;
41 
43  static const unsigned char MAX_VALUE;
44 
46  static const int SIZE;
47 
48  public:
49 
53  Byte(unsigned char value);
54 
63  Byte(const std::string& value);
64 
65  virtual ~Byte() {}
66 
75  virtual int compareTo(const Byte& c) const {
76  return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
77  }
78 
84  virtual bool operator==(const Byte& c) const {
85  return this->value == c.value;
86  }
87 
94  virtual bool operator<(const Byte& c) const {
95  return this->value < c.value;
96  }
97 
106  virtual int compareTo(const unsigned char& c) const {
107  return this->value < c ? -1 : (this->value > c) ? 1 : 0;
108  }
109 
115  virtual bool operator==(const unsigned char& c) const {
116  return this->value == c;
117  }
118 
125  virtual bool operator<(const unsigned char& c) const {
126  return this->value < c;
127  }
128 
132  bool equals(const Byte& c) const {
133  return this->value == c.value;
134  }
135 
139  bool equals(const unsigned char& c) const {
140  return this->value == c;
141  }
142 
146  std::string toString() const;
147 
152  virtual double doubleValue() const {
153  return (double) this->value;
154  }
155 
160  virtual float floatValue() const {
161  return (float) this->value;
162  }
163 
168  virtual unsigned char byteValue() const {
169  return this->value;
170  }
171 
176  virtual short shortValue() const {
177  return (short) this->value;
178  }
179 
184  virtual int intValue() const {
185  return (int) this->value;
186  }
187 
192  virtual long long longValue() const {
193  return (long long) this->value;
194  }
195 
196  public: // statics
197 
201  static std::string toString(unsigned char value);
202 
218  static Byte decode(const std::string& value);
219 
245  static unsigned char parseByte(const std::string& s, int radix);
246 
258  static unsigned char parseByte(const std::string& s);
259 
265  static Byte valueOf(unsigned char value) {
266  return Byte(value);
267  }
268 
279  static Byte valueOf(const std::string& value);
280 
294  static Byte valueOf(const std::string& value, int radix);
295 
296  };
297 
298 }}
299 
300 #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:115
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Byte.h:176
unsigned char Byte
Definition: zconf.h:335
static const int SIZE
The size of the primitive character in bits.
Definition: Byte.h:46
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Byte.h:160
virtual int compareTo(const Byte &c) const
Compares this Byte instance with another.
Definition: Byte.h:75
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Byte.h:168
static Byte valueOf(unsigned char value)
Returns a Character instance representing the specified char value.
Definition: Byte.h:265
virtual int compareTo(const unsigned char &c) const
Compares this Byte instance with a char type.
Definition: Byte.h:106
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Byte.h:192
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:94
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Byte.h:184
Definition: Byte.h:30
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:125
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
static const unsigned char MAX_VALUE
The maximum value that a unsigned char can take on.
Definition: Byte.h:43
bool equals(const Byte &c) const
Definition: Byte.h:132
virtual ~Byte()
Definition: Byte.h:65
virtual bool operator==(const Byte &c) const
Compares equality between this object and the one passed.
Definition: Byte.h:84
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition: Byte.h:152
#define DECAF_API
Definition: Config.h:29
bool equals(const unsigned char &c) const
Definition: Byte.h:139
static const unsigned char MIN_VALUE
The minimum value that a unsigned char can take on.
Definition: Byte.h:40
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25