Library: Foundation
Package: Core
Header: Poco/Nullable.h
Nullable is a simple wrapper class for value types that allows objects or native type variables to have "null" value.
The class is useful for passing parameters to functions when parameters are optional and no default values should be used or when a non-assigned state is needed, such as in e.g. fetching null values from database.
A Nullable can be default constructed. In this case, the Nullable will have a Null value and isNull() will return true. Calling value() (without default value) on a Null object will throw a NullValueException.
A Nullable can also be constructed from a value. It is possible to assign a value to a Nullable, and to reset a Nullable to contain a Null value by calling clear().
For use with Nullable, the value type should support default construction.
Member Functions: assign, clear, isNull, operator !=, operator <, operator =, operator ==, operator >, operator C &, operator NullType &, operator const C &, swap, value
Nullable();
Creates an empty Nullable.
Nullable(
const NullType & param205
);
Creates an empty Nullable.
Nullable(
const C & value
);
Creates a Nullable with the given value.
Nullable(
const Nullable & other
);
Creates a Nullable by copying another one.
~Nullable();
Destroys the Nullable.
Nullable & assign(
const C & value
);
Assigns a value to the Nullable.
Nullable & assign(
const Nullable & other
);
Assigns another Nullable.
Sets value to null.
void clear();
Clears the Nullable.
bool isNull() const;
Returns true if the Nullable is empty.
bool operator != (
const C & value
) const;
Compares Nullable with value for non equality
bool operator != (
const Nullable < C > & other
) const;
Compares two Nullables for non equality
bool operator != (
const NullType & param207
) const;
Compares with NullData for non equality
bool operator < (
const Nullable < C > & other
) const;
Compares two Nullable objects. Return true if this object's value is smaler than the other object's value. Null value is smaller than a non-null value.
Nullable & operator = (
const C & value
);
Assigns a value to the Nullable.
Nullable & operator = (
const Nullable & other
);
Assigns another Nullable.
Nullable & operator = (
NullType
);
Assigns another Nullable.
bool operator == (
const Nullable < C > & other
) const;
Compares two Nullables for equality
bool operator == (
const C & value
) const;
Compares Nullable with value for equality
bool operator == (
const NullType & param206
) const;
Compares Nullable with NullData for equality
bool operator > (
const Nullable < C > & other
) const;
Compares two Nullable objects. Return true if this object's value is greater than the other object's value. A non-null value is greater than a null value.
operator C & ();
Get reference to the value
operator NullType & ();
Get reference to the value
operator const C & () const;
Get const reference to the value
void swap(
Nullable & other
);
Swaps this Nullable with other.
C & value();
Returns the Nullable's value.
Throws a NullValueException if the Nullable is empty.
const C & value() const;
Returns the Nullable's value.
Throws a NullValueException if the Nullable is empty.
const C & value(
const C & deflt
) const;