activemq-cpp-3.6.0
decaf::lang::Long Class Reference

#include <src/main/decaf/lang/Long.h>

Inheritance diagram for decaf::lang::Long:

Public Member Functions

 Long (long long value)
 Long (const std::string &value)
 Constructs a new Long and attempts to convert the given string to an long long value, assigning it to the new object is successful or throwing a NumberFormatException if the string is not a properly formatted long long.
virtual ~Long ()
virtual int compareTo (const Long &l) const
 Compares this Long instance with another.
bool equals (const Long &l) const
virtual bool operator== (const Long &l) const
 Compares equality between this object and the one passed.
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 passed.
virtual int compareTo (const long long &l) const
 Compares this Long instance with another.
bool equals (const long long &l) const
virtual bool operator== (const long long &l) const
 Compares equality between this object and the one passed.
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 passed.
std::string toString () const
virtual double doubleValue () const
 Answers the double value which the receiver represents.
virtual float floatValue () const
 Answers the float value which the receiver represents.
virtual unsigned char byteValue () const
 Answers the byte value which the receiver represents.
virtual short shortValue () const
 Answers the short value which the receiver represents.
virtual int intValue () const
 Answers the int value which the receiver represents.
virtual long long longValue () const
 Answers the long value which the receiver represents.
- Public Member Functions inherited from decaf::lang::Number
virtual ~Number ()
- Public Member Functions inherited from decaf::lang::Comparable< Long >
virtual ~Comparable ()
- Public Member Functions inherited from decaf::lang::Comparable< long long >
virtual ~Comparable ()

Static Public Member Functions

static int bitCount (long long value)
 Returns the number of one-bits in the two's complement binary representation of the specified int value.
static Long decode (const std::string &value)
 Decodes a String into a Long.
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 ("leftmost") one-bit in the specified int value.
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 ("rightmost") one-bit in the specified int value.
static int numberOfLeadingZeros (long long value)
 Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long long value.
static int numberOfTrailingZeros (long long value)
 Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long long value.
static long long parseLong (const std::string &value)
 Parses the string argument as a signed decimal long.
static long long parseLong (const std::string &value, int radix)
 Returns a Long object holding the value extracted from the specified string when parsed with the radix given by the second argument.
static long long reverseBytes (long long value)
 Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified long long value.
static long long reverse (long long value)
 Returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified long long value.
static long long rotateLeft (long long value, int distance)
 Returns the value obtained by rotating the two's complement binary representation of the specified value left by the specified number of bits.
static long long rotateRight (long long value, int distance)
 Returns the value obtained by rotating the two's complement binary representation of the specified value right by the specified number of bits.
static int signum (long long value)
 Returns the signum function of the specified value.
static std::string toString (long long value)
 Converts the long to a String representation.
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 std::string toOctalString (long long value)
 Returns a string representation of the long long argument as an unsigned long long in base 8.
static std::string toBinaryString (long long value)
 Returns a string representation of the long long argument as an unsigned long long in base 2.
static Long valueOf (long long value)
 Returns a Long instance representing the specified int value.
static Long valueOf (const std::string &value)
 Returns a Long object holding the value given by the specified std::string.
static Long valueOf (const std::string &value, int radix)
 Returns a Long object holding the value extracted from the specified std::string when parsed with the radix given by the second argument.

Static Public Attributes

static const int SIZE = 64
 The size in bits of the primitive long long type.
static const long long MAX_VALUE = (long long)0x7FFFFFFFFFFFFFFFLL
 The maximum value that the primitive type can hold.
static const long long MIN_VALUE = (long long)0x8000000000000000LL
 The minimum value that the primitive type can hold.

Constructor & Destructor Documentation

decaf::lang::Long::Long ( long long  value)
Parameters
value- the primitive long long to wrap
decaf::lang::Long::Long ( const std::string &  value)

Constructs a new Long and attempts to convert the given string to an long long value, assigning it to the new object is successful or throwing a NumberFormatException if the string is not a properly formatted long long.

