|
activemq-cpp-3.3.0
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_LANG_SHORT_H_ 00019 #define _DECAF_LANG_SHORT_H_ 00020 00021 #include <decaf/util/Config.h> 00022 #include <decaf/lang/Number.h> 00023 #include <decaf/lang/Comparable.h> 00024 #include <decaf/lang/exceptions/NumberFormatException.h> 00025 #include <string> 00026 00027 namespace decaf{ 00028 namespace lang{ 00029 00030 class DECAF_API Short : public Number, 00031 public Comparable<Short>, 00032 public Comparable<short> { 00033 private: 00034 00035 // The short value 00036 short value; 00037 00038 public: 00039 00041 static const int SIZE = 16; 00042 00044 static const short MAX_VALUE = (short)0x7FFF; 00045 00047 static const short MIN_VALUE = (short)0x8000; 00048 00049 public: 00050 00054 Short( short value ); 00055 00062 Short( const std::string& value ); 00063 00064 virtual ~Short() {} 00065 00074 virtual int compareTo( const Short& s ) const; 00075 00079 bool equals( const Short& s ) const { 00080 return this->value == s.value; 00081 } 00082 00088 virtual bool operator==( const Short& s ) const { 00089 return this->value == s.value; 00090 } 00091 00098 virtual bool operator<( const Short& s ) const { 00099 return this->value < s.value; 00100 } 00101 00110 virtual int compareTo( const short& s ) const; 00111 00115 bool equals( const short& s ) const { 00116 return this->value == s; 00117 } 00118 00124 virtual bool operator==( const short& s ) const { 00125 return this->value == s; 00126 } 00127 00134 virtual bool operator<( const short& s ) const { 00135 return this->value < s; 00136 } 00137 00141 std::string toString() const; 00142 00147 virtual double doubleValue() const { 00148 return (double)this->value; 00149 } 00150 00155 virtual float floatValue() const { 00156 return (float)this->value; 00157 } 00158 00163 virtual unsigned char byteValue() const { 00164 return (unsigned char)this->value; 00165 } 00166 00171 virtual short shortValue() const { 00172 return this->value; 00173 } 00174 00179 virtual int intValue() const { 00180 return (int)this->value; 00181 } 00182 00187 virtual long long longValue() const { 00188 return (long long)this->value; 00189 } 00190 00191 public: // statics 00192 00196 static std::string toString( short value ); 00197 00213 static Short decode( const std::string& value ); 00214 00221 static short reverseBytes( short value ); 00222 00246 static short parseShort( const std::string& s, int radix ); 00247 00260 static short parseShort( const std::string& s ); 00261 00267 static Short valueOf( short value ); 00268 00279 static Short valueOf( const std::string& value ); 00280 00293 static Short valueOf( const std::string& value, int radix ); 00294 00295 }; 00296 00297 }} 00298 00299 #endif /*_DECAF_LANG_SHORT_H_*/