From df0f93e3b5836d6bf941756a57d4689559024383 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 9 Jun 2010 11:34:33 +0000 Subject: [PATCH 1/6] v2, v3, integration branch [SVN r62649] From 292f21393cd8ec16cc11eba38aa2974ae0eacb00 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 17 Jun 2010 16:09:50 +0000 Subject: [PATCH 2/6] Move header, provide all template parameters, clean up code [SVN r63042] --- include/boost/io/quote_manip.hpp | 179 +++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 include/boost/io/quote_manip.hpp diff --git a/include/boost/io/quote_manip.hpp b/include/boost/io/quote_manip.hpp new file mode 100644 index 0000000..3a98ca0 --- /dev/null +++ b/include/boost/io/quote_manip.hpp @@ -0,0 +1,179 @@ +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +//--------------------------------------------------------------------------------------// + +#ifndef BOOST_QUOTE_MANIP +#define BOOST_QUOTE_MANIP + +#include +#include +#include +#include + +namespace boost +{ + namespace io + { + namespace detail { // forward declare the helpers + template struct quote_proxy; + template struct c_str_quote_proxy; + template struct unquote_proxy; + } + + // ------------ public interface ------------------------------------------------// + + template + detail::quote_proxy + quote(const std::basic_string& s, + Char escape='\\', Char delim='\"'); + + template + detail::c_str_quote_proxy + quote(const Char* s, Char escape='\\', Char delim='\"'); + + template + detail::unquote_proxy + unquote(std::basic_string& s, + Char escape='\\', Char delim='\"'); + + // ----------- implementation details -------------------------------------------// + + namespace detail + { + // string inserter helpers + + template + struct quote_proxy + { + const std::basic_string& s; + Char escape; + Char delim; + + quote_proxy(const std::basic_string& s_, + Char escape_, Char delim_) + : s(s_), escape(escape_), delim(delim_) {} + }; + + template + std::basic_ostream& operator<<(std::basic_ostream& os, + quote_proxy& proxy) + { + os << proxy.delim; + std::basic_string::const_iterator end_it = proxy.s.end(); + for (std::basic_string::const_iterator it = proxy.s.begin(); + it != end_it; + ++it ) + { + if (*it == proxy.delim || *it == proxy.escape) + os << proxy.escape; + os << *it; + } + os << proxy.delim; + return os; + } + + // c_str inserter helpers + + template + struct c_str_quote_proxy + { + const Char* s; + Char escape; + Char delim; + + c_str_quote_proxy(const Char* s_, Char escape_, Char delim_) + : s(s_), escape(escape_), delim(delim_) {} + }; + + template + std::basic_ostream& operator<<(std::basic_ostream& os, + c_str_quote_proxy& proxy) + { + os << proxy.delim; + for (const Char* it = proxy.s; + *it; + ++it ) + { + if (*it == proxy.delim || *it == proxy.escape) + os << proxy.escape; + os << *it; + } + os << proxy.delim; + return os; + } + + // string extractor helpers + + template + struct unquote_proxy + { + std::basic_string& s; + Char escape; + Char delim; + + unquote_proxy(std::basic_string& s_, + Char escape_, Char delim_) + : s(s_), escape(escape_), delim(delim_) {} + }; + + template + std::basic_istream& operator>>(std::basic_istream& is, + unquote_proxy& proxy) + { + Char c; + is >> c; + if (c != proxy.delim) + { + proxy.s = c; + is >> proxy.s; + return is; + } + proxy.s.clear(); + { + boost::io::ios_flags_saver ifs(is); + is >> std::noskipws; + for (;;) + { + is >> c; + if (c == proxy.escape) + is >> c; + else if (c == proxy.delim) + break; + proxy.s += c; + } + } + return is; + } + + } // namespace detail + + // manipulator implementations + + template + inline detail::quote_proxy + quote(const std::basic_string& s, Char escape, Char delim) + { + return detail::quote_proxy(s, escape, delim); + } + + template + inline detail::c_str_quote_proxy + quote(const Char* s, Char escape, Char delim) + { + return detail::c_str_quote_proxy(s, escape, delim); + } + + template + inline detail::unquote_proxy + unquote(std::basic_string& s, Char escape, Char delim) + { + return detail::unquote_proxy(s, escape, delim); + } + + } // namespace io +} // namespace boost + +#endif // BOOST_QUOTE_MANIP From fa2be5fde6bc9549c27d43145b24ec2ea2b59cb4 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 18 Jun 2010 00:59:40 +0000 Subject: [PATCH 3/6] Accept a number of Eric Niebler's suggestions, including renaming. [SVN r63074] --- include/boost/io/quote_manip.hpp | 179 ------------------------------ include/boost/io/quoted_manip.hpp | 158 ++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 179 deletions(-) delete mode 100644 include/boost/io/quote_manip.hpp create mode 100644 include/boost/io/quoted_manip.hpp diff --git a/include/boost/io/quote_manip.hpp b/include/boost/io/quote_manip.hpp deleted file mode 100644 index 3a98ca0..0000000 --- a/include/boost/io/quote_manip.hpp +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright Beman Dawes 2010 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt - -//--------------------------------------------------------------------------------------// - -#ifndef BOOST_QUOTE_MANIP -#define BOOST_QUOTE_MANIP - -#include -#include -#include -#include - -namespace boost -{ - namespace io - { - namespace detail { // forward declare the helpers - template struct quote_proxy; - template struct c_str_quote_proxy; - template struct unquote_proxy; - } - - // ------------ public interface ------------------------------------------------// - - template - detail::quote_proxy - quote(const std::basic_string& s, - Char escape='\\', Char delim='\"'); - - template - detail::c_str_quote_proxy - quote(const Char* s, Char escape='\\', Char delim='\"'); - - template - detail::unquote_proxy - unquote(std::basic_string& s, - Char escape='\\', Char delim='\"'); - - // ----------- implementation details -------------------------------------------// - - namespace detail - { - // string inserter helpers - - template - struct quote_proxy - { - const std::basic_string& s; - Char escape; - Char delim; - - quote_proxy(const std::basic_string& s_, - Char escape_, Char delim_) - : s(s_), escape(escape_), delim(delim_) {} - }; - - template - std::basic_ostream& operator<<(std::basic_ostream& os, - quote_proxy& proxy) - { - os << proxy.delim; - std::basic_string::const_iterator end_it = proxy.s.end(); - for (std::basic_string::const_iterator it = proxy.s.begin(); - it != end_it; - ++it ) - { - if (*it == proxy.delim || *it == proxy.escape) - os << proxy.escape; - os << *it; - } - os << proxy.delim; - return os; - } - - // c_str inserter helpers - - template - struct c_str_quote_proxy - { - const Char* s; - Char escape; - Char delim; - - c_str_quote_proxy(const Char* s_, Char escape_, Char delim_) - : s(s_), escape(escape_), delim(delim_) {} - }; - - template - std::basic_ostream& operator<<(std::basic_ostream& os, - c_str_quote_proxy& proxy) - { - os << proxy.delim; - for (const Char* it = proxy.s; - *it; - ++it ) - { - if (*it == proxy.delim || *it == proxy.escape) - os << proxy.escape; - os << *it; - } - os << proxy.delim; - return os; - } - - // string extractor helpers - - template - struct unquote_proxy - { - std::basic_string& s; - Char escape; - Char delim; - - unquote_proxy(std::basic_string& s_, - Char escape_, Char delim_) - : s(s_), escape(escape_), delim(delim_) {} - }; - - template - std::basic_istream& operator>>(std::basic_istream& is, - unquote_proxy& proxy) - { - Char c; - is >> c; - if (c != proxy.delim) - { - proxy.s = c; - is >> proxy.s; - return is; - } - proxy.s.clear(); - { - boost::io::ios_flags_saver ifs(is); - is >> std::noskipws; - for (;;) - { - is >> c; - if (c == proxy.escape) - is >> c; - else if (c == proxy.delim) - break; - proxy.s += c; - } - } - return is; - } - - } // namespace detail - - // manipulator implementations - - template - inline detail::quote_proxy - quote(const std::basic_string& s, Char escape, Char delim) - { - return detail::quote_proxy(s, escape, delim); - } - - template - inline detail::c_str_quote_proxy - quote(const Char* s, Char escape, Char delim) - { - return detail::c_str_quote_proxy(s, escape, delim); - } - - template - inline detail::unquote_proxy - unquote(std::basic_string& s, Char escape, Char delim) - { - return detail::unquote_proxy(s, escape, delim); - } - - } // namespace io -} // namespace boost - -#endif // BOOST_QUOTE_MANIP diff --git a/include/boost/io/quoted_manip.hpp b/include/boost/io/quoted_manip.hpp new file mode 100644 index 0000000..325f14b --- /dev/null +++ b/include/boost/io/quoted_manip.hpp @@ -0,0 +1,158 @@ +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +//--------------------------------------------------------------------------------------// + +#ifndef BOOST_QUOTE_MANIP +#define BOOST_QUOTE_MANIP + +#include +#include +#include + +namespace boost +{ + namespace io + { + namespace detail { template struct quoted_proxy; } + + // ------------ public interface ------------------------------------------------// + + template + detail::quoted_proxy const &, Char> + quoted(const std::basic_string& s, + Char escape='\\', Char delim='\"'); + + template + detail::quoted_proxy + quoted(const Char* s, Char escape='\\', Char delim='\"'); + + template + detail::quoted_proxy &, Char> + quoted(std::basic_string& s, + Char escape='\\', Char delim='\"'); + + // ----------- implementation details -------------------------------------------// + + namespace detail + { + + template + struct quoted_proxy + { + String string; + Char escape; + Char delim; + + quoted_proxy(String s_, Char escape_, Char delim_) + : string(s_), escape(escape_), delim(delim_) {} + }; + + template + std::basic_ostream& operator<<(std::basic_ostream& os, + const quoted_proxy const &, Char>& proxy) + { + os << proxy.delim; + std::basic_string::const_iterator end_it = proxy.string.end(); + for (std::basic_string::const_iterator it = proxy.string.begin(); + it != end_it; + ++it ) + { + if (*it == proxy.delim || *it == proxy.escape) + os << proxy.escape; + os << *it; + } + os << proxy.delim; + return os; + } + + template + inline + std::basic_ostream& operator<<(std::basic_ostream& os, + const quoted_proxy&, Char>& proxy) + { + return os << + *reinterpret_cast const &, Char>*>(&proxy); + } + + template + std::basic_ostream& operator<<(std::basic_ostream& os, + const quoted_proxy& proxy) + { + os << proxy.delim; + for (const Char* it = proxy.string; + *it; + ++it ) + { + if (*it == proxy.delim || *it == proxy.escape) + os << proxy.escape; + os << *it; + } + os << proxy.delim; + return os; + } + + template + std::basic_istream& operator>>(std::basic_istream& is, + const quoted_proxy&, Char>& proxy) + { + Char c; + is >> c; + if (c != proxy.delim) + { + proxy.string = c; + is >> proxy.string; + return is; + } + proxy.string.clear(); + { + boost::io::ios_flags_saver ifs(is); + is >> std::noskipws; + for (;;) + { + is >> c; + if (c == proxy.escape) + is >> c; + else if (c == proxy.delim) + break; + proxy.string += c; + } + } + return is; + } + + } // namespace detail + + // manipulator implementations + + template + inline detail::quoted_proxy const &, Char> + quoted(const std::basic_string& s, Char escape, Char delim) + { + return detail::quoted_proxy const &, Char> + (s, escape, delim); + } + + template + inline detail::quoted_proxy + quoted(const Char* s, Char escape, Char delim) + { + return detail::quoted_proxy (s, escape, delim); + } + + + template + inline detail::quoted_proxy &, Char> + quoted(std::basic_string& s, Char escape, Char delim) + { + return detail::quoted_proxy&, Char> + (s, escape, delim); + } + + } // namespace io +} // namespace boost + +#endif // BOOST_QUOTE_MANIP From cab10052da2e9447542eab097fab4dd6b768894d Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 18 Jun 2010 16:37:34 +0000 Subject: [PATCH 4/6] Clean up code, add initial documentation draft [SVN r63082] --- doc/quoted_manip.html | 145 ++++++++++++++++++++++++++++++ include/boost/io/quoted_manip.hpp | 79 +++++++++------- 2 files changed, 194 insertions(+), 30 deletions(-) create mode 100644 doc/quoted_manip.html diff --git a/doc/quoted_manip.html b/doc/quoted_manip.html new file mode 100644 index 0000000..4391941 --- /dev/null +++ b/doc/quoted_manip.html @@ -0,0 +1,145 @@ + + + + + + Boost quoted string manipulator + + + + + + + + + + + + + +
boost.png (6897 bytes) +

