SequoiaDB
 All Classes Namespaces Files Functions Variables Enumerations Properties Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
SequoiaDB.Bson.BsonDecimal Class Reference

Represents a BSON decimal value. More...

Inheritance diagram for SequoiaDB.Bson.BsonDecimal:
SequoiaDB.Bson.BsonValue

Public Member Functions

 BsonDecimal (String value, int precision, int scale)
 Constructor.
 
 BsonDecimal (String value)
 Constructor.
 
 BsonDecimal (Decimal value)
 Constructor.
 
 BsonDecimal (int size, int typemod, short signscale, short weight, short[] digits)
 
decimal ToDecimal ()
 Converted this BsonDecimal to a Decimal.
 
new double ToDouble ()
 Converts this BsonDecimal to a Double.
 
new long ToInt64 ()
 Converts this BsonDecimal to a Int64.
 
new int ToInt32 ()
 Converts this BsonDecimal to a Int32.
 
int CompareTo (BsonDecimal other)
 Compares this BsonDecimal to another BsonDecimal.
 
override int CompareTo (BsonValue other)
 Compares the BsonDecimal to another BsonValue.
 
bool Equals (BsonDecimal rhs)
 Compares this BsonDecimal to another BsonDecimal.
 
override bool Equals (object obj)
 Compares this BsonDecimal to another object.
 
override int GetHashCode ()
 Gets the hash code.
 
override string ToString ()
 Returns a string representation of the value.
 
- Public Member Functions inherited from SequoiaDB.Bson.BsonValue
virtual BsonValue Clone ()
 Creates a shallow clone of the BsonValue (see also DeepClone).
 
int CompareTypeTo (BsonValue other)
 Compares the type of this BsonValue to the type of another BsonValue.
 
virtual BsonValue DeepClone ()
 Creates a deep clone of the BsonValue (see also Clone).
 
bool Equals (BsonValue rhs)
 Compares this BsonValue to another BsonValue.
 
override bool Equals (object obj)
 Compares this BsonValue to another object.
 
override int GetHashCode ()
 Gets the hash code.
 
bool ToBoolean ()
 Converts this BsonValue to a Boolean (using the JavaScript definition of truthiness).
 
double ToDouble ()
 Converts this BsonValue to a Double.
 
int ToInt32 ()
 Converts this BsonValue to an Int32.
 
long ToInt64 ()
 Converts this BsonValue to an Int64.
 
void WriteTo (BsonWriter bsonWriter)
 Writes the BsonValue to a BsonWriter.
 

Static Public Member Functions

static BsonDecimal Create (int size, int typemod, short signscale, short weight, short[] digits)
 Creates a new instance of the BsonDecimal class.
 
static BsonDecimal Create (decimal value)
 Creates a new instance of the BsonDecimal class.
 
static new BsonDecimal Create (object value)
 Creates a new instance of the BsonDecimal class.
 
static implicit operator BsonDecimal (decimal value)
 Converts an decimal to a BsonDecimal.
 
static bool operator!= (BsonDecimal lhs, BsonDecimal rhs)
 Compares two BsonDecimal values.
 
static bool operator== (BsonDecimal lhs, BsonDecimal rhs)
 Compares two BsonDecimal values.
 
- Static Public Member Functions inherited from SequoiaDB.Bson.BsonValue
static operator bool (BsonValue value)
 Casts a BsonValue to a bool.
 
static operator bool? (BsonValue value)
 Casts a BsonValue to a bool?.
 
static implicit operator BsonValue (bool value)
 Converts a bool to a BsonValue.
 
static implicit operator BsonValue (bool?value)
 Converts a bool? to a BsonValue.
 
static implicit operator BsonValue (byte[] value)
 Converts a byte[] to a BsonValue.
 
static implicit operator BsonValue (DateTime value)
 Converts a DateTime to a BsonValue.
 
static implicit operator BsonValue (DateTime?value)
 Converts a DateTime? to a BsonValue.
 
static implicit operator BsonValue (double value)
 Converts a double to a BsonValue.
 
static implicit operator BsonValue (double?value)
 Converts a double? to a BsonValue.
 
static implicit operator BsonValue (Enum value)
 Converts an Enum to a BsonValue.
 
static implicit operator BsonValue (Guid value)
 Converts a Guid to a BsonValue.
 
static implicit operator BsonValue (Guid?value)
 Converts a Guid? to a BsonValue.
 
static implicit operator BsonValue (int value)
 Converts an int to a BsonValue.
 
static implicit operator BsonValue (int?value)
 Converts an int? to a BsonValue.
 
