SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Provides storage for C++ primitive types and structured types used by the DB Interface Module, and adds NULL/NOT NULL
semantics.
More...
#include <rw/db/value.h>
Public Types | |
enum | ValueType { NoType, Char, UnsignedChar, Tiny, UnsignedTiny, Short, UnsignedShort, Int, UnsignedInt, Long, UnsignedLong, LongLong, UnsignedLongLong, Float, Double, LongDouble, Decimal, Date, DateTime, Duration, String, Blob, WString, MBString, UString } |
Public Member Functions | |
virtual RWCollectable * | newSpecies () const |
virtual RWClassID | isA () const |
RWDBValue () | |
RWDBValue (const RWDBValue &value) | |
RWDBValue (RWDBValueManip manip) | |
RWDBValue (char value) | |
RWDBValue (unsigned char value) | |
RWDBValue (short value) | |
RWDBValue (unsigned short value) | |
RWDBValue (int value) | |
RWDBValue (unsigned int value) | |
RWDBValue (long value) | |
RWDBValue (unsigned long value) | |
RWDBValue (long long value) | |
RWDBValue (unsigned long long value) | |
RWDBValue (float value) | |
RWDBValue (double value) | |
RWDBValue (long double value) | |
RWDBValue (const char *value) | |
RWDBValue (const wchar_t *value) | |
RWDBValue (const RWDecimalPortable &value) | |
RWDBValue (const RWDate &value) | |
RWDBValue (const RWDBDateTime &value) | |
RWDBValue (const RWDateTime &value) | |
RWDBValue (const RWDBDuration &value) | |
RWDBValue (const RWCString &value) | |
RWDBValue (const RWDBBlob &value) | |
RWDBValue (const RWWString &value) | |
RWDBValue (const RWDBMBString &value) | |
RWDBValue (const RWBasicUString &value) | |
virtual RWspace | binaryStoreSize () const |
virtual int | compareTo (const RWCollectable *cp) const |
virtual bool | isEqual (const RWCollectable *cp) const |
virtual unsigned | hash () const |
virtual void | saveGuts (RWFile &file) const |
virtual void | saveGuts (RWvostream &stream) const |
virtual void | restoreGuts (RWFile &file) |
virtual void | restoreGuts (RWvistream &stream) |
ValueType | type () const |
RWCString | typeString () const |
bool | isNull () const |
bool | canConvert (ValueType type) const |
char | asChar () const |
unsigned char | asUnsignedChar () const |
short | asShort () const |
unsigned short | asUnsignedShort () const |
int | asInt () const |
unsigned int | asUnsignedInt () const |
long | asLong () const |
unsigned long | asUnsignedLong () const |
long long | asLongLong () const |
unsigned long long | asUnsignedLongLong () const |
float | asFloat () const |
double | asDouble () const |
long double | asLongDouble () const |
RWDecimalPortable | asDecimal () const |
RWDate | asDate () const |
RWDBDateTime | asDateTime () const |
RWDBDuration | asDuration () const |
RWCString | asString () const |
RWCString | asString (const RWDBPhraseBook &phraseBook) const |
RWDBBlob | asBlob () const |
RWWString | asWString () const |
RWDBMBString | asMBString () const |
RWBasicUString | asUString () const |
RWDBValue & | operator= (const RWDBValue &value) |
RWDBValue & | operator= (RWDBValueManip manip) |
RWDBValue & | operator= (char value) |
RWDBValue & | operator= (unsigned char value) |
RWDBValue & | operator= (short value) |
RWDBValue & | operator= (unsigned short value) |
RWDBValue & | operator= (int value) |
RWDBValue & | operator= (unsigned int value) |
RWDBValue & | operator= (long value) |
RWDBValue & | operator= (unsigned long value) |
RWDBValue & | operator= (long long value) |
RWDBValue & | operator= (unsigned long long value) |
RWDBValue & | operator= (float value) |
RWDBValue & | operator= (double value) |
RWDBValue & | operator= (long double value) |
RWDBValue & | operator= (const RWDecimalPortable &value) |
RWDBValue & | operator= (const RWDate &value) |
RWDBValue & | operator= (const RWDBDateTime &value) |
RWDBValue & | operator= (const RWDBDuration &value) |
RWDBValue & | operator= (const RWCString &value) |
RWDBValue & | operator= (const RWDBBlob &value) |
RWDBValue & | operator= (const RWWString &value) |
RWDBValue & | operator= (const RWDBMBString &value) |
RWDBValue & | operator= (const RWBasicUString &value) |
Static Public Member Functions | |
static RWClassID | classIsA () |
Friends | |
void | rwdbNull (RWDBValue &) |
Related Functions | |
(Note that these are not member functions.) | |
typedef void(* | RWDBValueManip )(RWDBValue &) |
RWDBValue provides storage for C++ primitive types and structured types used by the DB Interface Module. It also adds NULL/NOT NULL
semantics to the types. RWDBValue is used in two ways:
int
or RWDateTime, you could simply read the data into an RWDBValue instance and use the asString() method to convert the data into an RWCString.RWDBValue inherits from class RWCollectable of the Essential Tools Module. The virtual functions of the base class RWCollectable are redefined, allowing instances of RWDBValue to be stored in the Smalltalk-like collections of the Essential Tools Module.
#include <rw/db/value.h> RWDBValue value; //null, no type value RWDBValue value(20); //integer value
enum RWDBValue::ValueType |
Every RWDBValue is tagged with a ValueType. In addition, RWDBColumn uses RWDBValue::ValueType to store schema information. In that context, Tiny and UnsignedTiny refer to one-byte integers. The DB Interface Module does not store data as Tiny or UnsignedTiny.
RWDBValue::RWDBValue | ( | ) |
The default constructor creates a NULL
value without type.
RWDBValue::RWDBValue | ( | RWDBValueManip | manip | ) |
RWDBValue::RWDBValue | ( | char | value | ) |
RWDBValue::RWDBValue | ( | unsigned char | value | ) |
RWDBValue::RWDBValue | ( | short | value | ) |
RWDBValue::RWDBValue | ( | unsigned short | value | ) |
RWDBValue::RWDBValue | ( | int | value | ) |
RWDBValue::RWDBValue | ( | unsigned int | value | ) |
RWDBValue::RWDBValue | ( | long | value | ) |
RWDBValue::RWDBValue | ( | unsigned long | value | ) |
RWDBValue::RWDBValue | ( | long long | value | ) |
RWDBValue::RWDBValue | ( | unsigned long long | value | ) |
RWDBValue::RWDBValue | ( | float | value | ) |
RWDBValue::RWDBValue | ( | double | value | ) |
RWDBValue::RWDBValue | ( | long double | value | ) |
RWDBValue::RWDBValue | ( | const char * | value | ) |
RWDBValue::RWDBValue | ( | const wchar_t * | value | ) |
RWDBValue::RWDBValue | ( | const RWDecimalPortable & | value | ) |
RWDBValue::RWDBValue | ( | const RWDate & | value | ) |
RWDBValue::RWDBValue | ( | const RWDBDateTime & | value | ) |
RWDBValue::RWDBValue | ( | const RWDateTime & | value | ) |
RWDBValue::RWDBValue | ( | const RWDBDuration & | value | ) |
RWDBValue::RWDBValue | ( | const RWCString & | value | ) |
RWDBValue::RWDBValue | ( | const RWDBBlob & | value | ) |
RWDBValue::RWDBValue | ( | const RWWString & | value | ) |
RWDBValue::RWDBValue | ( | const RWDBMBString & | value | ) |
RWDBValue::RWDBValue | ( | const RWBasicUString & | value | ) |
Constructs an RWDBValue from the supplied value. Self is non-NULL
and is tagged with the appropriate ValueType.
RWDBBlob RWDBValue::asBlob | ( | ) | const |
Returns self as an RWDBBlob. If self cannot be converted according to canConvert() using an argument of RWDBValue::Blob, returns an RWDBBlob with zero length. If self holds data of type RWDBValue::UString, conversion to RWDBBlob checks the endian format used by the current system (Big-Endian or Little-Endian) to give the same RWDBBlob data for the same UString data independent of the endian format of the system.
char RWDBValue::asChar | ( | ) | const |
Returns self as a char
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Char, returns a char
with value (char)0
.
RWDate RWDBValue::asDate | ( | ) | const |
Returns self as an RWDate. If self cannot be converted according to canConvert() using an argument of RWDBValue::Date, returns an RWDate whose state is invalid.
RWDBDateTime RWDBValue::asDateTime | ( | ) | const |
Returns self as an RWDBDateTime. If self cannot be converted according to canConvert() using an argument of RWDBValue::DateTime, returns an RWDBDateTime whose state is invalid.
RWDecimalPortable RWDBValue::asDecimal | ( | ) | const |
Returns self as an RWDecimalPortable. If self cannot be converted according to canConvert() using an argument of RWDBValue::Decimal, returns an RWDecimalPortable with a value of 0
.
double RWDBValue::asDouble | ( | ) | const |
Returns self as a double
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Double, returns a double
with a value of 0
.
RWDBDuration RWDBValue::asDuration | ( | ) | const |
Returns self as an RWDBDuration. If self cannot be converted according to canConvert() using an argument of RWDBValue::Duration, returns an RWDBDuration whose state is invalid.
float RWDBValue::asFloat | ( | ) | const |
Returns self as a float
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Float, returns a float
with a value of 0
.
int RWDBValue::asInt | ( | ) | const |
Returns self as an int
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Int, returns an int
with a value of 0
.
long RWDBValue::asLong | ( | ) | const |
Returns self as a long
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Long, returns a long
with a value of 0
.
long double RWDBValue::asLongDouble | ( | ) | const |
Returns self as a long double
. If self cannot be converted according to canConvert() using an argument of RWDBValue::LongDouble, returns a long double
with a value of 0
.
long long RWDBValue::asLongLong | ( | ) | const |
Returns self as a long long
. If self cannot be converted according to canConvert() using an argument of RWDBValue::LongLong, returns a long long
with a value of 0
.
RWDBMBString RWDBValue::asMBString | ( | ) | const |
Returns self as an RWDBMBString. Any RWDBValue can be converted to an RWDBMBString.
short RWDBValue::asShort | ( | ) | const |
Returns self as a short
. If self cannot be converted according to canConvert() using an argument of RWDBValue::Short, returns a short
with a value of 0
.
RWCString RWDBValue::asString | ( | const RWDBPhraseBook & | phraseBook | ) | const |
RWCString RWDBValue::asString | ( | ) | const |
unsigned char RWDBValue::asUnsignedChar | ( | ) | const |
Returns self as an unsigned char
. If self cannot be converted according to canConvert() using an argument of RWDBValue::UnsignedChar, returns an unsigned char
with a value of (unsigned char) 0
.
unsigned int RWDBValue::asUnsignedInt | ( | ) | const |
Returns self as an unsigned int
. If self cannot be converted according to canConvert() using an argument of RWDBValue::UnsignedInt, returns an unsigned int
with a value of 0
.
unsigned long RWDBValue::asUnsignedLong | ( | ) | const |
Returns self as an unsigned long
. If self cannot be converted according to canConvert() using an argument of RWDBValue::UnsignedLong, returns an unsigned long
with a value of 0
.
unsigned long long RWDBValue::asUnsignedLongLong | ( | ) | const |
Returns self as an unsigned long long
. If self cannot be converted according to canConvert() using an argument of RWDBValue::UnsignedLongLong, returns an unsigned long long
with a value of 0
.
unsigned short RWDBValue::asUnsignedShort | ( | ) | const |
Returns self as an unsigned short
. If self cannot be converted according to canConvert() using an argument of RWDBValue::UnsignedShort, returns an unsigned short
with a value of 0
.
RWBasicUString RWDBValue::asUString | ( | ) | const |
Returns self as an RWBasicUString. If self cannot be converted according to canConvert() using an argument of RWDBValue::UString, then returns an empty RWBasicUString. If self holds data of type RWDBValue::Blob, conversion to RWBasicUString checks the endian format used by the current system (Big-Endian or Little-Endian) to give the same RWBasicUString data for the same Blob data independent of the endian format of the system.
RWWString RWDBValue::asWString | ( | ) | const |
virtual RWspace RWDBValue::binaryStoreSize | ( | ) | const [virtual] |
Returns the number of bytes required to store self in an RWFile.
Reimplemented from RWCollectable.
bool RWDBValue::canConvert | ( | ValueType | type | ) | const |
Returns true
if self can be converted to type by an RWDBValue::asType() method, otherwise returns false
. Returns true
when:
type
is String and self is a valid representation of a numberThe table below shows the supported type conversions. Each row is a data type to be converted, while each column is a conversion type. A 1
means can convert and a 0
means can't convert. For example, table shows that type Blob can be converted to itself and to String, WString, MBString, and UString.
Supported Type Conversions
Type | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | |
a | NoType | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
b | Char | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
c | UnsignedChar | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
d | Short | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
e | UnsignedShort | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
f | Int | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
g | UnsignedInt | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
h |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0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
s | String | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
t | Blob | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
u | WString | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
v | MBString | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
w | UString | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
1 Conversion to RWDecimalPortable from Double will only be carried out to scale of 6.
RWDBValue aNumber("12345.6789"); assert(aNumber.canConvert(RWDBValue::Char)); char numberThatIsTooSmall = aNumber.asChar(); // No way that 12345.6789 can fit. assert(aNumber.canConvert(RWDBValue::Decimal)); RWDecimalPortable bigEnough = aNumber.asDecimal(); // This is OK.
static RWClassID RWDBValue::classIsA | ( | ) | [static] |
Returns the RWClassID of this class.
Reimplemented from RWCollectable.
virtual int RWDBValue::compareTo | ( | const RWCollectable * | cp | ) | const [virtual] |
Interprets cp as a pointer to an RWDBValue, dereferences it, and compares the result with self. If either self or *cp is NULL
, the result is undefined. Otherwise, if self and *cp have the same type, the result is -1
, 0
, or 1
, depending upon whether or not self is less than, equal to, or greater than *cp, according to the semantics of self's type. Otherwise self and *cp have different types, and the result is defined only as being nonzero.
Reimplemented from RWCollectable.
virtual unsigned RWDBValue::hash | ( | ) | const [virtual] |
Returns a suitable value for hashing.
Reimplemented from RWCollectable.
virtual RWClassID RWDBValue::isA | ( | ) | const [virtual] |
Returns __RWDBVALUE, i.e. a class identifier, that identifies this object's class.
Reimplemented from RWCollectable.
virtual bool RWDBValue::isEqual | ( | const RWCollectable * | cp | ) | const [virtual] |
Returns true
if compareTo( cp ) == 0
, otherwise returns false
.
Reimplemented from RWCollectable.
bool RWDBValue::isNull | ( | ) | const |
Returns true
if self represents a NULL
value, otherwise returns false
. Note that the results of arithmetic and logical operations on NULL
values are undefined; checks for NULL
must be made independently.
virtual RWCollectable* RWDBValue::newSpecies | ( | ) | const [virtual] |
Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it.
Reimplemented from RWCollectable.
RWDBValue& RWDBValue::operator= | ( | const RWBasicUString & | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | const RWDBMBString & | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | const RWDBDuration & | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | const RWDBDateTime & | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | const RWDecimalPortable & | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | long double | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | double | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | float | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | unsigned long long | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | long long | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | unsigned long | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | long | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | unsigned int | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | int | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | unsigned short | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | short | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | unsigned char | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | char | value | ) |
Assigns value's type and value to self.
RWDBValue& RWDBValue::operator= | ( | RWDBValueManip | manip | ) |
Assignment operator. RWDBValue obeys value semantics.
virtual void RWDBValue::restoreGuts | ( | RWvistream & | stream | ) | [virtual] |
Replaces the value of self with a value read from stream.
Reimplemented from RWCollectable.
virtual void RWDBValue::restoreGuts | ( | RWFile & | file | ) | [virtual] |
Replaces the value of self with a value read from file.
Reimplemented from RWCollectable.
virtual void RWDBValue::saveGuts | ( | RWvostream & | stream | ) | const [virtual] |
Writes self to stream.
Reimplemented from RWCollectable.
virtual void RWDBValue::saveGuts | ( | RWFile & | file | ) | const [virtual] |
Writes self to file.
Reimplemented from RWCollectable.
ValueType RWDBValue::type | ( | ) | const |
Returns the data type of self.
RWCString RWDBValue::typeString | ( | ) | const |
Returns the data type of self formatted as a string
.
void rwdbNull | ( | RWDBValue & | ) | [friend] |
rwdbNull is of type RWDBValueManip. It is used to represent a literal NULL
value.
typedef void(* RWDBValueManip)(RWDBValue &) [related] |
RWDBValueManip is a typedef and is typically used to insert a NULL
value.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.