Quoted String
+ Stream + I/O Manipulator

+
+ +

Introduction

+

C++ Standard library stream I/O for strings that contain embedded spaces +can produce unexpected results. For example,

+
+
std::stringstream ss;
+std::string original = "fooled you";
+std::string round_trip;
+
+ss << original;
+ss >> round_trip;
+
+std::cout << original;   // outputs: fooled you
+std::cout << round_trip; // outputs: fooled
+
+assert(original == round_trip); // assert will fire
+
+

The Boost quoted string stream I/O manipulator places delimiters, defaulted +to the double-quote ("), around strings on output, and strips off +the delimiters on input. This ensures strings with embedded spaces round-trip as +desired. For example,

+
+
std::stringstream ss;
+std::string original = "fooled you";
+std::string round_trip;
+
+ss << quoted(original);
+ss >> quoted(round_trip);
+
+std::cout << quoted(original); // outputs: "fooled you"
+std::cout << round_trip;       // outputs: fooled you
+
+assert(original == round_trip); // assert will not fire
+
+

Header <boost/io/quoted_manip.hpp> synopsis

+
namespace boost
+{
+  namespace io
+  {
+    // manipulator for const std::basic_string&
+
+    template <class Char, class Traits, class Alloc>
+    unspecified-type1 quoted(const std::basic_string<Char, Traits, Alloc>& string, Char escape='\\', Char delim='\"');
+
+    // manipulator for const C-string*
+
+    template <class Char>
+    unspecified-type2 quoted(const Char* string, Char escape='\\', Char delim='\"');
+
+    // manipulator for non-const std::basic_string&
+
+    template <class Char, class Traits, class Alloc>
+    unspecified-type3 quoted(std::basic_string<Char, Traits, Alloc>& string, Char escape='\\', Char delim='\"');
+  }
+}
+

unspecified_type1, unspecified_type2, +and unspecified_type3 are implementation supplied +types with implementation supplied operator<<:

+
+
template <class Char, class Traits>
+  std::basic_ostream<Char, Traits>&
+    operator<<(std::basic_ostream<Char, Traits>& os, const unspecified_typeN& proxy);
+

Effects: Inserts characters into os:

+
    +
  • delim.
  • +
  • Each character in string. If the character to be output is + equal to escape or delim, as determined by + operator==, first output escape.
  • +
  • delim.
  • +
+

Remarks: string, escape, and delim +have the type and value of the corresponding arguments of the call to the +quoted function that constructed proxy.

+

Returns: os.

+
+

unspecified_type3 is an implementation supplied +type with an implementation supplied operator>>:

+
+
template <class Char, class Traits>
+  std::basic_istream<Char, Traits>&
+    operator>>(std::basic_istream<Char, Traits>& is, const unspecified_type3& proxy);
+

Effects: Extracts characters from os:

+
    +
  • If the first character extracted is equal to delim, as determined by + operator==, then:
      +
    • Turn off the skipws flag.
    • +
    • string.clear()
    • +
    • Until an unescaped delim character is reached, extract + characters from os and append them to string, + except that if an escape is reached, ignore it and append the + next character to string.
    • +
    • Discard the final delim character.
    • +
    • Restore the skipws flag to its original value.
    • +
    +
  • +
  • Otherwise, os >> string.
  • +
+

Remarks: string, escape, and delim +have the type and value of the corresponding arguments of the call to the +quoted function that constructed proxy.

+

Returns: is.

+
+

Acknowledgements

+

The quoted() stream manipulator emerged from discussions on the +Boost developers mailing list. Participants included Beman Dawes, Rob Stewart, +Alexander Lamaison, Eric Niebler, Vicente Botet, Andrey Semashev, Phil Richards, +and Rob Murray. Eric Niebler's suggestions provided the basis for the name and +form of the templates.

+
+

© Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010

+

Distributed under the Boost Software License, Version 1.0. See +www.boost.org/LICENSE_1_0.txt

+

Revised +18 June 2010

+ + + \ No newline at end of file diff --git a/include/boost/io/quoted_manip.hpp b/include/boost/io/quoted_manip.hpp index 325f14b..48253d3 100644 --- a/include/boost/io/quoted_manip.hpp +++ b/include/boost/io/quoted_manip.hpp @@ -1,12 +1,16 @@ +// boost/io/quoted_manip.hpp ---------------------------------------------------------// + // Copyright Beman Dawes 2010 // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt +// Library home page http://www.boost.org/libs/io + //--------------------------------------------------------------------------------------// -#ifndef BOOST_QUOTE_MANIP -#define BOOST_QUOTE_MANIP +#ifndef BOOST_IO_QUOTED_MANIP +#define BOOST_IO_QUOTED_MANIP #include #include @@ -20,25 +24,28 @@ namespace boost // ------------ public interface ------------------------------------------------// + // manipulator for const std::basic_string& template detail::quoted_proxy const &, Char> quoted(const std::basic_string& s, Char escape='\\', Char delim='\"'); - template - detail::quoted_proxy - quoted(const Char* s, Char escape='\\', Char delim='\"'); - + // manipulator for non-const std::basic_string& template detail::quoted_proxy &, Char> quoted(std::basic_string& s, Char escape='\\', Char delim='\"'); + // manipulator for const C-string* + template + detail::quoted_proxy + quoted(const Char* s, Char escape='\\', Char delim='\"'); + // ----------- implementation details -------------------------------------------// namespace detail { - + // proxy used as an argument pack template struct quoted_proxy { @@ -50,34 +57,45 @@ namespace boost : string(s_), escape(escape_), delim(delim_) {} }; + // abstract away difference between proxies with const or non-const basic_strings template - std::basic_ostream& operator<<(std::basic_ostream& os, - const quoted_proxy const &, Char>& proxy) + std::basic_ostream& + basic_string_inserter_imp(std::basic_ostream& os, + std::basic_string const & string, Char escape, Char delim) { - os << proxy.delim; - std::basic_string::const_iterator end_it = proxy.string.end(); - for (std::basic_string::const_iterator it = proxy.string.begin(); + os << delim; + std::basic_string::const_iterator end_it = string.end(); + for (std::basic_string::const_iterator it = string.begin(); it != end_it; ++it ) { - if (*it == proxy.delim || *it == proxy.escape) - os << proxy.escape; + if (*it == delim || *it == escape) + os << escape; os << *it; } - os << proxy.delim; + os << delim; return os; } + // inserter for const std::basic_string& proxies + template + inline + std::basic_ostream& operator<<(std::basic_ostream& os, + const quoted_proxy const &, Char>& proxy) + { + return basic_string_inserter_imp(os, proxy.string, proxy.escape, proxy.delim); + } + + // inserter for non-const std::basic_string& proxies template inline std::basic_ostream& operator<<(std::basic_ostream& os, const quoted_proxy&, Char>& proxy) { - return os << - *reinterpret_cast const &, Char>*>(&proxy); + return basic_string_inserter_imp(os, proxy.string, proxy.escape, proxy.delim); } - + + // inserter for const C-string* proxies template std::basic_ostream& operator<<(std::basic_ostream& os, const quoted_proxy& proxy) @@ -95,6 +113,7 @@ namespace boost return os; } + // extractor for non-const std::basic_string& proxies template std::basic_istream& operator>>(std::basic_istream& is, const quoted_proxy&, Char>& proxy) @@ -126,8 +145,7 @@ namespace boost } // namespace detail - // manipulator implementations - + // manipulator implementation for const std::basic_string& template inline detail::quoted_proxy const &, Char> quoted(const std::basic_string& s, Char escape, Char delim) @@ -136,14 +154,7 @@ namespace boost (s, escape, delim); } - template - inline detail::quoted_proxy - quoted(const Char* s, Char escape, Char delim) - { - return detail::quoted_proxy (s, escape, delim); - } - - + // manipulator implementation for non-const std::basic_string& template inline detail::quoted_proxy &, Char> quoted(std::basic_string& s, Char escape, Char delim) @@ -152,7 +163,15 @@ namespace boost (s, escape, delim); } + // manipulator implementation for const C-string* + template + inline detail::quoted_proxy + quoted(const Char* s, Char escape, Char delim) + { + return detail::quoted_proxy (s, escape, delim); + } + } // namespace io } // namespace boost -#endif // BOOST_QUOTE_MANIP +#endif // BOOST_IO_QUOTED_MANIP From a6f0ee9b1988e3be41805b4915b980ffdfb8b3a6 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 19 Jun 2010 13:25:55 +0000 Subject: [PATCH 5/6] Cope with I/O errors or premature eof [SVN r63099] --- doc/quoted_manip.html | 20 +++++++++++++------- include/boost/io/quoted_manip.hpp | 10 +++++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/doc/quoted_manip.html b/doc/quoted_manip.html index 4391941..9cd0b37 100644 --- a/doc/quoted_manip.html +++ b/doc/quoted_manip.html @@ -4,7 +4,7 @@ - Boost quoted string manipulator + Boost "quoted" I/O manipulator @@ -19,9 +19,9 @@ style="border-collapse: collapse"> src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="300" height="86" border="0" /> -

Quoted String
- Stream - I/O Manipulator

+

"Quoted" + I/O Manipulator
+ for Strings

@@ -43,7 +43,7 @@ std::cout << round_trip; // outputs: fooled assert(original == round_trip); // assert will fire -

The Boost quoted string stream I/O manipulator places delimiters, defaulted +

The Boost quoted stream I/O manipulator places delimiters, defaulted to the double-quote ("), around strings on output, and strips off the delimiters on input. This ensures strings with embedded spaces round-trip as desired. For example,

@@ -60,6 +60,11 @@ std::cout << round_trip; // outputs: fooled you assert(original == round_trip); // assert will not fire +

If the string contains the delimiter character, on output that character will +be preceded by an escape character, as will the escape character itself:

+
+
std::cout << quoted("'Jack & Jill'", '&', '\'');  // outputs: '&'Jack && Jill&''
+

Header <boost/io/quoted_manip.hpp> synopsis

namespace boost
 {
@@ -113,7 +118,8 @@ type with an implementation supplied operator>>:

operator==, then:
  • Turn off the skipws flag.
  • string.clear()
  • -
  • Until an unescaped delim character is reached, extract +
  • Until an unescaped delim character is reached or + is.not_good(), extract characters from os and append them to string, except that if an escape is reached, ignore it and append the next character to string.
  • @@ -139,7 +145,7 @@ form of the templates.

    Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

    Revised -18 June 2010

    +19 June 2010

    \ No newline at end of file diff --git a/include/boost/io/quoted_manip.hpp b/include/boost/io/quoted_manip.hpp index 48253d3..6b21daa 100644 --- a/include/boost/io/quoted_manip.hpp +++ b/include/boost/io/quoted_manip.hpp @@ -13,7 +13,9 @@ #define BOOST_IO_QUOTED_MANIP #include +#include #include +#include #include namespace boost @@ -130,11 +132,17 @@ namespace boost { boost::io::ios_flags_saver ifs(is); is >> std::noskipws; - for (;;) + for (;;) { is >> c; + if (!is.good()) // cope with I/O errors or end-of-file + break; if (c == proxy.escape) + { is >> c; + if (!is.good()) // cope with I/O errors or end-of-file + break; + } else if (c == proxy.delim) break; proxy.string += c; From b925279bc93013e85f31bf3d1f1abd0258d07c3c Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 19 Jun 2010 14:55:01 +0000 Subject: [PATCH 6/6] Move header to detail in preparation for merge to trunk [SVN r63100] --- doc/quoted_manip.html | 15 +++++++++++++-- include/boost/io/{ => detail}/quoted_manip.hpp | 0 2 files changed, 13 insertions(+), 2 deletions(-) rename include/boost/io/{ => detail}/quoted_manip.hpp (100%) diff --git a/doc/quoted_manip.html b/doc/quoted_manip.html index 9cd0b37..220c445 100644 --- a/doc/quoted_manip.html +++ b/doc/quoted_manip.html @@ -20,13 +20,24 @@ style="border-collapse: collapse"> width="300" height="86" border="0" />

    "Quoted" - I/O Manipulator
    + I/O Manipulators
    for Strings

    + + + + +
    +

    "Quoted" + I/O Manipulators + for Strings are not yet accepted into Boost as public components. Thus the + header file is currently located in <boost/io/detail/quoted_manip.hpp>, and + this documentation page is not linked to from official documentation.

    +

    Introduction

    C++ Standard library stream I/O for strings that contain embedded spaces can produce unexpected results. For example,

    @@ -65,7 +76,7 @@ be preceded by an escape character, as will the escape character itself:

    std::cout << quoted("'Jack & Jill'", '&', '\'');  // outputs: '&'Jack && Jill&''
    -

    Header <boost/io/quoted_manip.hpp> synopsis

    +

    Header <boost/io/quoted_manip.hpp> synopsis

    namespace boost
     {
       namespace io
    diff --git a/include/boost/io/quoted_manip.hpp b/include/boost/io/detail/quoted_manip.hpp
    similarity index 100%
    rename from include/boost/io/quoted_manip.hpp
    rename to include/boost/io/detail/quoted_manip.hpp