H3D API  2.4.1
Classes | Functions
H3D::X3D::Convert Namespace Reference

The Convert namespace contains help functions for parsing a string and converting it to a X3D field value. More...

Classes

class  X3DFieldConversionError
 An exception for errors when string to convert to a field value is invalid for the field type. More...
 
class  UnimplementedConversionType
 An exception for errors when the conversion from a string to the type that we try convert to is not implemented. More...
 

Functions

const char * skipWhitespaces (const char *s)
 Skip whitespaces at the beginning of a string. More...
 
const char * skipWhitespacesAndCommas (const char *s)
 Skip whitespaces and commas at the beginning of a string. More...
 
string getQuoteEnclosedStringValue (const char *s, const char *&rest)
 Works the same way as getValue<string>() but with the exception that the string given is within double quotes. More...
 
template<class Type >
Type getValue (const char *s, const char *&rest)
 Function that reads characters from a char * and converts them to a given type. More...
 
template<>
string getValue< string > (const char *s, const char *&rest)
 Template specialization to handle the type 'string'. More...
 
template<>
bool getValue< bool > (const char *s, const char *&rest)
 Template specialization to handle the type 'bool'. More...
 
template<>
double getValue< double > (const char *s, const char *&rest)
 Template specialization to handle the type 'double'. More...
 
template<>
float getValue< float > (const char *s, const char *&rest)
 Template specialization to handle the type 'float'. More...
 
template<>
int getValue< int > (const char *s, const char *&rest)
 Template specialization to handle the type 'int'. More...
 
template<>
RGB getValue< RGB > (const char *s, const char *&rest)
 Template specialization to handle the type 'RGB'. More...
 
template<>
RGBA getValue< RGBA > (const char *s, const char *&rest)
 Template specialization to handle the type 'RGBA'. More...
 
template<>
Rotation getValue< Rotation > (const char *s, const char *&rest)
 Template specialization to handle the type 'Rotation'. More...
 
template<>
Quaternion getValue< Quaternion > (const char *s, const char *&rest)
 Template specialization to handle the type 'Quaternion'. More...
 
template<>
Matrix4f getValue< Matrix4f > (const char *s, const char *&rest)
 Template specialization to handle the type 'Matrix4f'. More...
 
template<>
Matrix3f getValue< Matrix3f > (const char *s, const char *&rest)
 Template specialization to handle the type 'Matrix3f'. More...
 
template<>
Matrix4d getValue< Matrix4d > (const char *s, const char *&rest)
 Template specialization to handle the type 'Matrix4d'. More...
 
template<>
Matrix3d getValue< Matrix3d > (const char *s, const char *&rest)
 Template specialization to handle the type 'Matrix3f'. More...
 
template<>
Vec4f getValue< Vec4f > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec4f'. More...
 
template<>
Vec4d getValue< Vec4d > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec4d'. More...
 
template<>
Vec3f getValue< Vec3f > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec3f'. More...
 
template<>
Vec3d getValue< Vec3d > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec3d'. More...
 
template<>
Vec2f getValue< Vec2f > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec2f'. More...
 
template<>
Vec2d getValue< Vec2d > (const char *s, const char *&rest)
 Template specialization to handle the type 'Vec2d'. More...
 
double atof (const char *s)
 The same as standard atof function with the difference that the decimal point is always . More...
 

Detailed Description

The Convert namespace contains help functions for parsing a string and converting it to a X3D field value.

Function Documentation

◆ atof()

double H3D::X3D::Convert::atof ( const char *  s)
inline

The same as standard atof function with the difference that the decimal point is always .

regardless of locale settings.

On success, the function returns the converted floating point number as a double value. If no valid conversion could be performed, the function returns zero (0.0).

References getValue< double >().

◆ getQuoteEnclosedStringValue()

string H3D::X3D::Convert::getQuoteEnclosedStringValue ( const char *  s,
const char *&  rest 
)
inline

Works the same way as getValue<string>() but with the exception that the string given is within double quotes.

The resulting value will be the string inside the quotes.

Referenced by H3D::X3D::X3DStringToVector< vector< string > >().

◆ getValue()

template<class Type >
Type H3D::X3D::Convert::getValue ( const char *  s,
const char *&  rest 
)
inline

Function that reads characters from a char * and converts them to a given type.

It will use as many characters from the char * as possible to build the value. Used by H3D::X3D::X3DStringToVector and H3D::X3D::X3DStringToValue to read values. The default implementation just returns an exception. Each type that is supported must have a template specialization handling it.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

