Beispiel #1
0
Char16
String::toChar16() const
{
	if (UTF8Length() != 1)
	{
		throwStringConversion(c_str(), "Char16");
	}
	return Char16(*this);
}
Beispiel #2
0
static inline
T convertToRealType(const String::buf_t& m_buf, const char* type, FP fp)
{
	if (m_buf)
	{
		char* endptr(0);
		errno = 0;		// errno is thread local
		T rv = fp(m_buf->data(), &endptr);
		if (*endptr != '\0' || errno == ERANGE || rv == HUGE_VAL || rv == -HUGE_VAL)
		{
			throwStringConversion(m_buf, type);
		}
		return rv;
	}
	else
	{
		throwStringConversion("", type);
	}
	return T(); // to make compiler happy
}
Beispiel #3
0
static inline
T doConvertToIntType(const String::buf_t& m_buf, const char* type, FP fp, int base)
{
	if (m_buf)
	{
		char* endptr(0);
		errno = 0;		// errno is thread local
		FPRT v = fp(m_buf->data(), &endptr, base);
		T rv = static_cast<T>(v);
		if (*endptr != '\0' || errno == ERANGE || FPRT(rv) != v)
		{
			throwStringConversion(m_buf, type);
		}
		return rv;
	}
	else
	{
		throwStringConversion("", type);
	}
	return T(); // to make compiler happy
}
Beispiel #4
0
static inline
T doConvertToIntType(const String::buf_t& m_buf, const char* type, FP fp, int base)
{
	// the error detecting code below won't detect an empty string, so
	// we have to check for it explicitly.
	if (m_buf && m_buf->length() > 0)
	{
		char* endptr(0);
		errno = 0;		// errno is thread local
		FPRT v = fp(m_buf->data(), &endptr, base);
		T rv = static_cast<T>(v);
		if (*endptr != '\0' || errno == ERANGE || FPRT(rv) != v)
		{
			throwStringConversion(m_buf, type);
		}
		return rv;
	}
	else
	{
		throwStringConversion("", type);
	}
	return T(); // to make compiler happy
}
Beispiel #5
0
bool
String::toBool() const
{
	if (equalsIgnoreCase("true"))
	{
		return true;
	}
	else if (equalsIgnoreCase("false"))
	{
		return false;
	}
	else
	{
		throwStringConversion(c_str(), "bool");
	}
	return false; // to make compiler happy
}