macro renamed: PT_HAS_MORM -> PT_HAS_MORM_LIBRARY

TextStream::to_string(...) is now TextStream::to_str(...)
added: std::string TextStream::to_str() const;
added: std::wstring TextStream::to_wstr() const;
This commit is contained in:
2021-06-20 16:46:08 +02:00
parent 819c49e638
commit ac407b2362
6 changed files with 51 additions and 17 deletions

View File

@@ -90,8 +90,11 @@ public:
// IMPROVE ME
// add cbegin(), cend(), rbegin(), rend(), crbegin(), crend()
void to_string(std::string & str, bool clear_string = true) const;
void to_string(std::wstring & str, bool clear_string = true) const;
void to_str(std::string & str, bool clear_string = true) const;
void to_str(std::wstring & str, bool clear_string = true) const;
std::string to_str() const;
std::wstring to_wstr() const;
char_type & operator[](size_t index);
char_type operator[](size_t index) const;
@@ -224,7 +227,7 @@ TextStreamBase<char_type, stack_size, heap_block_size>::end() const
template<typename char_type, size_t stack_size, size_t heap_block_size>
void TextStreamBase<char_type, stack_size, heap_block_size>::to_string(std::string & str, bool clear_string) const
void TextStreamBase<char_type, stack_size, heap_block_size>::to_str(std::string & str, bool clear_string) const
{
if( clear_string )
str.clear();
@@ -250,7 +253,7 @@ void TextStreamBase<char_type, stack_size, heap_block_size>::to_string(std::stri
template<typename char_type, size_t stack_size, size_t heap_block_size>
void TextStreamBase<char_type, stack_size, heap_block_size>::to_string(std::wstring & str, bool clear_string) const
void TextStreamBase<char_type, stack_size, heap_block_size>::to_str(std::wstring & str, bool clear_string) const
{
if( clear_string )
str.clear();
@@ -269,13 +272,41 @@ void TextStreamBase<char_type, stack_size, heap_block_size>::to_string(std::wstr
{
// IMPROVE ME don't use a temporary object
std::string utf8;
to_string(utf8);
to_str(utf8);
utf8_to_wide(utf8, str, false);
}
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
std::string TextStreamBase<char_type, stack_size, heap_block_size>::to_str() const
{
std::string str;
to_str(str, false);
return str;
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
std::wstring TextStreamBase<char_type, stack_size, heap_block_size>::to_wstr() const
{
std::wstring str;
to_str(str, false);
return str;
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
char_type & TextStreamBase<char_type, stack_size, heap_block_size>::operator[](size_t index)