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