libsgfc++ 2.0.1
A C++ library that uses SGFC to read and write SGF (Smart Game Format) data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
LibSgfcPlusPlus::SgfcValueConverter Class Reference

The SgfcValueConverter class converts raw string values into value types defined by the SGF standard, and vice versa. More...

#include <SgfcValueConverter.h>

Public Member Functions

 SgfcValueConverter ()
 Initializes a newly constructed SgfcValueConverter object.
 
virtual ~SgfcValueConverter ()
 Destroys and cleans up the SgfcValueConverter object.
 
bool TryConvertStringToNumberValue (const std::string &stringValue, SgfcNumber &outNumberValue, std::string &outTypeConversionErrorMessage) const
 Attempts to convert the specified string value stringValue into an SgfcNumber value. The number is formed by the first sequence of digit characters encountered in stringValue. Whitespace at the beginning is ignored. Plus and minus characters indicate the number's sign. The first non-digit, non-sign, non-whitespace character and all characters beyond are ignored.
 
std::string ConvertNumberValueToString (SgfcNumber numberValue) const
 Converts the specified SgfcNumber numberValue into a string value and returns that string value.
 
bool TryConvertStringToRealValue (const std::string &stringValue, SgfcReal &outRealValue, std::string &outTypeConversionErrorMessage) const
 Attempts to convert the specified string value stringValue into an SgfcReal value. The number is formed by the first sequence of digit and decimal point (".") characters encountered in stringValue. Whitespace at the beginning is ignored. Plus and minus characters indicate the number's sign. The first non-digit, non-decimal point, non-sign, non-whitespace character and all characters beyond are ignored. The only exception is the scientific notation which is also recognized.
 
std::string ConvertRealValueToString (SgfcReal realValue) const
 Converts the specified SgfcReal realValue into a string value and returns that string value.
 
bool TryConvertStringToDoubleValue (const std::string &stringValue, SgfcDouble &outDoubleValue, std::string &outTypeConversionErrorMessage) const
 Attempts to convert the specified string value stringValue into an SgfcDouble value.
 
std::string ConvertDoubleValueToString (SgfcDouble doubleValue) const
 Converts the specified SgfcDouble doubleValue into a string value and returns that string value.
 
bool TryConvertStringToColorValue (const std::string &stringValue, SgfcColor &outColorValue, std::string &outTypeConversionErrorMessage) const
 Attempts to convert the specified string value stringValue into an SgfcColor value.
 
std::string ConvertColorValueToString (SgfcColor colorValue) const
 Converts the specified SgfcColor colorValue into a string value and returns that string value.
 

Detailed Description

The SgfcValueConverter class converts raw string values into value types defined by the SGF standard, and vice versa.

Member Function Documentation

◆ TryConvertStringToColorValue()

bool LibSgfcPlusPlus::SgfcValueConverter::TryConvertStringToColorValue ( const std::string & stringValue,
SgfcColor & outColorValue,
std::string & outTypeConversionErrorMessage ) const

Attempts to convert the specified string value stringValue into an SgfcColor value.

Return values
trueif conversion succeeds. outColorValue in this case holds the converted value. The value of outTypeConversionErrorMessage is undefined.
falseif conversion fails. outTypeConversionErrorMessage in this case holds an error message with a human readable description why the conversion failed. The value of outColorValue is undefined.

◆ TryConvertStringToDoubleValue()

bool LibSgfcPlusPlus::SgfcValueConverter::TryConvertStringToDoubleValue ( const std::string & stringValue,
SgfcDouble & outDoubleValue,
std::string & outTypeConversionErrorMessage ) const

Attempts to convert the specified string value stringValue into an SgfcDouble value.

Return values
trueif conversion succeeds. outDoubleValue in this case holds the converted value. The value of outTypeConversionErrorMessage is undefined.
falseif conversion fails. outTypeConversionErrorMessage in this case holds an error message with a human readable description why the conversion failed. The value of outDoubleValue is undefined.

◆ TryConvertStringToNumberValue()

bool LibSgfcPlusPlus::SgfcValueConverter::TryConvertStringToNumberValue ( const std::string & stringValue,
SgfcNumber & outNumberValue,
std::string & outTypeConversionErrorMessage ) const

Attempts to convert the specified string value stringValue into an SgfcNumber value. The number is formed by the first sequence of digit characters encountered in stringValue. Whitespace at the beginning is ignored. Plus and minus characters indicate the number's sign. The first non-digit, non-sign, non-whitespace character and all characters beyond are ignored.

Conversion succeeds if at least one usable digit character is found. Conversion fails if no usable digit characters are found.

Example: A floating point number is read up to the decimal point.

Return values
trueif conversion succeeds. outNumberValue in this case holds the converted value. The value of outTypeConversionErrorMessage is undefined.
falseif conversion fails. outTypeConversionErrorMessage in this case holds an error message with a human readable description why the conversion failed. The value of outNumberValue is undefined.

◆ TryConvertStringToRealValue()

bool LibSgfcPlusPlus::SgfcValueConverter::TryConvertStringToRealValue ( const std::string & stringValue,
SgfcReal & outRealValue,
std::string & outTypeConversionErrorMessage ) const

Attempts to convert the specified string value stringValue into an SgfcReal value. The number is formed by the first sequence of digit and decimal point (".") characters encountered in stringValue. Whitespace at the beginning is ignored. Plus and minus characters indicate the number's sign. The first non-digit, non-decimal point, non-sign, non-whitespace character and all characters beyond are ignored. The only exception is the scientific notation which is also recognized.

Conversion succeeds if at least one usable digit character is found. Conversion fails if no usable digit characters are found.

Return values
trueif conversion succeeds. outRealValue in this case holds the converted value. The value of outTypeConversionErrorMessage is undefined.
falseif conversion fails. outTypeConversionErrorMessage in this case holds an error message with a human readable description why the conversion failed. The value of outRealValue is undefined.

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