activemq-cpp-3.9.5
Short.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_SHORT_H_
19#define _DECAF_LANG_SHORT_H_
20
21#include <decaf/util/Config.h>
22#include <decaf/lang/String.h>
23#include <decaf/lang/Number.h>
26#include <string>
27
28namespace decaf {
29namespace lang {
30
31 class DECAF_API Short : public Number,
32 public Comparable<Short>,
33 public Comparable<short> {
34 private:
35
36 // The short value
37 short value;
38
39 public:
40
42 static const int SIZE;
43
45 static const short MAX_VALUE;
46
48 static const short MIN_VALUE;
49
50 public:
51
55 Short(short value);
56
63 Short(const String& value);
64
65 virtual ~Short();
66
75 virtual int compareTo(const Short& s) const;
76
80 bool equals(const Short& s) const {
81 return this->value == s.value;
82 }
83
89 virtual bool operator==(const Short& s) const {
90 return this->value == s.value;
91 }
92
99 virtual bool operator<(const Short& s) const {
100 return this->value < s.value;
101 }
102
111 virtual int compareTo(const short& s) const;
112
116 bool equals(const short& s) const {
117 return this->value == s;
118 }
119
125 virtual bool operator==(const short& s) const {
126 return this->value == s;
127 }
128
135 virtual bool operator<(const short& s) const {
136 return this->value < s;
137 }
138
142 std::string toString() const;
143
148 virtual double doubleValue() const {
149 return (double) this->value;
150 }
151
156 virtual float floatValue() const {
157 return (float) this->value;
158 }
159
164 virtual unsigned char byteValue() const {
165 return (unsigned char) this->value;
166 }
167
172 virtual short shortValue() const {
173 return this->value;
174 }
175
180 virtual int intValue() const {
181 return (int) this->value;
182 }
183
188 virtual long long longValue() const {
189 return (long long) this->value;
190 }
191
192 public:
193
197 static std::string toString(short value);
198
214 static Short decode(const String& value);
215
222 static short reverseBytes(short value);
223
251 static short parseShort(const String& s, int radix);
252
268 static short parseShort(const String& s);
269
275 static Short valueOf(short value);
276
291 static Short valueOf(const String& value);
292
310 static Short valueOf(const String& value, int radix);
311
312 };
313
314}}
315
316#endif /*_DECAF_LANG_SHORT_H_*/
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
virtual bool operator<(const Short &s) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Short.h:99
static short reverseBytes(short value)
Returns the value obtained by reversing the order of the bytes in the two's complement representation...
static Short valueOf(short value)
Returns a Short instance representing the specified short value.
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Short.h:156
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Short.h:188
static Short valueOf(const String &value, int radix)
Returns a Short object holding the value extracted from the specified std::string when parsed with th...
static const short MIN_VALUE
Max Value for this Object's primitive type.
Definition Short.h:48
bool equals(const short &s) const
Definition Short.h:116
virtual int compareTo(const short &s) const
Compares this Short instance with another.
Short(const String &value)
static Short decode(const String &value)
Decodes a String into a Short.
static const int SIZE
Size of this objects primitive type in bits.
Definition Short.h:42
std::string toString() const
static short parseShort(const String &s)
Parses the string argument as a signed decimal short.
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Short.h:180
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Short.h:172
static std::string toString(short value)
static short parseShort(const String &s, int radix)
Parses the string argument as a signed short in the radix specified by the second argument.
bool equals(const Short &s) const
Definition Short.h:80
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Short.h:164
virtual bool operator<(const short &s) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Short.h:135
static Short valueOf(const String &value)
Returns a Short object holding the value given by the specified std::string.
static const short MAX_VALUE
Max Value for this Object's primitive type.
Definition Short.h:45
virtual bool operator==(const short &s) const
Compares equality between this object and the one passed.
Definition Short.h:125
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Short.h:148
virtual int compareTo(const Short &s) const
Compares this Short instance with another.
Short(short value)
virtual bool operator==(const Short &s) const
Compares equality between this object and the one passed.
Definition Short.h:89
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