File Information
Library: Foundation
Package: Core
Header: Poco/Nullable.h
Description
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 Summary
Member Functions: assign, clear, isNull, operator !=, operator <, operator =, operator ==, operator >, operator C &, operator NullType &, operator const C &, swap, value
Constructors
Nullable
Nullable();
Creates an empty Nullable.
Nullable
Nullable(
const NullType & param342
);
Creates an empty Nullable.
Nullable
Nullable(
const C & value
);
Creates a Nullable with the given value.
Nullable
Nullable(
C && value
);
Creates a Nullable by moving the given value.
Nullable
Nullable(
const Nullable & other
);
Creates a Nullable by copying another one.
Nullable
Nullable(
Nullable && other
) noexcept;
Creates a Nullable by moving another one.
Destructor
~Nullable
~Nullable();
Destroys the Nullable.
Member Functions
assign
Nullable & assign(
const C & value
);
Assigns a value to the Nullable.
assign
Nullable & assign(
C && value
);
Assigns a value to the Nullable.
assign
Nullable & assign(
const Nullable & other
);
Assigns another Nullable.
assign
Sets value to null.
clear
void clear();
Clears the Nullable.
isNull
bool isNull() const;
Returns true if the Nullable is empty.
operator !=
bool operator != (
const C & value
) const;
Compares Nullable with value for non equality
operator !=
bool operator != (
const Nullable < C > & other
) const;
Compares two Nullables for non equality
operator !=
bool operator != (
const NullType & param344
) const;
Compares with NullData for non equality
operator <
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.
operator =
Nullable & operator = (
const C & value
);
Assigns a value to the Nullable.
operator =
Nullable & operator = (
C && value
);
Move-assigns a value to the Nullable.
operator =
Nullable & operator = (
const Nullable & other
);
Assigns another Nullable.
operator =
Nullable & operator = (
Nullable && other
) noexcept;
Moves another Nullable.
operator =
Nullable & operator = (
NullType
);
Assigns another Nullable.
operator ==
bool operator == (
const Nullable < C > & other
) const;
Compares two Nullables for equality
operator ==
bool operator == (
const C & value
) const;
Compares Nullable with value for equality
operator ==
bool operator == (
const NullType & param343
) const;
Compares Nullable with NullData for equality
operator >
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 &
operator C & ();
Get reference to the value
operator NullType &
operator NullType & ();
Get reference to the value
operator const C &
operator const C & () const;
Get const reference to the value
swap
void swap(
Nullable & other
);
Swaps this Nullable with other.
value
C & value();
Returns the Nullable's value.
Throws a NullValueException if the Nullable is empty.
value
const C & value() const;
Returns the Nullable's value.
Throws a NullValueException if the Nullable is empty.
value
const C & value(
const C & deflt
) const;