Library: Foundation
Package: Core
Header: Poco/Nullable.h
Description
Nullable is a simple wrapper class for value types that allows to introduce a "null" value or state to value objects.
The class is useful for passing parameters to functions when parameters are optional and no default values should be used.
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 =, swap, value
Constructors
Nullable
Nullable();
Creates an empty Nullable.
Nullable
Nullable(
const C & value
);
Creates a Nullable with the given value.
Nullable
Nullable(
const Nullable & other
);
Creates a Nullable by copying 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(
const Nullable & other
);
Assigns another Nullable.
clear
void clear();
Clears the Nullable.
isNull
bool isNull() const;
Returns true if and only if the Nullable is empty.
operator =
Nullable & operator = (
const C & value
);
operator =
Nullable & operator = (
const Nullable & other
);
swap
void swap(
Nullable & other
);
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;