* or is less than the value returned by GetMinValue(). @n
* 2) The specified string contains an invalid value.
* For example, day is 31 when the month is 2.
- * @remarks The format of the string is "mm/dd/yyyy hh:mm:ss.mmm".
+ * @remarks
+ * - The format of the string is "mm/dd/yyyy hh:mm:ss".
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& str, DateTime& dt);
*
* @since 2.1
*
- * @return An long long value indicating the tick of the current instance of %DateTime
+ * @return A long long value indicating the tick of the current instance of %DateTime
*/
long long GetTicks(void) const;
* @param[out] ret The converted numeric value
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, double& ret);
* @param[out] ret The numeric representation of the string
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
* @see Tizen::Base::Double::Parse()
*/
static result Parse(const String& s, float& ret);
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a byte that can be parsed.
- * @remarks This method assumes that the string representing the numeric value
- * uses a radix 10.
+ * @remarks
+ * - This method assumes that the string representing the numeric value uses a radix 10.
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, char& ret);
/**
* Parses the specified string representing a numeric value and
- * returns the value as @c signed @c char (as out parameter).
- *
+ * returns the value as @c signed @c char (as out parameter).
+ *
* @since 2.0
*
* @return The @c signed @c char equivalent of the specified string representing the numeric value using the specified index
* @param[in] s A string representing a numeric value
* @param[in] radix The radix of the string representing a numeric value @n
* It must either be 2, 8, 10, or 16.
- * @param[out] ret The result of the operation
+ * @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
* @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int radix, char& ret);
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @remarks This method assumes that the string representing the numeric value
- * uses a radix 10.
+ * @remarks
+ * - This method assumes that the string representing the numeric value uses a radix 10.
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int& ret);
*
* @return An error code
* @param[in] s A string representing a numeric value
- * @param[in] radix The radix of the string representing the numeric value @n
+ * @param[in] radix The radix of the string representing the numeric value @n
* It must either be 2, 8, 10, or 16.
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int radix, int& ret);
*
* @since 2.0
*
- * @return An error code
- * @param[in] s A string representing a numeric value
- * @param[out] ret The result of the operation
- * @exception E_SUCCESS The method is successful.
- * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @remarks This method assumes that the string representing the numeric value
- * uses a radix 10.
+ * @return An error code
+ * @param[in] s A string representing a numeric value
+ * @param[out] ret The result of the operation
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
+ * @remarks
+ * - This method assumes that the string representing the numeric value uses a radix 10.
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, long& ret);
*
* @return An error code
* @param[in] s A string representing a numeric value
- * @param[in] radix The radix of the string representing a numeric value @n
+ * @param[in] radix The radix of the string representing a numeric value @n
* It must be either 2, 8, 10, or 16.
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int radix, long& ret);
*
* @since 2.0
*
- * @return An error code
- * @param[in] s A string representing a numeric value
- * @param[out] ret The result of the operation
- * @exception E_SUCCESS The method is successful.
- * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @remarks This method assumes that the string representing the numeric value
- * uses a radix 10.
+ * @return An error code
+ * @param[in] s A string representing a numeric value
+ * @param[out] ret The result of the operation
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
+ * @remarks
+ * - This method assumes that the string representing the numeric value uses a radix 10.
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, long long& ret);
*
* @since 2.1
*
- * @return An error code
- * @param[in] s A string representing a numeric value
- * @param[in] radix The radix of the string representing a unmeric value @n
+ * @return An error code
+ * @param[in] s A string representing a numeric value
+ * @param[in] radix The radix of the string representing a unmeric value @n
* It must be either 2, 8, 10 or 16.
- * @param[out] ret The result of the operation
- * @exception E_SUCCESS The method is successful.
- * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @param[out] ret The result of the operation
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
+ * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int radix, long long& ret);
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @remarks The method assumes that the string representing the numeric value
- * uses radix 10.
+ * @remarks
+ * - This method assumes that the string representing the numeric value uses a radix 10.
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, short& ret);
*
* @since 2.0
*
- * @return An error code
- * @param[in] s A string representing a numeric value
- * @param[in] radix The radix of the string representing a numeric value @n
- * It must either be @c 2, @c 8, @c 10, or @c 16.
+ * @return An error code
+ * @param[in] s A string representing a numeric value
+ * @param[in] radix The radix of the string representing a numeric value @n
+ * It must either be @c 2, @c 8, @c 10, or @c 16.
* @param[out] ret The result of the operation
* @exception E_SUCCESS The method is successful.
* @exception E_NUM_FORMAT The specified string does not contain a number that can be parsed.
- * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @exception E_OUT_OF_RANGE The specified @c radix is invalid.
+ * @remarks This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& s, int radix, short& ret);
* @param[out] uuid An instance of %UuId
* @exception E_SUCCESS The method is successful.
* @exception E_INVALID_ARG The string does not contain an %UuId that can be parsed.
- * @remarks The format of a string representing a %UuId value is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (For example, 130DF2EC-8233-4975-B03D-F0AD99E3449D).
+ * @remarks
+ * - The format of a string representing a %UuId value is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (For example, 130DF2EC-8233-4975-B03D-F0AD99E3449D).
+ * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
*/
static result Parse(const String& str, UuId& uuid);
Double::Parse(const String& s, double& ret)
{
wchar_t* pEnd = null;
-
errno = 0;
- ret = wcstod(s.GetPointer(), &pEnd);
- SysTryReturnResult(NID_BASE, ((!(!Double::Compare(ret, 0) && errno == EINVAL)) && (pEnd[0] == 0)), E_NUM_FORMAT,
+ double tmpRet = wcstod(s.GetPointer(), &pEnd);
+ SysTryReturnResult(NID_BASE, ((!(!Double::Compare(tmpRet, 0) && errno == EINVAL)) && (pEnd[0] == 0)), E_NUM_FORMAT,
"Double parse failed with reason (%s). Scan stopped at (%ls)", __ConvertNativeErrorToMessage(errno), pEnd);
- SysTryReturnResult(NID_BASE, !(errno != 0 && (!Double::Compare(ret, HUGE_VAL)|| !Double::Compare(ret, -HUGE_VAL))),
+ SysTryReturnResult(NID_BASE, !(errno != 0 && (!Double::Compare(tmpRet, HUGE_VAL)|| !Double::Compare(tmpRet, -HUGE_VAL))),
E_NUM_FORMAT, "Parsed value cannot fit into a Double.");
+ ret = tmpRet;
return E_SUCCESS;
}
result
Float::Parse(const String& s, float& ret)
{
- wchar_t* pEnd = null;
- ret = 0;
-
SysTryReturn(NID_BASE, s.GetLength() >= 1, E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] The length of s MUST be greater than 0.", GetErrorMessage(E_NUM_FORMAT));
errno = 0;
- ret = wcstof(s.GetPointer(), &pEnd);
+ wchar_t* pEnd = null;
+ float tmpRet = wcstof(s.GetPointer(), &pEnd);
SysTryReturn(NID_BASE, (!Float::Compare(pEnd[0], 0)), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Float parse failed. Scan stopped at (%ls).", GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryReturn(NID_BASE, !((!Float::Compare(ret, HUGE_VAL) || !Float::Compare(ret, -HUGE_VAL)) && (errno != 0)),
+ SysTryReturn(NID_BASE, !((!Float::Compare(tmpRet, HUGE_VAL) || !Float::Compare(tmpRet, -HUGE_VAL)) && (errno != 0)),
E_NUM_FORMAT, E_NUM_FORMAT, "[%s] Parsed value cannot fit into a Float.", GetErrorMessage(E_NUM_FORMAT));
+ ret = tmpRet;
return E_SUCCESS;
}
(radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
- wchar_t* pEnd = null;
- long value = 0;
-
int len = s.GetLength();
SysTryReturn(NID_BASE, (len > 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
GetErrorMessage(E_NUM_FORMAT));
result r = E_SUCCESS;
errno = 0;
- value = wcstol(s.GetPointer(), &pEnd, radix);
- SysTryCatch(NID_BASE, (pEnd[0] == 0), r = E_NUM_FORMAT, E_NUM_FORMAT, "[%s] Int8 parse failed. Scan stopped at (%ls).",
+ wchar_t* pEnd = null;
+ long value = wcstol(s.GetPointer(), &pEnd, radix);
+ SysTryReturn(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] Int8 parse failed. Scan stopped at (%ls).",
GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryCatch(NID_BASE, !((value == LONG_MAX || value == LONG_MIN) && (errno != 0)), r = E_NUM_FORMAT, E_NUM_FORMAT,
+ SysTryReturn(NID_BASE, !((value == LONG_MAX || value == LONG_MIN) && (errno != 0)), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Parsed value cannot fit into an Int8.", GetErrorMessage(E_NUM_FORMAT));
-CATCH:
if (value > Int8::VALUE_MAX)
{
ret = Int8::VALUE_MAX;
}
- else if (value < (signed char) Int8::VALUE_MIN)
+ else if (value < static_cast< signed char >(Int8::VALUE_MIN))
{
- ret = (signed char) Int8::VALUE_MIN;
+ ret = static_cast< signed char >(Int8::VALUE_MIN);
}
else
{
- ret = (char) value;
+ ret = static_cast< char >(value);
}
return r;
(radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
- wchar_t* pEnd = null;
-
int len = s.GetLength();
SysTryReturn(NID_BASE, (len > 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
GetErrorMessage(E_NUM_FORMAT));
errno = 0;
- ret = wcstol(s.GetPointer(), &pEnd, radix);
+ wchar_t* pEnd = null;
+ int tmpRet = wcstol(s.GetPointer(), &pEnd, radix);
SysTryReturn(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Integer parse failed. Scan stopped at (%ls).", GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryReturn(NID_BASE, !((ret == LONG_MAX || ret == LONG_MIN) && (errno != 0)), E_NUM_FORMAT, E_NUM_FORMAT,
+ SysTryReturn(NID_BASE, !((tmpRet == LONG_MAX || tmpRet == LONG_MIN) && (errno != 0)), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Parsed value cannot fit into an Integer.", GetErrorMessage(E_NUM_FORMAT));
+ ret = tmpRet;
return E_SUCCESS;
}
(radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
- wchar_t* pEnd = null;
-
int len = s.GetLength();
SysTryReturn(NID_BASE, (len > 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
GetErrorMessage(E_NUM_FORMAT));
errno = 0;
- ret = wcstol(s.GetPointer(), &pEnd, radix);
+ wchar_t* pEnd = null;
+ long tmpRet = wcstol(s.GetPointer(), &pEnd, radix);
SysTryReturn(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] Long parse failed. Scan stopped at (%ls).",
GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryReturn(NID_BASE, !((ret == LONG_MAX || ret == LONG_MIN) && (errno != 0)), E_NUM_FORMAT, E_NUM_FORMAT,
+ SysTryReturn(NID_BASE, !((tmpRet == LONG_MAX || tmpRet == LONG_MIN) && (errno != 0)), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Parsed value cannot fit into a Long.", GetErrorMessage(E_NUM_FORMAT));
+ ret = tmpRet;
return E_SUCCESS;
}
radix == Character::RADIX_DECIMAL || radix == Character::RADIX_HEXADECIMAL, E_OUT_OF_RANGE,
"[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
- wchar_t* pEnd = null;
-
int len = s.GetLength();
SysTryReturnResult(NID_BASE, (len > 0), E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
GetErrorMessage(E_NUM_FORMAT));
errno = 0;
- ret = wcstoll(s.GetPointer(), &pEnd, radix);
+ wchar_t* pEnd = null;
+ long long tmpRet = wcstoll(s.GetPointer(), &pEnd, radix);
SysTryReturnResult(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, "[%s] LongLong parse failed. Scan stopped at (%ls).",
GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryReturnResult(NID_BASE, !(errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN)), E_NUM_FORMAT,
+ SysTryReturnResult(NID_BASE, !(errno == ERANGE && (tmpRet == LLONG_MAX || tmpRet == LLONG_MIN)), E_NUM_FORMAT,
"[%s] Parsed value cannot fit into a long long.", GetErrorMessage(E_NUM_FORMAT));
+ ret = tmpRet;
return E_SUCCESS;
}
(radix == Character::RADIX_DECIMAL) || (radix == Character::RADIX_HEXADECIMAL)), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[%s] The radix(%d) MUST be one of 2, 8, 10 and 16.", GetErrorMessage(E_OUT_OF_RANGE), radix);
- long value = 0;
- wchar_t* pEnd = null;
-
int len = s.GetLength();
SysTryReturn(NID_BASE, (len > 0), E_NUM_FORMAT, E_NUM_FORMAT, "[%s] The length of s MUST be greater than 0.",
GetErrorMessage(E_NUM_FORMAT));
result r = E_SUCCESS;
errno = 0;
- value = wcstol(s.GetPointer(), &pEnd, radix);
- SysTryCatch(NID_BASE, (pEnd[0] == 0), r = E_NUM_FORMAT, E_NUM_FORMAT,
+ wchar_t* pEnd = null;
+ long value = wcstol(s.GetPointer(), &pEnd, radix);
+ SysTryReturn(NID_BASE, (pEnd[0] == 0), E_NUM_FORMAT, E_NUM_FORMAT,
"[%s] Short parse failed. Scan stopped at (%ls).", GetErrorMessage(E_NUM_FORMAT), pEnd);
- SysTryCatch(NID_BASE, !(value > Short::VALUE_MAX || value < Short::VALUE_MIN) || (errno != 0), r = E_NUM_FORMAT,
+ SysTryReturn(NID_BASE, !(value > Short::VALUE_MAX || value < Short::VALUE_MIN) || (errno != 0), E_NUM_FORMAT,
E_NUM_FORMAT, "[%s] Parsed value cannot fit into Short.", GetErrorMessage(E_NUM_FORMAT));
-CATCH:
if (value > Short::VALUE_MAX)
{
ret = Short::VALUE_MAX;
}
else
{
- ret = (short) value;
+ ret = static_cast< short >(value);
}
return r;