add maybeQuote()

Something for the *NIX gurus
to light their pipes with.
This commit is contained in:
Michael Davidsaver
2020-06-16 16:21:59 -07:00
parent 79b02254c4
commit f17d2bbca1
4 changed files with 62 additions and 14 deletions

View File

@@ -144,8 +144,7 @@ PVString::PVString(ScalarConstPtr const & scalar)
std::ostream& PVString::dumpValue(std::ostream& o) const
{
// we escape, but do not quote, for scalar string
o<<escape(get());
o<<maybeQuote(get());
return o;
}
@@ -233,7 +232,7 @@ std::ostream& PVValueArray<T>::dumpValue(std::ostream& o) const
template<>
std::ostream& PVValueArray<std::string>::dumpValue(std::ostream& o, size_t index) const
{
return o << '"' << escape(this->view().at(index)) << '"';
return o << maybeQuote(this->view().at(index));
}
template<>
@@ -244,9 +243,9 @@ std::ostream& PVValueArray<std::string>::dumpValue(std::ostream& o) const
end(v.end());
o << '[';
if(it!=end) {
o << '"' << escape(*it++) << '"';
o << maybeQuote(*it++);
for(; it!=end; ++it)
o << ", \"" << escape(*it) << '"';
o << ", " << maybeQuote(*it);
}
return o << ']';