Parameters
valueThe string to convert to a primitive type to wrap.
Exceptions
NumberFormatExceptionif the string is not a a valid 64bit long.
virtual decaf::lang::Long::~Long ( )
inlinevirtual

Member Function Documentation

static int decaf::lang::Long::bitCount ( long long  value)
static

Returns the number of one-bits in the two's complement binary representation of the specified int value.

This function is sometimes referred to as the population count.

Parameters
value- the long long to count
Returns
the number of one-bits in the two's complement binary representation of the specified long long value.
virtual unsigned char decaf::lang::Long::byteValue ( ) const
inlinevirtual

Answers the byte value which the receiver represents.

Returns
int the value of the receiver.

Reimplemented from decaf::lang::Number.

virtual int decaf::lang::Long::compareTo ( const Long l) const
virtual

Compares this Long instance with another.

Parameters
l- the Long instance to be compared
Returns
zero if this object represents the same integer value as the argument; a positive value if this object represents a value greater than the passed in value, and -1 if this object represents a value less than the passed in value.

Implements decaf::lang::Comparable< Long >.

virtual int decaf::lang::Long::compareTo ( const long long &  l) const
virtual

Compares this Long instance with another.

Parameters
l- the Integer instance to be compared
Returns
zero if this object represents the same integer value as the argument; a positive value if this object represents a value greater than the passed in value, and -1 if this object represents a value less than the passed in value.

Implements decaf::lang::Comparable< long long >.

static Long decaf::lang::Long::decode ( const std::string &  value)
static

Decodes a String into a Long.

Accepts decimal, hexadecimal, and octal numbers given by the following grammar:

The sequence of characters following an (optional) negative sign and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the Integer.parseInteger method with the indicated radix (10, 16, or 8). This sequence of characters must represent a positive value or a NumberFormatException will be thrown. The result is negated if first character of the specified String is the minus sign. No whitespace characters are permitted in the string.

Parameters
value- The string to decode
Returns
a Long object containing the decoded value
Exceptions
NumberFomatExceptionif the string is not formatted correctly.
virtual double decaf::lang::Long::doubleValue ( ) const
inlinevirtual

Answers the double value which the receiver represents.

Returns
double the value of the receiver.

Implements decaf::lang::Number.

bool decaf::lang::Long::equals ( const Long l) const
inlinevirtual
Parameters
l- the Long object to compare against.
Returns
true if the two Integer Objects have the same value.

Implements decaf::lang::Comparable< Long >.

bool decaf::lang::Long::equals ( const long long &  l) const
inlinevirtual
Parameters
l- the Long object to compare against.
Returns
true if the two Integer Objects have the same value.

Implements decaf::lang::Comparable< long long >.

virtual float decaf::lang::Long::floatValue ( ) const
inlinevirtual

Answers the float value which the receiver represents.

Returns
float the value of the receiver.

Implements decaf::lang::Number.

static long long decaf::lang::Long::highestOneBit ( long long  value)
static

Returns an long long value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int value.

Returns zero if the specified value has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

Parameters
value- the long long to be inspected
Returns
an long long value with a single one-bit, in the position of the highest-order one-bit in the specified value, or zero if the specified value is itself equal to zero.
virtual int decaf::lang::Long::intValue ( ) const
inlinevirtual

Answers the int value which the receiver represents.

Returns
int the value of the receiver.

Implements decaf::lang::Number.

virtual long long decaf::lang::Long::longValue ( ) const
inlinevirtual

Answers the long value which the receiver represents.

Returns
long the value of the receiver.

Implements decaf::lang::Number.

static long long decaf::lang::Long::lowestOneBit ( long long  value)
static

Returns an long long value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value.

Returns zero if the specified value has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

Parameters
value- the long long to be inspected
Returns
an long long value with a single one-bit, in the position of the lowest-order one-bit in the specified value, or zero if the specified value is itself equal to zero.
static int decaf::lang::Long::numberOfLeadingZeros ( long long  value)
static

Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long long value.

