InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stringnumeric Namespace Reference

Functions

void ToWstring (const WideString &src, std::wstring &dest)
 
std::wstring ToWstring (const WideString &src)
 
template<typename T >
ErrorCode FromString (const WideString &str, T &num)
 
template<typename T >
ErrorCode FromString (const WideString &str, int32 precision, T &num)
 
template<>
ErrorCode FromString< PMReal > (const WideString &str, int32 precision, PMReal &num)
 
template<typename T >
ErrorCode ToString (T num, WideString &str)
 
template<typename T >
ErrorCode ToString (T num, int32 precision, WideString &str)
 
template<>
ErrorCode ToString< PMReal > (PMReal num, int32 precision, WideString &str)
 

Detailed Description

Namespace providing string to numeric and numeric to string conversion routines.

Function Documentation

template<typename T >
ErrorCode stringnumeric::FromString (const WideStringstr,
T & num 
)

Converts a WideString to a integral or floating point value. \ Note: 8 bit integral types are currently unsupported.

Parameters
str[IN] Source string. \ Valid signed integral form: [whitespace][{-|+}]digit[digits] \ Valid unsigned integral form: [whitespace][+]digit[digits]
num[OUT] Destination integral or floating point type.
Returns
kSuccess if the conversion succeeds, else an error code.
template<typename T >
ErrorCode stringnumeric::FromString (const WideStringstr,
int32 precision,
T & num 
)

Converts a WideString to a floating point value with a specified precision.

Parameters
str[IN] Source string.
precision[IN] Number of digits after the decimal point. \ -1 for maximum number of display digits.
num[OUT] Destination floating point type.
Returns
kSuccess if the conversion succeeds, else an error code.
template<>
ErrorCode stringnumeric::FromString< PMReal > (const WideStringstr,
int32 precision,
PMRealnum 
)

Converts a WideString to a PMReal.

Parameters
str[IN] Source string.
precision[IN] Number of digits after the decimal point. \ -1 for maximum number of display digits.
num[OUT] Destination PMReal.
Returns
kSuccess if the conversion succeeds, else an error code.
template<typename T >
ErrorCode stringnumeric::ToString (num,
WideStringstr 
)

Converts a integral value or floating point value to a WideString. \ Floating point values are converted using a display precision of 3.

Parameters
num[IN] Source integral or floating point value.
str[OUT] Destination string.
Returns
kSuccess if the conversion succeeds, else an error code.
template<typename T >
ErrorCode stringnumeric::ToString (num,
int32 precision,
WideStringstr 
)

Converts a floating point value to a WideString with a specified precision.

Parameters
num[IN] Source floating point value.
precision[IN] Number of digits after the decimal point. \ -1 for maximum number of display digits.
str[OUT] Destination string.
Returns
kSuccess if the conversion succeeds, else an error code.
template<>
ErrorCode stringnumeric::ToString< PMReal > (PMReal num,
int32 precision,
WideStringstr 
)

Converts a PMReal to a WideString with a specified precision.

Parameters
num[IN] Source PMReal.
precision[IN] Number of digits after the decimal point. \ -1 for maximum number of display digits.
str[OUT] Destination string.
Returns
kSuccess if the conversion succeeds, else an error code.
void stringnumeric::ToWstring (const WideStringsrc,
std::wstring & dest 
)

Converts WideString to a std::wstring. \ Note: wstring uses wchar_t as character type and is 16 bit on Windows and 32 bit on Mac.

Parameters
src[IN] Source string.
dest[OUT] Destination string.
std::wstring stringnumeric::ToWstring (const WideStringsrc)
inline

Converts a WideString to a std::wstring. \ Overloaded for convenience. Beware of the cost (return by value). \ Note: wstring uses wchar_t as character type and is 16 bit on Windows and 32 bit on Mac.

Parameters
src[IN] Source string.
Returns
Resulting std::wstring.