Template class which implements a variant object, with or without ownership semantics.
The object can represent a string or a double number, and maps directly to the underlying AMPL type system. It is not intended to be used directly, please use Variant (with ownership semantics, each object stores the values that it represents) or VariantRef (without ownership semantics, each object is only a reference to values stored elsewhere).
Public Functions
-
inline explicit BasicVariant(internal::Variant var)
Constructor from POD data type.
If the BasicVariant has ownership semantics, it owns the POD data (deleting it when the BasicVariant is deleted and copying it when it is copied).
-
inline explicit BasicVariant(internal::Variant *var)
-
inline BasicVariant()
Default constructor, creates an empty variant.
-
inline BasicVariant(int value)
Creates a numeric variant with the specified value.
-
inline BasicVariant(unsigned value)
Creates a numeric variant with the specified value.
-
inline BasicVariant(long value)
Creates a numeric variant with the specified value.
-
inline BasicVariant(unsigned long value)
Creates a numeric variant with the specified value.
-
inline BasicVariant(double value)
Creates a numeric variant with the specified value.
-
inline BasicVariant(const std::string &value)
Creates a string variant which references or owns a copy of the specified string.
-
inline BasicVariant(const char *value)
Creates a string variant which references or owns a copy of the specified string literal.
-
inline BasicVariant(const BasicVariant &other)
Copy constructor.
If OWNING
copy the resources
-
template<bool U>
inline BasicVariant(BasicVariant<U> const &other)
Coercing copy constructor.
-
inline ~BasicVariant()
Destructor.
If OWNING
frees the resources.
-
template<bool U>
inline BasicVariant &operator=(const BasicVariant<U> &other)
Coercing assignment operator.
-
inline BasicVariant &operator=(const BasicVariant &other)
Assignment operator.
-
inline const char *c_str() const
Returns the pointer to a C string.
-
inline double dbl() const
Returns the numerical value.
-
inline std::string str() const
Converts an AMPL variant element to an std::string
object.
-
inline Type type() const
Returns the type of this variant object.
-
inline internal::Variant impl() const
Get the inner POD struct.
-
inline internal::Variant *impl_ptr()
-
inline std::string toString() const
Return an AMPL like representation of this variant.
String variants are single-quoted, numeric are not.