activemq-cpp-3.8.2
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/Number.h>
23 #include <decaf/lang/Comparable.h>
25 #include <string>
26 
27 namespace decaf{
28 namespace lang{
29 
30  class DECAF_API Short : public Number,
31  public Comparable<Short>,
32  public Comparable<short> {
33  private:
34 
35  // The short value
36  short value;
37 
38  public:
39 
41  static const int SIZE;
42 
44  static const short MAX_VALUE;
45 
47  static const short MIN_VALUE;
48 
49  public:
50 
54  Short( short value );
55 
62  Short( const std::string& value );
63 
64  virtual ~Short() {}
65 
74  virtual int compareTo( const Short& s ) const;
75 
79  bool equals( const Short& s ) const {
80  return this->value == s.value;
81  }
82 
88  virtual bool operator==( const Short& s ) const {
89  return this->value == s.value;
90  }
91 
98  virtual bool operator<( const Short& s ) const {
99  return this->value < s.value;
100  }
101 
110  virtual int compareTo( const short& s ) const;
111 
115  bool equals( const short& s ) const {
116  return this->value == s;
117  }
118 
124  virtual bool operator==( const short& s ) const {
125  return this->value == s;
126  }
127 
134  virtual bool operator<( const short& s ) const {
135  return this->value < s;
136  }
137 
141  std::string toString() const;
142 
147  virtual double doubleValue() const {
148  return (double)this->value;
149  }
150 
155  virtual float floatValue() const {
156  return (float)this->value;
157  }
158 
163  virtual unsigned char byteValue() const {
164  return (unsigned char)this->value;
165  }
166 
171  virtual short shortValue() const {
172  return this->value;
173  }
174 
179  virtual int intValue() const {
180  return (int)this->value;
181  }
182 
187  virtual long long longValue() const {
188  return (long long)this->value;
189  }
190 
191  public: // statics
192 
196  static std::string toString( short value );
197 
213  static Short decode( const std::string& value );
214 
221  static short reverseBytes( short value );
222 
246  static short parseShort( const std::string& s, int radix );
247 
260  static short parseShort( const std::string& s );
261 
267  static Short valueOf( short value );
268 
279  static Short valueOf( const std::string& value );
280 
293  static Short valueOf( const std::string& value, int radix );
294 
295  };
296 
297 }}
298 
299 #endif /*_DECAF_LANG_SHORT_H_*/
virtual ~Short()
Definition: Short.h:64
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:134
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition: Short.h:163
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition: Short.h:171
virtual int intValue() const
Answers the int value which the receiver represents.
Definition: Short.h:179
virtual bool operator==(const short &s) const
Compares equality between this object and the one passed.
Definition: Short.h:124
The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short.
Definition: Number.h:35
Definition: Short.h:30
static const int SIZE
Size of this objects primitive type in bits.
Definition: Short.h:41
static const short MIN_VALUE
Max Value for this Object&#39;s primitive type.
Definition: Short.h:47
virtual bool operator==(const Short &s) const
Compares equality between this object and the one passed.
Definition: Short.h:88
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition: Short.h:147
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition: Short.h:155
#define DECAF_API
Definition: Config.h:29
static const short MAX_VALUE
Max Value for this Object&#39;s primitive type.
Definition: Short.h:44
bool equals(const Short &s) const
Definition: Short.h:79
bool equals(const short &s) const
Definition: Short.h:115
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition: Short.h:187
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
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:98
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25