Returns 64 if the specified value has no one-bits in its two's complement representation, in other words if it is equal to zero.

Note that this method is closely related to the logarithm base 2. For all positive int values x:

* floor( log2(x)) = 63 - numberOfLeadingZeros(x)
* ceil( log2(x)) = 64 - numberOfLeadingZeros(x - 1)
Parameters
value- the long long to be inspected
Returns
the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation of the specified long long value, or 64 if the value is equal to zero.
static int decaf::lang::Long::numberOfTrailingZeros ( long long  value)
static

Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long long value.

Returns 64 if the specified value has no one-bits in its two's complement representation, in other words if it is equal to zero.

Parameters
value- the int to be inspected
Returns
the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation of the specified long long value, or 64 if the value is equal to zero.
virtual bool decaf::lang::Long::operator< ( const Long l) const
inlinevirtual

Compares this object to another and returns true if this object is considered to be less than the one passed.

This

Parameters
l- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< Long >.

virtual bool decaf::lang::Long::operator< ( const long long &  l) const
inlinevirtual

Compares this object to another and returns true if this object is considered to be less than the one passed.

This

Parameters
l- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< long long >.

virtual bool decaf::lang::Long::operator== ( const Long l) const
inlinevirtual

Compares equality between this object and the one passed.

Parameters
l- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< Long >.

virtual bool decaf::lang::Long::operator== ( const long long &  l) const
inlinevirtual

Compares equality between this object and the one passed.

Parameters
l- the value to be compared to this one.
Returns
true if this object is equal to the one passed.

Implements decaf::lang::Comparable< long long >.

static long long decaf::lang::Long::parseLong ( const std::string &  value)
static

Parses the string argument as a signed decimal long.

The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' to indicate a negative value. The resulting long value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseLong(java.lang.String, int) method.

Note that the characters LL or ULL are not permitted to appear at the end of this string as would normally be permitted in a C++ program.

Parameters
value- String to parse
Returns
long long value
Exceptions
NumberFormatExceptionon invalid string value
static long long decaf::lang::Long::parseLong ( const std::string &  value,
int  radix 
)
static

Returns a Long object holding the value extracted from the specified string when parsed with the radix given by the second argument.

The first argument is interpreted as representing a signed long in the radix specified by the second argument, exactly as if the arguments were given to the parseLong(std::string, int) method. The result is a Long object that represents the long long value specified by the string.

Parameters
value- String to parse
radix- the base encoding of the string
Returns
long long value
Exceptions
NumberFormatExceptionon invalid string value
static long long decaf::lang::Long::reverse ( long long  value)
static

Returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified long long value.

Parameters
value- the value whose bits are to be reversed
Returns
the reversed bits long long.
static long long decaf::lang::Long::reverseBytes ( long long  value)
static

Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified long long value.

Parameters
value- the long long whose bytes we are to reverse
Returns
the reversed long long.
static long long decaf::lang::Long::rotateLeft ( long long  value,
int  distance 
)
static

Returns the value obtained by rotating the two's complement binary representation of the specified value left by the specified number of bits.

(Bits shifted out of the left hand, or high-order, side reenter on the right, or low-order.)