static implicit operator BsonValue (long value)
 Converts a long to a BsonValue.
 
static implicit operator BsonValue (long?value)
 Converts a long? to a BsonValue.
 
static implicit operator BsonValue (decimal value)
 Converts a decimal to a BsonValue.
 
static implicit operator BsonValue (decimal?value)
 Converts a decimal? to a BsonValue.
 
static implicit operator BsonValue (ObjectId value)
 Converts an ObjectId to a BsonValue.
 
static implicit operator BsonValue (ObjectId?value)
 Converts an ObjectId? to a BsonValue.
 
static implicit operator BsonValue (Regex value)
 Converts a Regex to a BsonValue.
 
static implicit operator BsonValue (string value)
 Converts a string to a BsonValue.
 
static operator byte[] (BsonValue value)
 Casts a BsonValue to a byte[].
 
static operator DateTime (BsonValue value)
 Casts a BsonValue to a DateTime.
 
static operator DateTime? (BsonValue value)
 Casts a BsonValue to a DateTime?.
 
static operator double (BsonValue value)
 Casts a BsonValue to a double.
 
static operator double? (BsonValue value)
 Casts a BsonValue to a double?.
 
static operator Guid (BsonValue value)
 Casts a BsonValue to a Guid.
 
static operator Guid? (BsonValue value)
 Casts a BsonValue to a Guid?.
 
static operator int (BsonValue value)
 Casts a BsonValue to an int.
 
static operator int? (BsonValue value)
 Casts a BsonValue to an int?.
 
static operator long (BsonValue value)
 Casts a BsonValue to a long.
 
static operator long? (BsonValue value)
 Casts a BsonValue to a long?.
 
static operator decimal (BsonValue value)
 Casts a BsonValue to a decimal.
 
static operator decimal? (BsonValue value)
 Casts a BsonValue to a decimal?.
 
static operator ObjectId (BsonValue value)
 Casts a BsonValue to an ObjectId.
 
static operator ObjectId? (BsonValue value)
 Casts a BsonValue to an ObjectId?.
 
static operator Regex (BsonValue value)
 Casts a BsonValue to a Regex.
 
static operator string (BsonValue value)
 Casts a BsonValue to a string.
 
