activemq-cpp-3.9.5
Long.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_LONG_H_
19#define _DECAF_LANG_LONG_H_
20
21#include <decaf/lang/Number.h>
22#include <decaf/lang/String.h>
25#include <string>
26
27namespace decaf {
28namespace lang {
29
30 class DECAF_API Long : public Number,
31 public Comparable<Long>,
32 public Comparable<long long> {
33 private:
34
35 // The primitive long long value
36 long long value;
37
38 public:
39
41 static const int SIZE;
42
44 static const long long MAX_VALUE;
45
47 static const long long MIN_VALUE;
48
49 public:
50
54 Long(long long value);
55
66 Long(const String& value);
67
68 virtual ~Long();
69
78 virtual int compareTo(const Long& l) const;
79
84 bool equals(const Long& l) const {
85 return this->value == l.value;
86 }
87
93 virtual bool operator==(const Long& l) const {
94 return this->value == l.value;
95 }
96
103 virtual bool operator<(const Long& l) const {
104 return this->value < l.value;
105 }
106
115 virtual int compareTo(const long long& l) const;
116
121 bool equals(const long long& l) const {
122 return this->value == l;
123 }
124
130 virtual bool operator==(const long long& l) const {
131 return this->value == l;
132 }
133
140 virtual bool operator<(const long long& l) const {
141 return this->value < l;
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 (unsigned char) 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 this->value;
195 }
196
197 public:
198
207 static int bitCount(long long value);
208
224 static Long decode(const String& value);
225
236 static long long highestOneBit(long long value);
237
248 static long long lowestOneBit(long long value);
249
267 static int numberOfLeadingZeros(long long value);
268
279 static int numberOfTrailingZeros(long long value);
280
294 static long long parseLong(const String& value);
295
308 static long long parseLong(const String& value, int radix);
309
316 static long long reverseBytes(long long value);
317
324 static long long reverse(long long value);
325
343 static long long rotateLeft(long long value, int distance);
344
362 static long long rotateRight(long long value, int distance);
363
371 static int signum(long long value);
372
378 static std::string toString(long long value);
379
380 /*
381 * Returns a string representation of the first argument in the radix
382 * specified by the second argument.
383 *
384 * If the radix is smaller than Character.MIN_RADIX or larger than
385 * Character.MAX_RADIX, then the radix 10 is used instead.
386 *
387 * If the first argument is negative, the first element of the result is
388 * the ASCII minus character '-'. If the first argument is not
389 * negative, no sign character appears in the result.
390 *
391 * The remaining characters of the result represent the magnitude of the
392 * first argument. If the magnitude is zero, it is represented by a single
393 * zero character '0'; otherwise, the first character of the
394 * representation of the magnitude will not be the zero character. The
395 * following ASCII characters are used as digits:
396 *
397 * 0123456789abcdefghijklmnopqrstuvwxyz
398 *
399 * @param value - the long long to convert to a string
400 * @param radix - the radix to format the string in
401 * @return an long long formatted to the string value of the radix given.
402 */
403 static std::string toString(long long value, int radix);
404
424 static std::string toHexString(long long value);
425
444 static std::string toOctalString(long long value);
445
461 static std::string toBinaryString(long long value);
462
468 static Long valueOf(long long value) {
469 return Long(value);
470 }
471
485 static Long valueOf(const String& value);
486
503 static Long valueOf(const String& value, int radix);
504
505 private:
506
507 static long long parse(const String& value, int offset, int radix, bool negative);
508
509 };
510
511}}
512
513#endif /*_DECAF_LANG_LONG_H_*/
This interface imposes a total ordering on the objects of each class that implements it.
Definition Comparable.h:33
std::string toString() const
static int numberOfLeadingZeros(long long value)
Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complem...
static const int SIZE
The size in bits of the primitive long long type.
Definition Long.h:41
static int numberOfTrailingZeros(long long value)
Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complem...
static long long reverse(long long value)
Returns the value obtained by reversing the order of the bits in the two's complement binary represen...
static Long valueOf(const String &value, int radix)
Returns a Long object holding the value extracted from the specified std::string when parsed with the...
static std::string toBinaryString(long long value)
Returns a string representation of the long long argument as an unsigned long long in base 2.
virtual int compareTo(const long long &l) const
Compares this Long instance with another.
static int signum(long long value)
Returns the signum function of the specified value.
virtual int compareTo(const Long &l) const
Compares this Long instance with another.
virtual float floatValue() const
Answers the float value which the receiver represents.
Definition Long.h:161
static long long highestOneBit(long long value)
Returns an long long value with at most a single one-bit, in the position of the highest-order ("left...
virtual long long longValue() const
Answers the long value which the receiver represents.
Definition Long.h:193
static const long long MIN_VALUE
The minimum value that the primitive type can hold.
Definition Long.h:47
Long(const String &value)
Constructs a new Long and attempts to convert the given string to an long long value,...
Long(long long value)
static long long rotateRight(long long value, int distance)
Returns the value obtained by rotating the two's complement binary representation of the specified va...
virtual bool operator==(const Long &l) const
Compares equality between this object and the one passed.
Definition Long.h:93
virtual short shortValue() const
Answers the short value which the receiver represents.
Definition Long.h:177
static long long lowestOneBit(long long value)
Returns an long long value with at most a single one-bit, in the position of the lowest-order ("right...
static long long parseLong(const String &value)
Parses the string argument as a signed decimal long.
static std::string toOctalString(long long value)
Returns a string representation of the long long argument as an unsigned long long in base 8.
virtual bool operator<(const long long &l) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Long.h:140
static Long valueOf(const String &value)
Returns a Long object holding the value given by the specified std::string.
static Long decode(const String &value)
Decodes a String into a Long.
static long long reverseBytes(long long value)
Returns the value obtained by reversing the order of the bytes in the two's complement representation...
static long long parseLong(const String &value, int radix)
Returns a Long object holding the value extracted from the specified string when parsed with the radi...
bool equals(const long long &l) const
Definition Long.h:121
virtual bool operator<(const Long &l) const
Compares this object to another and returns true if this object is considered to be less than the one...
Definition Long.h:103
virtual int intValue() const
Answers the int value which the receiver represents.
Definition Long.h:185
static std::string toString(long long value, int radix)
static std::string toHexString(long long value)
Returns a string representation of the integer argument as an unsigned integer in base 16.
static Long valueOf(long long value)
Returns a Long instance representing the specified int value.
Definition Long.h:468
static std::string toString(long long value)
Converts the long to a String representation.
static int bitCount(long long value)
Returns the number of one-bits in the two's complement binary representation of the specified int val...
virtual double doubleValue() const
Answers the double value which the receiver represents.
Definition Long.h:153
virtual bool operator==(const long long &l) const
Compares equality between this object and the one passed.
Definition Long.h:130
virtual unsigned char byteValue() const
Answers the byte value which the receiver represents.
Definition Long.h:169
bool equals(const Long &l) const
Definition Long.h:84
static const long long MAX_VALUE
The maximum value that the primitive type can hold.
Definition Long.h:44
static long long rotateLeft(long long value, int distance)
Returns the value obtained by rotating the two's complement binary representation of the specified va...
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