Note that left rotation with a negative distance is equivalent to right rotation: rotateLeft(val, -distance) == rotateRight(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateLeft(val, distance) == rotateLeft(val, distance & 0x1F).

Parameters
value- the long long to be inspected
distance- the number of bits to rotate
Returns
the value obtained by rotating the two's complement binary representation of the specified value left by the specified number of bits.
static long long decaf::lang::Long::rotateRight ( long long  value,
int  distance 
)
static

Returns the value obtained by rotating the two's complement binary representation of the specified value right by the specified number of bits.

(Bits shifted out of the right hand, or low-order, side reenter on the left, or high-order.)

Note that right rotation with a negative distance is equivalent to left rotation: rotateRight(val, -distance) == rotateLeft(val, distance). Note also that rotation by any multiple of 32 is a no-op, so all but the last five bits of the rotation distance can be ignored, even if the distance is negative: rotateRight(val, distance) == rotateRight(val, distance & 0x1F).

Parameters
value- the long long to be inspected
distance- the number of bits to rotate
Returns
the value obtained by rotating the two's complement binary representation of the specified value right by the specified number of bits.
virtual short decaf::lang::Long::shortValue ( ) const
inlinevirtual

Answers the short value which the receiver represents.

Returns
int the value of the receiver.

Reimplemented from decaf::lang::Number.

static int decaf::lang::Long::signum ( long long  value)
static

Returns the signum function of the specified value.

(The return value is -1 if the specified value is negative; 0 if the specified value is zero; and 1 if the specified value is positive.)

Parameters
value- the long long to be inspected
Returns
the signum function of the specified long long value.
static std::string decaf::lang::Long::toBinaryString ( long long  value)
static

Returns a string representation of the long long argument as an unsigned long long in base 2.

The unsigned long long value is the argument plus 2^32 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0'; otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The characters '0' and '1' are used as binary digits.

Parameters
value- the long long to be translated to a binary string
Returns
the unsigned long long value as a binary string
static std::string decaf::lang::Long::toHexString ( long long  value)
static

Returns a string representation of the integer argument as an unsigned integer in base 16.

The unsigned integer value is the argument plus 2^32 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0'; otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:

            0123456789abcdef

If uppercase letters are desired, the toUpperCase() method may be called on the result:

Parameters
value- the long long to be translated to an Octal string
Returns
the unsigned long long value as a Octal string
static std::string decaf::lang::Long::toOctalString ( long long  value)
static

Returns a string representation of the long long argument as an unsigned long long in base 8.

The unsigned long long value is the argument plus 2^32 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading 0s.

If the unsigned magnitude is zero, it is represented by a single zero character '0'; otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as octal digits:

 01234567
Parameters
value- the long long to be translated to an Octal string
Returns
the unsigned long long value as a Octal string
std::string decaf::lang::Long::toString ( ) const
Returns
this Long Object as a String Representation
static std::string decaf::lang::Long::toString ( long long  value)
static

Converts the long to a String representation.

Parameters
valueThe long to convert to a std::string.
Returns
string representation
static std::string decaf::lang::Long::toString ( long long  value,
int  radix 
)
static
static Long decaf::lang::Long::valueOf ( long long  value)
inlinestatic

Returns a Long instance representing the specified int value.

Parameters
value- the long long to wrap
Returns
the new Integer object wrapping value.
static Long decaf::lang::Long::valueOf ( const std::string &  value)
static

Returns a Long object holding the value given by the specified std::string.

The argument is interpreted as representing a signed decimal long long, exactly as if the argument were given to the parseLong( std::string ) method. The result is a Integer object that represents the long long value specified by the string.

Parameters
value- std::string to parse as base 10
Returns
new Long Object wrapping the primitive
Exceptions
NumberFormatExceptionif the string is not a decimal long long.
static Long decaf::lang::Long::valueOf ( const std::string &  value,
int  radix 
)
static

Returns a Long object holding the value extracted from the specified std::string when parsed with the radix given by the second argument.

The first argument is interpreted as representing a signed long long in the radix specified by the second argument, exactly as if the argument were given to the parseLong( std::string, int ) method. The result is a Long object that represents the long long value specified by the string.

Parameters
value- std::string to parse as base ( radix )
radix- base of the string to parse.
Returns
new Long Object wrapping the primitive
Exceptions
NumberFormatExceptionif the string is not a valid long long.

Field Documentation

const long long decaf::lang::Long::MAX_VALUE = (long long)0x7FFFFFFFFFFFFFFFLL
static

The maximum value that the primitive type can hold.

const long long decaf::lang::Long::MIN_VALUE = (long long)0x8000000000000000LL
static

The minimum value that the primitive type can hold.

const int decaf::lang::Long::SIZE = 64
static

The size in bits of the primitive long long type.


The documentation for this class was generated from the following file: