added to Space: long double to Space::Value and methods for converting from/to long double
added global methods for converting float/string double/string and long double/string (convert/double.h|cpp): float to_float(const char * str, const char ** after = nullptr); float to_float(const wchar_t * str, const wchar_t ** after = nullptr); double to_double(const char * str, const char ** after = nullptr); double to_double(const wchar_t * str, const wchar_t ** after = nullptr); long double to_long_double(const char * str, const char ** after = nullptr); long double to_long_double(const wchar_t * str, const wchar_t ** after = nullptr); float to_float(const std::string & str, const char ** after = nullptr); float to_float(const std::wstring & str, const wchar_t ** after = nullptr); double to_double(const std::string & str, const char ** after = nullptr); double to_double(const std::wstring & str, const wchar_t ** after = nullptr); long double to_long_double(const std::string & str, const char ** after = nullptr); long double to_long_double(const std::wstring & str, const wchar_t ** after = nullptr); std::string to_str(float val); std::wstring to_wstr(float val); std::string to_str(double val); std::wstring to_wstr(double val); std::string to_str(long double val); std::wstring to_wstr(long double val);
This commit is contained in:
@@ -124,6 +124,10 @@ public:
|
||||
TextStreamBase & operator<<(const Space & space);
|
||||
TextStreamBase & operator<<(const Date & date);
|
||||
|
||||
char get_char(size_t index) const;
|
||||
wchar_t get_wchar(size_t index) const;
|
||||
|
||||
|
||||
// min width for integer output
|
||||
// if the output value has less digits then first zeroes are added
|
||||
// (0 turn off)
|
||||
@@ -518,7 +522,7 @@ TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(double v)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, sizeof(buf)/sizeof(char), "%f", v);
|
||||
snprintf(buf, sizeof(buf)/sizeof(char), "%g", v);
|
||||
return operator<<(buf);
|
||||
}
|
||||
|
||||
@@ -529,7 +533,7 @@ TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(long double v
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
snprintf(buf, sizeof(buf)/sizeof(char), "%Lf", v);
|
||||
snprintf(buf, sizeof(buf)/sizeof(char), "%Lg", v);
|
||||
return operator<<(buf);
|
||||
}
|
||||
|
||||
@@ -635,6 +639,21 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
char TextStreamBase<char_type, stack_size, heap_block_size>::get_char(size_t index) const
|
||||
{
|
||||
return static_cast<char>(buffer[index]);
|
||||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
wchar_t TextStreamBase<char_type, stack_size, heap_block_size>::get_wchar(size_t index) const
|
||||
{
|
||||
return static_cast<wchar_t>(buffer[index]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
|
Reference in New Issue
Block a user