NAP
Public Member Functions | List of all members
APIArgument Class Referencefinal

#include <apiargument.h>

Public Member Functions

 APIArgument (std::unique_ptr< APIBaseValue > value)
 
 ~APIArgument ()=default
 
 APIArgument (APIArgument &)=delete
 
APIArgumentoperator= (const APIArgument &)=delete
 
const rtti::TypeInfo getValueType () const
 
const APIBaseValuegetValue () const
 
template<typename T >
T * get ()
 
template<typename T >
const T * get () const
 
template<typename T >
getCopy ()
 
bool isArray () const
 
template<typename T >
const std::vector< T > * asArray () const
 
template<typename T >
std::vector< T > * asArray ()
 
bool isString () const
 
std::string asString () const
 
bool isChar () const
 
char asChar () const
 
bool isByte () const
 
uint8_t asByte () const
 
bool isFloat () const
 
float asFloat () const
 
bool isDouble () const
 
double asDouble () const
 
bool isInt () const
 
int asInt () const
 
bool isBool () const
 
bool asBool () const
 
bool isLong () const
 
int64_t asLong () const
 
const std::string & getName () const
 

Description

Wrapper around an APIValue that can be given to or is received from an external environment. This object can not be copied or moved but the APIValue can be moved and copied. To access the managed APIValue use the get() or getCopy() methods. Use the other methods to translate this argument directly into more common types such as int, string, vector<T> etc.

Constructor & Destructor Documentation

◆ APIArgument() [1/2]

APIArgument ( std::unique_ptr< APIBaseValue value)

Arguments can only be constructed using a value

Parameters
valuethe value associated with this argument, owned by this object.

◆ ~APIArgument()

~APIArgument ( )
default

◆ APIArgument() [2/2]

APIArgument ( APIArgument )
delete

Copy is not allowed

Member Function Documentation

◆ asArray() [1/2]

std::vector< T > * asArray

Returns the API value as a vector of value type T, nullptr if the argument isn't an array or value types don't match.

◆ asArray() [2/2]

const std::vector< T > * asArray

Returns the API value as a vector of value type T, nullptr if the argument isn't an array or value types don't match.

◆ asBool()

bool asBool ( ) const
Returns
this argument's value as a bool

◆ asByte()

uint8_t asByte ( ) const
Returns
this argument's value as a char

◆ asChar()

char asChar ( ) const
Returns
this argument's value as a char

◆ asDouble()

double asDouble ( ) const
Returns
this argument's value as a float

◆ asFloat()

float asFloat ( ) const
Returns
this argument's value as a float

◆ asInt()

int asInt ( ) const
Returns
this argument's value as an int

◆ asLong()

int64_t asLong ( ) const
Returns
this argument's value as a bool

◆ asString()

std::string asString ( ) const
Returns
this argument's value as a string

◆ get() [1/2]

T * get

Returns the API value as a pointer of type T, where T is of type APIValue

Returns
pointer to the API value, nullptr if the api value is not of type T.

◆ get() [2/2]

const T * get

Returns the API value as a pointer of type T, where T is of type APIValue

Returns
pointer to the API value, nullptr if the api value is not of type T.

◆ getCopy()

T getCopy
Returns
a copy of the API value as T, where T is of type APIValue

◆ getName()

const std::string& getName ( ) const
Returns
this argument's name

◆ getValue()

const APIBaseValue& getValue ( ) const
Returns
the api value managed by this argument.

◆ getValueType()

const rtti::TypeInfo getValueType ( ) const

Returns the actual type of the value managed by this argument: RTTI_OF(float), RTTI_OF(int) etc. Note that when this argument represents an array the return value is the value type contained by the array. For example, the return type of an array, say std::vector<float> is RTTI_OF(float).

Returns
the value type represented by this argument.

◆ isArray()

bool isArray ( ) const
Returns
if this argument holds an array

◆ isBool()

bool isBool ( ) const
Returns
if this argument's value is a bool

◆ isByte()

bool isByte ( ) const
Returns
if this argument's value is a char

◆ isChar()

bool isChar ( ) const
Returns
if this argument's value is a char

◆ isDouble()

bool isDouble ( ) const
Returns
if this argument's value is a float

◆ isFloat()

bool isFloat ( ) const
Returns
if this argument's value is a float

◆ isInt()

bool isInt ( ) const
Returns
if this argument's value is an int

◆ isLong()

bool isLong ( ) const
Returns
if this argument's value is a bool

◆ isString()

bool isString ( ) const
Returns
if argument's value is a string

◆ operator=()

APIArgument& operator= ( const APIArgument )
delete