Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::ConstantDefinition Class Reference

Class for constant definitions. More...

#include <ServiceDefinition.h>

Public Member Functions

 ConstantDefinition (const boost::shared_ptr< ServiceDefinition > &service)
 Construct a new ConstantDefinition with a parent ServiceDefinition.
 ConstantDefinition (const boost::shared_ptr< ServiceEntryDefinition > &service_entry)
 Construct a new ConstantDefinition with a parent ServiceEntryDefinition.
std::string ToString ()
 Convert constant definition to string.
void FromString (boost::string_ref s, const ServiceDefinitionParseInfo *parse_info=NULL)
 Parse a constant definition from string.
void Reset ()
 Clear all fields.
bool VerifyValue () const
 Verify that this constant definition has a valid value.
template<typename T>
ValueToScalar () const
 Convert the constant value to a numeric scalar.
template<typename T>
boost::intrusive_ptr< RRArray< T > > ValueToArray () const
 Convert the constant scalar to a numeric primitive array.
std::string ValueToString ()
 Convert the constant value to string.
std::vector< ConstantDefinition_StructFieldValueToStructFields () const
 Convert the constant value to structure fields.

Static Public Member Functions

static bool VerifyTypeAndValue (TypeDefinition &t, boost::string_ref value)
 Verify that the specified constant type and value are valid.

Public Attributes

std::string Name
 The name of the constant.
boost::shared_ptr< TypeDefinitionType
 The value type of the constant.
std::string Value
 The value of the constant, as a string.
std::string DocString
 Documentation string for the constant.
RR_WEAK_PTR< ServiceDefinitionservice
 The parent service definition.
RR_WEAK_PTR< ServiceEntryDefinitionservice_entry
 The parent service entry.
ServiceDefinitionParseInfo ParseInfo
 Parsing diagnostic information.

Detailed Description

Class for constant definitions.

See service_definitions.md for more information.

Constructor & Destructor Documentation

◆ ConstantDefinition() [1/2]

RobotRaconteur::ConstantDefinition::ConstantDefinition ( const boost::shared_ptr< ServiceDefinition > & service)

Construct a new ConstantDefinition with a parent ServiceDefinition.

Must be constructed with boost::make_shared<ConstantDefinition>()

Parameters
serviceThe parent service definition

◆ ConstantDefinition() [2/2]

RobotRaconteur::ConstantDefinition::ConstantDefinition ( const boost::shared_ptr< ServiceEntryDefinition > & service_entry)

Construct a new ConstantDefinition with a parent ServiceEntryDefinition.

Must be constructed with boost::make_shared<ConstantDefinition>()

Parameters
service_entryThe parent service entry definition

Member Function Documentation

◆ FromString()

void RobotRaconteur::ConstantDefinition::FromString ( boost::string_ref s,
const ServiceDefinitionParseInfo * parse_info = NULL )

Parse a constant definition from string.

Parameters
sThe constant definition string
parse_infoParsing diagnostic information

◆ ToString()

std::string RobotRaconteur::ConstantDefinition::ToString ( )

Convert constant definition to string.

Returns
std::string The constant definition string

◆ ValueToArray()

template<typename T>
boost::intrusive_ptr< RRArray< T > > RobotRaconteur::ConstantDefinition::ValueToArray ( ) const
inline

Convert the constant scalar to a numeric primitive array.

Template Parameters
TThe numeric primitive type
Returns
RR_INTRUSIVE_PTR<RRArray<T> > The numeric primitive array

◆ ValueToScalar()

template<typename T>
T RobotRaconteur::ConstantDefinition::ValueToScalar ( ) const
inline

Convert the constant value to a numeric scalar.

Template Parameters
TThe numeric scalar type
Returns
T The numeric scalar

◆ ValueToString()

std::string RobotRaconteur::ConstantDefinition::ValueToString ( )

Convert the constant value to string.

Returns
std::string The constant value as a string

◆ ValueToStructFields()

std::vector< ConstantDefinition_StructField > RobotRaconteur::ConstantDefinition::ValueToStructFields ( ) const

Convert the constant value to structure fields.

Returns
std::vector<ConstantDefinition_StructField> The constant as structure fields

◆ VerifyTypeAndValue()

bool RobotRaconteur::ConstantDefinition::VerifyTypeAndValue ( TypeDefinition & t,
boost::string_ref value )
static

Verify that the specified constant type and value are valid.

Parameters
tThe type of the constant
valueThe value of the constant
Returns
true The type and value are valid
false The type and/or value are invalid

◆ VerifyValue()

bool RobotRaconteur::ConstantDefinition::VerifyValue ( ) const

Verify that this constant definition has a valid value.

Returns
true The constant definition value is valid
false The constant definition value is invalid

Member Data Documentation

◆ ParseInfo

ServiceDefinitionParseInfo RobotRaconteur::ConstantDefinition::ParseInfo

Parsing diagnostic information.

The ParseInfo field is populated by FromString()

◆ service

RR_WEAK_PTR<ServiceDefinition> RobotRaconteur::ConstantDefinition::service

The parent service definition.

service and service_entry are mutually exclusive

◆ service_entry

RR_WEAK_PTR<ServiceEntryDefinition> RobotRaconteur::ConstantDefinition::service_entry

The parent service entry.

service and service_entry are mutually exclusive


The documentation for this class was generated from the following file: