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;
htmlparserlistener
Tomasz Sowa 2 years ago
parent 819c49e638
commit ac407b2362

@ -41,7 +41,7 @@
#include "date/date.h"
#include "utf8/utf8.h"
#ifdef PT_HAS_MORM
#ifdef PT_HAS_MORM_LIBRARY
#include "morm.h"
#endif
@ -313,7 +313,7 @@ Log & Log::operator<<(const Date & date)
}
#ifdef PT_HAS_MORM
#ifdef PT_HAS_MORM_LIBRARY
Log & Log::operator<<(morm::Model & model)
{
operator<<(model.to_string());

@ -131,7 +131,7 @@ public:
virtual Log & operator<<(const Space & space);
virtual Log & operator<<(const Date & date);
#ifdef PT_HAS_MORM
#ifdef PT_HAS_MORM_LIBRARY
virtual Log & operator<<(morm::Model & model);
#endif

@ -954,7 +954,7 @@ std::string Space::to_str() const
{
TextStream stream;
serialize_string_buffer(value.value_wstring.c_str(), value.value_wstring.size(), stream, Escape::no_escape);
stream.to_string(str);
stream.to_str(str);
return str;
}
@ -1310,7 +1310,7 @@ void Space::serialize_to_space_to(std::string & str, bool pretty_print) const
TextStream stream;
serialize_to_space_stream(stream, pretty_print);
stream.to_string(str);
stream.to_str(str);
}
@ -1319,7 +1319,7 @@ void Space::serialize_to_space_to(std::wstring & str, bool pretty_print) const
WTextStream stream;
serialize_to_space_stream(stream, pretty_print);
stream.to_string(str);
stream.to_str(str);
}
@ -1345,7 +1345,7 @@ void Space::serialize_to_json_to(std::string & str) const
TextStream stream;
serialize_to_json_stream(stream);
stream.to_string(str);
stream.to_str(str);
}
@ -1354,7 +1354,7 @@ void Space::serialize_to_json_to(std::wstring & str) const
WTextStream stream;
serialize_to_json_stream(stream);
stream.to_string(str);
stream.to_str(str);
}

@ -314,7 +314,7 @@ public:
Space & add_stream(const wchar_t * field, StreamType & str)
{
std::wstring temp;
str.to_string(temp);
str.to_str(temp);
return add(field, temp);
}
@ -323,7 +323,7 @@ public:
Space & add_stream(const std::wstring & field, StreamType & str)
{
std::wstring temp;
str.to_string(temp);
str.to_str(temp);
return add(field, temp);
}

@ -61,8 +61,11 @@ public:
virtual void reserve(size_t len) = 0;
virtual size_t capacity() const = 0;
virtual void to_string(std::string & str, bool clear_string = true) const = 0;
virtual void to_string(std::wstring & str, bool clear_string = true) const = 0;
virtual void to_str(std::string & str, bool clear_string = true) const = 0;
virtual void to_str(std::wstring & str, bool clear_string = true) const = 0;
virtual std::string to_str() const = 0;
virtual std::wstring to_wstr() const = 0;
virtual Stream & operator<<(const char * str) = 0;
virtual Stream & operator<<(const std::string & str) = 0;

@ -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)

Loading…
Cancel
Save