mirror of
https://github.com/boostorg/io.git
synced 2025-07-30 04:17:13 +02:00
Merge branch 'develop'
This commit is contained in:
@ -46,17 +46,21 @@ class osp_guard {
|
|||||||
public:
|
public:
|
||||||
explicit osp_guard(std::basic_ostream<charT, traits>& os) BOOST_NOEXCEPT
|
explicit osp_guard(std::basic_ostream<charT, traits>& os) BOOST_NOEXCEPT
|
||||||
: os_(&os) { }
|
: os_(&os) { }
|
||||||
|
|
||||||
~osp_guard() BOOST_NOEXCEPT_IF(false) {
|
~osp_guard() BOOST_NOEXCEPT_IF(false) {
|
||||||
if (os_) {
|
if (os_) {
|
||||||
os_->setstate(std::basic_ostream<charT, traits>::badbit);
|
os_->setstate(std::basic_ostream<charT, traits>::badbit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void release() BOOST_NOEXCEPT {
|
void release() BOOST_NOEXCEPT {
|
||||||
os_ = 0;
|
os_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osp_guard(const osp_guard&);
|
osp_guard(const osp_guard&);
|
||||||
osp_guard& operator=(const osp_guard&);
|
osp_guard& operator=(const osp_guard&);
|
||||||
|
|
||||||
std::basic_ostream<charT, traits>* os_;
|
std::basic_ostream<charT, traits>* os_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,15 +31,14 @@ inline std::basic_ostream<Char, Traits>&
|
|||||||
operator<<(std::basic_ostream<Char, Traits>& os,
|
operator<<(std::basic_ostream<Char, Traits>& os,
|
||||||
const quoted_proxy<const Char*, Char>& proxy)
|
const quoted_proxy<const Char*, Char>& proxy)
|
||||||
{
|
{
|
||||||
os << proxy.delim;
|
os.put(proxy.delim);
|
||||||
for (const Char* it = proxy.string; *it; ++it) {
|
for (const Char* it = proxy.string; *it; ++it) {
|
||||||
if (*it == proxy.delim || *it == proxy.escape) {
|
if (*it == proxy.delim || *it == proxy.escape) {
|
||||||
os << proxy.escape;
|
os.put(proxy.escape);
|
||||||
}
|
}
|
||||||
os << *it;
|
os.put(*it);
|
||||||
}
|
}
|
||||||
os << proxy.delim;
|
return os.put(proxy.delim);
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Char, class Traits, class Alloc>
|
template<class Char, class Traits, class Alloc>
|
||||||
@ -48,18 +47,16 @@ quoted_output(std::basic_ostream<Char, Traits>& os,
|
|||||||
const std::basic_string<Char, Traits, Alloc>& string, Char escape,
|
const std::basic_string<Char, Traits, Alloc>& string, Char escape,
|
||||||
Char delim)
|
Char delim)
|
||||||
{
|
{
|
||||||
os << delim;
|
os.put(delim);
|
||||||
typename std::basic_string<Char, Traits,
|
|
||||||
Alloc>::const_iterator end = string.end();
|
|
||||||
for (typename std::basic_string<Char, Traits,
|
for (typename std::basic_string<Char, Traits,
|
||||||
Alloc>::const_iterator it = string.begin(); it != end; ++it) {
|
Alloc>::const_iterator it = string.begin(), end = string.end();
|
||||||
|
it != end; ++it) {
|
||||||
if (*it == delim || *it == escape) {
|
if (*it == delim || *it == escape) {
|
||||||
os << escape;
|
os.put(escape);
|
||||||
}
|
}
|
||||||
os << *it;
|
os.put(*it);
|
||||||
}
|
}
|
||||||
os << delim;
|
return os.put(delim);
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Char, class Traits, class Alloc>
|
template <class Char, class Traits, class Alloc>
|
||||||
@ -86,21 +83,20 @@ 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();
|
|
||||||
Char ch;
|
Char ch;
|
||||||
if (!(is >> ch).good()) {
|
if (!(is >> ch)) {
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
if (ch != proxy.delim) {
|
if (ch != proxy.delim) {
|
||||||
is.unget();
|
is.unget();
|
||||||
is >> *proxy.string;
|
return is >> *proxy.string;
|
||||||
return is;
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
boost::io::ios_flags_saver ifs(is);
|
boost::io::ios_flags_saver ifs(is);
|
||||||
std::noskipws(is);
|
std::noskipws(is);
|
||||||
while ((is >> ch).good() && ch != proxy.delim) {
|
proxy.string->clear();
|
||||||
if (ch == proxy.escape && !(is >> ch).good()) {
|
while ((is >> ch) && ch != proxy.delim) {
|
||||||
|
if (ch == proxy.escape && !(is >> ch)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
proxy.string->push_back(ch);
|
proxy.string->push_back(ch);
|
||||||
|
Reference in New Issue
Block a user