XLL+ Class Library

COper::ReadOptional

Reads an optional argument from an OPER

[C++]
template< class T >
bool ReadOptional(
   T& result,
   const char* pszArgName,
   CString& strError,
   boolean bStrict = false
);
template< class T >
bool ReadOptional(
   T& result,
   const char* pszArgName,
   CXlOper& xloError,
   boolean bStrict = false
);

Parameters

result

If an appropriate value is found, then it is converted to the output type and placed in the variable referenced by this parameter.

If the value is missing or empty, then the value is left unchanged.

If the argument cannot be converted, then the output variable will not be affected.

The following types are directly supported for T:

  • bool
  • long
  • unsigned long
  • int
  • unsigned int
  • short
  • unsigned short
  • double
  • float
  • CString
  • std::string
Any other type is treated as an enumerated type, and converted first to long and then to the specified type.

pszArgName

If the input value cannot be converted to the type of result then this name will be used for the error description; e.g. "#Error: could not convert MyArg".

strError

If the input value cannot be converted to the type of result then an error description will be placed into this variable.

bStrict

If bStrict is set to true, then no attempt will be made to convert strings to numbers and vice versa. If bStrict is false (the default) then standard Excel type transformations will be used.

xloError

If the input value cannot be converted to the type of result then an error description string will be placed into this variable.

Return value

This function returns true or false as follows:

falseThe argument was of an unexpected type and could not be read.
trueThe argument was missing or empty, and the value of result was left unchanged; or the value was present and correct, and the value of result was set.

Requirements

Header: xllplus.h

See Also

COper Class | COper Methods