add to Space methods which takes a Stream as an argument

- Space::set(const Stream & stream)
- Space::add(const Stream & stream)
- Space::add(const wchar_t * field, const Stream & stream)
- Space::add(const std::wstring & field, const Stream & stream)
This commit is contained in:
Tomasz Sowa 2022-08-20 00:26:12 +02:00
parent 7eba07a439
commit ce0348b2d7
2 changed files with 59 additions and 0 deletions

View File

@ -446,6 +446,20 @@ void Space::set(const std::wstring & str)
value.value_wstring = str; value.value_wstring = str;
} }
void Space::set(const Stream & stream)
{
if( stream.is_char_stream() )
{
initialize_value_string_if_needed();
stream.to_str(value.value_string);
}
else
{
initialize_value_wstring_if_needed();
stream.to_str(value.value_wstring);
}
}
void Space::set(const Space & space) void Space::set(const Space & space)
{ {
copy_from(space); copy_from(space);
@ -567,6 +581,24 @@ Space & Space::add(const std::wstring & val)
return add_generic(val); return add_generic(val);
} }
Space & Space::add(const Stream & stream)
{
if( stream.is_char_stream() )
{
pt::Space & new_item = add_empty_space();
new_item.set_empty_string();
stream.to_str(new_item.value.value_string);
return new_item;
}
else
{
pt::Space & new_item = add_empty_space();
new_item.set_empty_wstring();
stream.to_str(new_item.value.value_wstring);
return new_item;
}
}
Space & Space::add(const Space & space) Space & Space::add(const Space & space)
{ {
return add_generic(space); return add_generic(space);
@ -690,6 +722,24 @@ Space & Space::add(const wchar_t * field, const std::wstring & val)
return add_generic(field, val); return add_generic(field, val);
} }
Space & Space::add(const wchar_t * field, const Stream & stream)
{
if( stream.is_char_stream() )
{
pt::Space & new_item = add_empty_space(field);
new_item.set_empty_string();
stream.to_str(new_item.value.value_string);
return new_item;
}
else
{
pt::Space & new_item = add_empty_space(field);
new_item.set_empty_wstring();
stream.to_str(new_item.value.value_wstring);
return new_item;
}
}
Space & Space::add(const wchar_t * field, const Space & space) Space & Space::add(const wchar_t * field, const Space & space)
{ {
return add_generic(field, space); return add_generic(field, space);
@ -822,6 +872,11 @@ Space & Space::add(const std::wstring & field, const std::wstring & val)
return add_generic_string(field, val); return add_generic_string(field, val);
} }
Space & Space::add(const std::wstring & field, const Stream & stream)
{
return add(field.c_str(), stream);
}
Space & Space::add(const std::wstring & field, const Space & space) Space & Space::add(const std::wstring & field, const Space & space)
{ {
return add_generic_string(field, space); return add_generic_string(field, space);

View File

@ -242,6 +242,7 @@ public:
void set(const wchar_t * str, size_t len); void set(const wchar_t * str, size_t len);
void set(const std::string & str); void set(const std::string & str);
void set(const std::wstring & str); void set(const std::wstring & str);
void set(const Stream & stream);
void set(const Space & space); void set(const Space & space);
void set(const Space * space); void set(const Space * space);
void set(Space && space); void set(Space && space);
@ -267,6 +268,7 @@ public:
Space & add_to_table(const wchar_t * val, size_t len); // the name add would collapse with add(const wchar_t * field, unsigned long val) below; Space & add_to_table(const wchar_t * val, size_t len); // the name add would collapse with add(const wchar_t * field, unsigned long val) below;
Space & add(const std::string & val); Space & add(const std::string & val);
Space & add(const std::wstring & val); Space & add(const std::wstring & val);
Space & add(const Stream & stream);
Space & add(const Space & space); Space & add(const Space & space);
Space & add(const Space * space); Space & add(const Space * space);
Space & add(Space && space); Space & add(Space && space);
@ -294,6 +296,7 @@ public:
Space & add(const wchar_t * field, const wchar_t * val, size_t len); Space & add(const wchar_t * field, const wchar_t * val, size_t len);
Space & add(const wchar_t * field, const std::string & val); Space & add(const wchar_t * field, const std::string & val);
Space & add(const wchar_t * field, const std::wstring & val); Space & add(const wchar_t * field, const std::wstring & val);
Space & add(const wchar_t * field, const Stream & stream);
Space & add(const wchar_t * field, const Space & space); Space & add(const wchar_t * field, const Space & space);
Space & add(const wchar_t * field, const Space * space); Space & add(const wchar_t * field, const Space * space);
Space & add(const wchar_t * field, Space && space); Space & add(const wchar_t * field, Space && space);
@ -318,6 +321,7 @@ public:
Space & add(const std::wstring & field, const wchar_t * val, size_t len); Space & add(const std::wstring & field, const wchar_t * val, size_t len);
Space & add(const std::wstring & field, const std::string & val); Space & add(const std::wstring & field, const std::string & val);
Space & add(const std::wstring & field, const std::wstring & val); Space & add(const std::wstring & field, const std::wstring & val);
Space & add(const std::wstring & field, const Stream & stream);
Space & add(const std::wstring & field, const Space & space); Space & add(const std::wstring & field, const Space & space);
Space & add(const std::wstring & field, const Space * space); Space & add(const std::wstring & field, const Space * space);
Space & add(const std::wstring & field, Space && space); Space & add(const std::wstring & field, Space && space);