Referenced by H3D::TypedRefCountField< RefCountedType, BaseRefCountType >::getValue(), H3D::H3DFakeHapticsDevice::GetValueSafeField< BaseField >::getValue(), H3D::ThreadSafeSField< BaseField >::getValue(), H3D::ThreadSafeRefSField< BaseField >::getValue(), H3D::ThreadSafeMField< BaseField >::getValue(), H3D::MFBool::getValueAsString(), H3D::MFString::getValueAsString(), H3D::X3DTexture2DNode::SFImage::getValueAsString(), H3D::Collision::movingSphereIntersect(), H3D::Extrusion::render(), H3D::Contour2D::renderTrimmedCurve(), H3D::MagneticGeometryEffect::traverseSG(), H3D::SpringEffect::traverseSG(), H3D::ColorInterpolator::SFValue::update(), H3D::CoordinateInterpolator::MFValue::update(), H3D::DynamicTransform::SFMatrix4f::update(), H3D::GeometryGroup::IsTouched::update(), H3D::H3DHapticsDevice::TrackerPosition::update(), H3D::H3DHapticsDevice::TrackerOrientation::update(), H3D::H3DHapticsDevice::TrackerAngularVelocity::update(), H3D::H3DWindowNode::WindowSizeChanged::update(), H3D::HumanHand::SFBound::update(), H3D::NurbsCurve::SFBound::update(), H3D::SpaceWareSensor::ScaleRotation::update(), H3D::SpaceWareSensor::ScaleTranslation::update(), H3D::SpaceWareSensor::AccumulateRotation::update(), H3D::SpaceWareSensor::AccumulateTranslation::update(), H3D::Text::SFBound::update(), H3D::TimeSensor::TimeHandler::update(), H3D::X3DTimeDependentNode::TimeHandler::update(), H3D::X3DViewpointNode::SFSumVec3f::update(), H3D::X3DViewpointNode::SFSumRotation::update(), H3D::X3D::X3DStringToVector(), and H3D::X3DTimeDependentNode::X3DTimeDependentNode().

◆ getValue< bool >()

template<>
bool H3D::X3D::Convert::getValue< bool > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'bool'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References skipWhitespaces().

◆ getValue< double >()

template<>
double H3D::X3D::Convert::getValue< double > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'double'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References H3DPow().

Referenced by atof(), and getValue< float >().

◆ getValue< float >()

template<>
float H3D::X3D::Convert::getValue< float > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'float'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References getValue< double >().

◆ getValue< int >()

template<>
int H3D::X3D::Convert::getValue< int > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'int'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

Referenced by H3D::X3D::X3DStringTo2DImage(), and H3D::X3D::X3DStringTo3DImage().

◆ getValue< Matrix3d >()

template<>
Matrix3d H3D::X3D::Convert::getValue< Matrix3d > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Matrix3f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Matrix3f >()

template<>
Matrix3f H3D::X3D::Convert::getValue< Matrix3f > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Matrix3f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Matrix4d >()

template<>
Matrix4d H3D::X3D::Convert::getValue< Matrix4d > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Matrix4d'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Matrix4f >()

template<>
Matrix4f H3D::X3D::Convert::getValue< Matrix4f > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Matrix4f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Quaternion >()

template<>
Quaternion H3D::X3D::Convert::getValue< Quaternion > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Quaternion'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< RGB >()

template<>
RGB H3D::X3D::Convert::getValue< RGB > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'RGB'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< RGBA >()

template<>
RGBA H3D::X3D::Convert::getValue< RGBA > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'RGBA'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Rotation >()

template<>
Rotation H3D::X3D::Convert::getValue< Rotation > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Rotation'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References Rotation().

◆ getValue< string >()

template<>
string H3D::X3D::Convert::getValue< string > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'string'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

Referenced by H3D::X3D::X3DStringToVector< vector< string > >().

◆ getValue< Vec2d >()

template<>
Vec2d H3D::X3D::Convert::getValue< Vec2d > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec2d'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References Vec2d().

◆ getValue< Vec2f >()

template<>
Vec2f H3D::X3D::Convert::getValue< Vec2f > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec2f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References Vec2f().

◆ getValue< Vec3d >()

template<>
Vec3d H3D::X3D::Convert::getValue< Vec3d > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec3d'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References Vec3d().

◆ getValue< Vec3f >()

template<>
Vec3f H3D::X3D::Convert::getValue< Vec3f > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec3f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Vec4d >()

template<>
Vec4d H3D::X3D::Convert::getValue< Vec4d > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec4d'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

◆ getValue< Vec4f >()

template<>
Vec4f H3D::X3D::Convert::getValue< Vec4f > ( const char *  s,
const char *&  rest 
)
inline

Template specialization to handle the type 'Vec4f'.

Parameters
sThe string to convert.
restReturn value pointing at the first character in the string not used in the conversion.

References Vec4f().

◆ skipWhitespaces()

const char* H3D::X3D::Convert::skipWhitespaces ( const char *  s)
inline

Skip whitespaces at the beginning of a string.

Parameters
sThe string to skip whitespace in
Returns
A pointer to the first character in the string that is not a whitespace

Referenced by getValue< bool >(), H3D::X3D::X3DStringTo2DImage(), H3D::X3D::X3DStringTo3DImage(), H3D::X3D::X3DStringToValue(), H3D::X3D::X3DStringToVector(), and H3D::X3D::X3DStringToVector< vector< string > >().

◆ skipWhitespacesAndCommas()

const char* H3D::X3D::Convert::skipWhitespacesAndCommas ( const char *  s)
inline

Skip whitespaces and commas at the beginning of a string.

Parameters
sThe string to skip whitespace in
Returns
A pointer to the first character in the string that is not a whitespace

Referenced by H3D::X3D::X3DStringToVector(), and H3D::X3D::X3DStringToVector< vector< string > >().