mirror of
https://github.com/boostorg/io.git
synced 2025-06-25 03:51:36 +02:00
Make quoted_proxy a trivial type
This commit is contained in:
@ -20,19 +20,10 @@ namespace io {
|
||||
namespace detail {
|
||||
|
||||
template<class String, class Char>
|
||||
class quoted_proxy {
|
||||
public:
|
||||
quoted_proxy(String string_, Char escape_, Char delim_)
|
||||
: string(string_)
|
||||
, escape(escape_)
|
||||
, delim(delim_) { }
|
||||
|
||||
struct quoted_proxy {
|
||||
String string;
|
||||
Char escape;
|
||||
Char delim;
|
||||
|
||||
private:
|
||||
quoted_proxy& operator=(const quoted_proxy&);
|
||||
};
|
||||
|
||||
template<class Char, class Traits>
|
||||
@ -74,35 +65,35 @@ quoted_output(std::basic_ostream<Char, Traits>& os,
|
||||
template <class Char, class Traits, class Alloc>
|
||||
inline std::basic_ostream<Char, Traits>&
|
||||
operator<<(std::basic_ostream<Char, Traits>& os,
|
||||
const quoted_proxy<const std::basic_string<Char, Traits, Alloc>&,
|
||||
const quoted_proxy<const std::basic_string<Char, Traits, Alloc>*,
|
||||
Char>& proxy)
|
||||
{
|
||||
return boost::io::detail::quoted_output(os, proxy.string, proxy.escape,
|
||||
return boost::io::detail::quoted_output(os, *proxy.string, proxy.escape,
|
||||
proxy.delim);
|
||||
}
|
||||
|
||||
template<class Char, class Traits, class Alloc>
|
||||
inline std::basic_ostream<Char, Traits>&
|
||||
operator<<(std::basic_ostream<Char, Traits>& os,
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>& proxy)
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>*, Char>& proxy)
|
||||
{
|
||||
return boost::io::detail::quoted_output(os, proxy.string, proxy.escape,
|
||||
return boost::io::detail::quoted_output(os, *proxy.string, proxy.escape,
|
||||
proxy.delim);
|
||||
}
|
||||
|
||||
template<class Char, class Traits, class Alloc>
|
||||
inline std::basic_istream<Char, Traits>&
|
||||
operator>>(std::basic_istream<Char, Traits>& is,
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>& proxy)
|
||||
const quoted_proxy<std::basic_string<Char, Traits, Alloc>*, Char>& proxy)
|
||||
{
|
||||
proxy.string.clear();
|
||||
proxy.string->clear();
|
||||
Char ch;
|
||||
if (!(is >> ch).good()) {
|
||||
return is;
|
||||
}
|
||||
if (ch != proxy.delim) {
|
||||
is.unget();
|
||||
is >> proxy.string;
|
||||
is >> *proxy.string;
|
||||
return is;
|
||||
}
|
||||
{
|
||||
@ -112,7 +103,7 @@ operator>>(std::basic_istream<Char, Traits>& is,
|
||||
if (ch == proxy.escape && !(is >> ch).good()) {
|
||||
break;
|
||||
}
|
||||
proxy.string.push_back(ch);
|
||||
proxy.string->push_back(ch);
|
||||
}
|
||||
}
|
||||
return is;
|
||||
@ -121,29 +112,32 @@ operator>>(std::basic_istream<Char, Traits>& is,
|
||||
} /* detail */
|
||||
|
||||
template<class Char, class Traits, class Alloc>
|
||||
inline detail::quoted_proxy<const std::basic_string<Char, Traits, Alloc>&,
|
||||
inline detail::quoted_proxy<const std::basic_string<Char, Traits, Alloc>*,
|
||||
Char>
|
||||
quoted(const std::basic_string<Char, Traits, Alloc>& s, Char escape='\\',
|
||||
Char delim='\"')
|
||||
{
|
||||
return detail::quoted_proxy<const std::basic_string<Char, Traits, Alloc>&,
|
||||
Char>(s, escape, delim);
|
||||
detail::quoted_proxy<const std::basic_string<Char, Traits, Alloc>*,
|
||||
Char> proxy = { &s, escape, delim };
|
||||
return proxy;
|
||||
}
|
||||
|
||||
template<class Char, class Traits, class Alloc>
|
||||
inline detail::quoted_proxy<std::basic_string<Char, Traits, Alloc>&, Char>
|
||||
inline detail::quoted_proxy<std::basic_string<Char, Traits, Alloc>*, Char>
|
||||
quoted(std::basic_string<Char, Traits, Alloc>& s, Char escape='\\',
|
||||
Char delim='\"')
|
||||
{
|
||||
return detail::quoted_proxy<std::basic_string<Char, Traits, Alloc>&,
|
||||
Char>(s, escape, delim);
|
||||
detail::quoted_proxy<std::basic_string<Char, Traits, Alloc>*,
|
||||
Char> proxy = { &s, escape, delim };
|
||||
return proxy;
|
||||
}
|
||||
|
||||
template<class Char>
|
||||
inline detail::quoted_proxy<const Char*, Char>
|
||||
quoted(const Char* s, Char escape='\\', Char delim='\"')
|
||||
{
|
||||
return detail::quoted_proxy<const Char*, Char>(s, escape, delim);
|
||||
detail::quoted_proxy<const Char*, Char> proxy = { s, escape, delim };
|
||||
return proxy;
|
||||
}
|
||||
|
||||
} /* io */
|
||||
|
Reference in New Issue
Block a user