static bool operator< (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static bool operator<= (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static bool operator!= (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static bool operator== (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static bool operator> (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static bool operator>= (BsonValue lhs, BsonValue rhs)
 Compares two BsonValues.
 
static BsonValue Create (object value)
 Creates a new instance of the BsonValue class.
 
static BsonValue ReadFrom (BsonReader bsonReader)
 Reads one BsonValue from a BsonReader.
 

Static Public Attributes

static readonly int DECIMAL_HEADER_SIZE = 12
 

Properties

String Value [get]
 The value of decimal.
 
int Precision [get]
 The precision specified by user or -1 for user does not specify it. It means the total number of significant digits in decimal.
 
int Scale [get]
 The scale specified by user or -1 for user did not specify it. It means the max number of digits after the decimal point.
 
int Size [get]
 
int Typemod [get]
 
short SignScale [get]
 
short Weight [get]
 
short[] Digits [get]
 
- Properties inherited from SequoiaDB.Bson.BsonValue
bool AsBoolean [get]
 Casts the BsonValue to a Boolean (throws an InvalidCastException if the cast is not valid).
 
BsonArray AsBsonArray [get]
 Casts the BsonValue to a BsonArray (throws an InvalidCastException if the cast is not valid).
 
BsonBinaryData AsBsonBinaryData [get]
 Casts the BsonValue to a BsonBinaryData (throws an InvalidCastException if the cast is not valid).
 
BsonDateTime AsBsonDateTime [get]
 Casts the BsonValue to a BsonDateTime (throws an InvalidCastException if the cast is not valid).
 
BsonDocument AsBsonDocument [get]
 Casts the BsonValue to a BsonDocument (throws an InvalidCastException if the cast is not valid).
 
BsonJavaScript AsBsonJavaScript [get]
 Casts the BsonValue to a BsonJavaScript (throws an InvalidCastException if the cast is not valid).
 
BsonJavaScriptWithScope AsBsonJavaScriptWithScope [get]
 Casts the BsonValue to a BsonJavaScriptWithScope (throws an InvalidCastException if the cast is not valid).
 
BsonMaxKey AsBsonMaxKey [get]
 Casts the BsonValue to a BsonMaxKey (throws an InvalidCastException if the cast is not valid).
 
BsonMinKey AsBsonMinKey [get]
 Casts the BsonValue to a BsonMinKey (throws an InvalidCastException if the cast is not valid).
 
BsonNull AsBsonNull [get]
 Casts the BsonValue to a BsonNull (throws an InvalidCastException if the cast is not valid).
 
BsonRegularExpression AsBsonRegularExpression [get]
 Casts the BsonValue to a BsonRegularExpression (throws an InvalidCastException if the cast is not valid).
 
BsonSymbol AsBsonSymbol [get]
 Casts the BsonValue to a BsonSymbol (throws an InvalidCastException if the cast is not valid).
 
BsonTimestamp AsBsonTimestamp [get]
 Casts the BsonValue to a BsonTimestamp (throws an InvalidCastException if the cast is not valid).
 
BsonDecimal AsBsonDecimal [get]
 Casts the BsonValue to a BsonDecimal (throws an InvalidCastException if the cast is not valid).
 
decimal AsDecimal [get]
 Casts the BsonValue to a decimal (throws an InvalidCastException if the cast is not valid).
 
BsonUndefined AsBsonUndefined [get]
 Casts the BsonValue to a BsonUndefined (throws an InvalidCastException if the cast is not valid).
 
BsonValue AsBsonValue [get]
 Casts the BsonValue to a BsonValue (a way of upcasting subclasses of BsonValue to BsonValue at compile time).
 
byte[] AsByteArray [get]
 Casts the BsonValue to a Byte[] (throws an InvalidCastException if the cast is not valid).
 
DateTime AsDateTime [get]
 Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid).
 
double AsDouble [get]
 Casts the BsonValue to a Double (throws an InvalidCastException if the cast is not valid).
 
Guid AsGuid [get]
 Casts the BsonValue to a Guid (throws an InvalidCastException if the cast is not valid).
 
int AsInt32 [get]
 Casts the BsonValue to an Int32 (throws an InvalidCastException if the cast is not valid).
 
DateTime AsLocalTime [get]
 Casts the BsonValue to a DateTime in the local timezone (throws an InvalidCastException if the cast is not valid).
 
long AsInt64 [get]
 Casts the BsonValue to a Int64 (throws an InvalidCastException if the cast is not valid).
 
bool AsNullableBoolean [get]
 Casts the BsonValue to a Nullable{Boolean} (throws an InvalidCastException if the cast is not valid).
 
DateTime AsNullableDateTime [get]
 Casts the BsonValue to a Nullable{DateTime} (throws an InvalidCastException if the cast is not valid).
 
double AsNullableDouble [get]
 Casts the BsonValue to a Nullable{Double} (throws an InvalidCastException if the cast is not valid).
 
Guid AsNullableGuid [get]
 Casts the BsonValue to a Nullable{Guid} (throws an InvalidCastException if the cast is not valid).
 
int AsNullableInt32 [get]
 Casts the BsonValue to a Nullable{Int32} (throws an InvalidCastException if the cast is not valid).
 
long AsNullableInt64 [get]
 Casts the BsonValue to a Nullable{Int64} (throws an InvalidCastException if the cast is not valid).
 
decimal AsNullableDecimal [get]
 Casts the BsonValue to a Nullable{decimal} (throws an InvalidCastException if the cast is not valid).
 
ObjectId AsNullableObjectId [get]
 Casts the BsonValue to a Nullable{ObjectId} (throws an InvalidCastException if the cast is not valid).
 
ObjectId AsObjectId [get]
 Casts the BsonValue to an ObjectId (throws an InvalidCastException if the cast is not valid).
 
Regex AsRegex [get]
 Casts the BsonValue to a Regex (throws an InvalidCastException if the cast is not valid).
 
string AsString [get]
 Casts the BsonValue to a String (throws an InvalidCastException if the cast is not valid).
 
DateTime AsUniversalTime [get]
 Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid).
 
BsonType BsonType [get]
 Gets the BsonType of this BsonValue.
 
bool IsBoolean [get]
 Tests whether this BsonValue is a Boolean.
 
bool IsBsonArray [get]
 Tests whether this BsonValue is a BsonArray.
 
bool IsBsonBinaryData [get]
 Tests whether this BsonValue is a BsonBinaryData.
 
bool IsBsonDateTime [get]
 Tests whether this BsonValue is a BsonDateTime.
 
bool IsBsonDocument [get]
 Tests whether this BsonValue is a BsonDocument.
 
bool IsBsonJavaScript [get]
 Tests whether this BsonValue is a BsonJavaScript.
 
bool IsBsonJavaScriptWithScope [get]
 Tests whether this BsonValue is a BsonJavaScriptWithScope.
 
bool IsBsonMaxKey [get]
 Tests whether this BsonValue is a BsonMaxKey.
 
bool IsBsonMinKey [get]
 Tests whether this BsonValue is a BsonMinKey.
 
bool IsBsonNull [get]
 Tests whether this BsonValue is a BsonNull.
 
bool IsBsonRegularExpression [get]
 Tests whether this BsonValue is a BsonRegularExpression.
 
bool IsBsonSymbol [get]
 Tests whether this BsonValue is a BsonSymbol .
 
bool IsBsonTimestamp [get]
 Tests whether this BsonValue is a BsonTimestamp.
 
bool IsBsonDecimal [get]
 Tests whether this BsonValue is a BsonDecimal.
 
bool IsBsonUndefined [get]
 Tests whether this BsonValue is a BsonUndefined.
 
bool IsDateTime [get]
 Tests whether this BsonValue is a DateTime.
 
bool IsDouble [get]
 Tests whether this BsonValue is a Double.
 
bool IsGuid [get]
 Tests whether this BsonValue is a Guid.
 
bool IsInt32 [get]
 Tests whether this BsonValue is an Int32.
 
bool IsInt64 [get]
 Tests whether this BsonValue is an Int64.
 
bool IsNumeric [get]
 Tests whether this BsonValue is a numeric value.
 
bool IsObjectId [get]
 Tests whether this BsonValue is an ObjectId .
 
bool IsString [get]
 Tests whether this BsonValue is a String.
 
virtual object RawValue [get]
 Gets the raw value of this BsonValue (or null if this BsonValue doesn't have a single scalar value).
 

Additional Inherited Members

- Protected Member Functions inherited from SequoiaDB.Bson.BsonValue
 BsonValue (BsonType bsonType)
 Initializes a new instance of the BsonValue class.
 
virtual bool OperatorEqualsImplementation (BsonValue rhs)
 Implementation of operator ==.
 

Detailed Description

Represents a BSON decimal value.

We use the following terms below: The scale of a BsonDecimal is the max number of digits after the decimal point. The precision of a BsonDecimal is the total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point. So the number 23.5141 has a precision of 6 and a scale of 4. Integers can be considered to have a scale of zero. Besides, when user does not specified precision and scale to build a BsonDecimal object, set both of them as -1. That means the precision and scale are determined by the upper limit of accuracy of the database. Database allow 131072 digits before decimal point and 16383 digits after decimal point at most.

By the way, when user specified the precision and scale, if the fractional part of the offered decimal is greater the scale, BsonDecimal will round the fractional part to the specified scale with the mode of HALP_UP.

Here is a example:

BsonDecimal decimal1 = new BsonDecimal("123.456789", 10, 5);
BsonDecimal decimal2 = new BsonDecimal("-123.456789", 10, 5);
Console.WriteLine(decimal1.toString()); // shows 123.45679;
Console.WriteLine(decimal2.toString()); // shows -123.45679;

Constructor & Destructor Documentation

SequoiaDB.Bson.BsonDecimal.BsonDecimal ( String  value,
int  precision,
int  scale 
)
inline

Constructor.

Parameters
valueThe value of the decimal in string format.
precisionThe precision specified by user.
scaleThe scale specified by user
SequoiaDB.Bson.BsonDecimal.BsonDecimal ( String  value)
inline

Constructor.

Parameters
valueThe value of the decimal in string format.
SequoiaDB.Bson.BsonDecimal.BsonDecimal ( Decimal  value)
inline

Constructor.

Parameters
valueThe value of the decimal in string format.
SequoiaDB.Bson.BsonDecimal.BsonDecimal ( int  size,
int  typemod,
short  signscale,
short  weight,
short[]  digits 
)
inline

Member Function Documentation

int SequoiaDB.Bson.BsonDecimal.CompareTo ( BsonDecimal  other)
inline

Compares this BsonDecimal to another BsonDecimal.

Parameters
otherThe other BsonDecimal.
Returns
A 32-bit signed integer that indicates whether this BsonDecimal is less than, equal to, or greather than the other.
override int SequoiaDB.Bson.BsonDecimal.CompareTo ( BsonValue  other)
inlinevirtual

Compares the BsonDecimal to another BsonValue.

Parameters
otherThe other BsonValue.
Returns
A 32-bit signed integer that indicates whether this BsonDecimal is less than, equal to, or greather than the other BsonValue.

Implements SequoiaDB.Bson.BsonValue.

static BsonDecimal SequoiaDB.Bson.BsonDecimal.Create ( int  size,
int  typemod,
short  signscale,
short  weight,
short[]  digits 
)
inlinestatic

Creates a new instance of the BsonDecimal class.

Parameters
sizeTotal size of this decimal(4+4+2+2+digits.Length).
typemodThe combined precision/scale value. precision = (typmod >> 16) & 0xffff;scale = typmod & 0xffff;
signscaleThe combined sign/scale value. sign = signscale & 0xC000;scale = signscale & 0x3FFF;
weightWeight of this decimal(NBASE=10000).
digitsReal data.
Returns
A BsonDecimal.
static BsonDecimal SequoiaDB.Bson.BsonDecimal.Create ( decimal  value)
inlinestatic

Creates a new instance of the BsonDecimal class.

Parameters
valueA decimal.
Returns
A BsonDecimal.
static new BsonDecimal SequoiaDB.Bson.BsonDecimal.Create ( object  value)
inlinestatic

Creates a new instance of the BsonDecimal class.

Parameters
valueAn object to be mapped to a BsonDecimal.
Returns
A BsonDecimal or null.
bool SequoiaDB.Bson.BsonDecimal.Equals ( BsonDecimal  rhs)
inline

Compares this BsonDecimal to another BsonDecimal.

Parameters
rhsThe other BsonDecimal.
Returns
True if the two BsonDecimal values are equal.
override bool SequoiaDB.Bson.BsonDecimal.Equals ( object  obj)
inline

Compares this BsonDecimal to another object.

Parameters
objThe other object.
Returns
True if the other object is a BsonDecimal and equal to this one.
override int SequoiaDB.Bson.BsonDecimal.GetHashCode ( )
inline

Gets the hash code.

Returns
The hash code.
static implicit SequoiaDB.Bson.BsonDecimal.operator BsonDecimal ( decimal  value)
inlinestatic

Converts an decimal to a BsonDecimal.

Parameters
valueAn decimal.
Returns
A BsonDecimal.
static bool SequoiaDB.Bson.BsonDecimal.operator!= ( BsonDecimal  lhs,
BsonDecimal  rhs 
)
inlinestatic

Compares two BsonDecimal values.

Parameters
lhsThe first BsonObjectId.
rhsThe other BsonObjectId.
Returns
True if the two BsonDecimal values are not equal according to ==.
static bool SequoiaDB.Bson.BsonDecimal.operator== ( BsonDecimal  lhs,
BsonDecimal  rhs 
)
inlinestatic

Compares two BsonDecimal values.

Parameters
lhsThe first BsonDecimal.
rhsThe other BsonDecimal.
Returns
True if the two BsonDecimal values are equal according to ==.
decimal SequoiaDB.Bson.BsonDecimal.ToDecimal ( )
inline

Converted this BsonDecimal to a Decimal.

Returns
A Decimal.
new double SequoiaDB.Bson.BsonDecimal.ToDouble ( )
inline

Converts this BsonDecimal to a Double.

Returns
A Double.
new int SequoiaDB.Bson.BsonDecimal.ToInt32 ( )
inline

Converts this BsonDecimal to a Int32.

Returns
A Int32.
new long SequoiaDB.Bson.BsonDecimal.ToInt64 ( )
inline

Converts this BsonDecimal to a Int64.

Returns
A Int64.
override string SequoiaDB.Bson.BsonDecimal.ToString ( )
inline

Returns a string representation of the value.

Returns
A string representation of the value.

Member Data Documentation

readonly int SequoiaDB.Bson.BsonDecimal.DECIMAL_HEADER_SIZE = 12
static

Property Documentation

short [] SequoiaDB.Bson.BsonDecimal.Digits
get
int SequoiaDB.Bson.BsonDecimal.Precision
get

The precision specified by user or -1 for user does not specify it. It means the total number of significant digits in decimal.

When user specify precision, the range of it is [1, 1000]. When user did not specify precision, it will be set to -1. That means the precision is determined by database. For decimal, database allow 131072 digits before decimal point and 16383 digits after decimal point at most.

int SequoiaDB.Bson.BsonDecimal.Scale
get

The scale specified by user or -1 for user did not specify it. It means the max number of digits after the decimal point.

When user specify scale, the range of it is [0, precision]. When user does not specify scale, it will be set to -1. That means the scale is determined by database. For decimal, database allow 131072 digits before decimal point and 16383 digits after decimal point at most.

short SequoiaDB.Bson.BsonDecimal.SignScale
get
int SequoiaDB.Bson.BsonDecimal.Size
get
int SequoiaDB.Bson.BsonDecimal.Typemod
get
String SequoiaDB.Bson.BsonDecimal.Value
get

The value of decimal.

short SequoiaDB.Bson.BsonDecimal.Weight
get

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