From bd1c6992207688b116f68410f9ee63250c41faed Mon Sep 17 00:00:00 2001 From: Nicola Musatti Date: Thu, 27 Apr 2006 06:50:17 +0000 Subject: [PATCH 01/24] Fixed for BCB2006 [SVN r33835] --- include/boost/io/ios_state.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/io/ios_state.hpp b/include/boost/io/ios_state.hpp index 68a5a69..2d1625b 100644 --- a/include/boost/io/ios_state.hpp +++ b/include/boost/io/ios_state.hpp @@ -134,7 +134,11 @@ public: explicit basic_ios_exception_saver( state_type &s ) : s_save_( s ), a_save_( s.exceptions() ) {} +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + basic_ios_exception_saver( state_type &s, aspect_type a ) +#else basic_ios_exception_saver( state_type &s, aspect_type const &a ) +#endif : s_save_( s ), a_save_( s.exceptions() ) { s.exceptions(a); } ~basic_ios_exception_saver() From 7aa98502d3154d69388849b07aa72431fa2be8af Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 31 May 2006 12:35:53 +0000 Subject: [PATCH 02/24] Include workaround header [SVN r34127] --- include/boost/io/ios_state.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/io/ios_state.hpp b/include/boost/io/ios_state.hpp index 2d1625b..c9b4576 100644 --- a/include/boost/io/ios_state.hpp +++ b/include/boost/io/ios_state.hpp @@ -10,6 +10,7 @@ #define BOOST_IO_IOS_STATE_HPP #include // self include +#include #include // for std::ios_base, std::basic_ios, etc. #ifndef BOOST_NO_STD_LOCALE From 8dfc0e65d1c80a46d0ca27ebc383643884d240de Mon Sep 17 00:00:00 2001 From: Daryle Walker Date: Sat, 4 Nov 2006 22:58:43 +0000 Subject: [PATCH 03/24] Added license to a person profile; updated license on Boost.Integer and Boost.IO doc files; changed 'BOOST_TEST' to 'BOOST_CHECK' on Boost.Integer testing *.cpp files [SVN r35844] --- doc/index.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/index.html b/doc/index.html index e2b8ea5..966c37b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -59,9 +59,8 @@ with/for the standard I/O library.

Revised: 26 Feb 2002

-

Copyright 2002 Boost.org. Use, -modification, and distribution are subject to the Boost Software -License, Version 1.0. (See accompanying file Copyright 2002 Daryle Walker. Use, modification, and distribution are +subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)

From 4722f5ebcff000fdd0bef54f1ac00ef14db4e64e Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:11:57 +0000 Subject: [PATCH 04/24] Add copyright, license [SVN r35905] --- index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index dff3b20..debe825 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,11 @@ Automatic redirection failed, please go to -doc/index.html. +doc/index.html
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt) +

\ No newline at end of file From 03d391862722aafbb93ae4006e427df579a29688 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 10 Nov 2006 19:09:56 +0000 Subject: [PATCH 05/24] Allow building of shared versions of some Boost.Test libraries. Adjust tests to use always use static linking to Boost.Test, since linking to the shared version requires test changes. Patch from Juergen Hunold. [SVN r35989] --- test/Jamfile.v2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 30de868..14b3e5b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -9,14 +9,14 @@ test-suite "io" : [ run ios_state_unit_test.cpp - ../../../libs/test/build//boost_unit_test_framework + ../../../libs/test/build//boost_unit_test_framework/static : # args : # input files # : std::locale-support ] [ run ios_state_test.cpp - ../../../libs/test/build//boost_test_exec_monitor + ../../../libs/test/build//boost_test_exec_monitor/static : # args : # input files # : std::locale-support From e0ba7aaea67605c44869f3e3d7fc47fd502ae88e Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 8 Aug 2007 19:02:26 +0000 Subject: [PATCH 06/24] Remove V1 Jamfiles [SVN r38516] --- test/Jamfile | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 test/Jamfile diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 8dab248..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,33 +0,0 @@ -# Boost.IO Library test Jamfile -# -# Copyright 2003 Daryle Walker. Use, modification, and distribution -# are subject to the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or a copy at -# .) -# -# See for the library's home page. -subproject libs/io/test ; - -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - -test-suite "io" - : [ run ios_state_unit_test.cpp - @boost/libs/test/build/boost_unit_test_framework - : # args - : # input files - : std::locale-support - ] - - [ run ios_state_test.cpp - @boost/libs/test/build/boost_test_exec_monitor - : # args - : # input files - : std::locale-support - ] - ; -} From a4085a5269ed0f0f5e562812594a30b43bdf1100 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 15 Dec 2007 17:36:31 +0000 Subject: [PATCH 07/24] Trivial patches to silence MSVC warnings. [SVN r42076] --- include/boost/io/ios_state.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/boost/io/ios_state.hpp b/include/boost/io/ios_state.hpp index c9b4576..9c45c0b 100644 --- a/include/boost/io/ios_state.hpp +++ b/include/boost/io/ios_state.hpp @@ -50,6 +50,8 @@ public: private: state_type & s_save_; aspect_type const a_save_; + + ios_flags_saver& operator=(const ios_flags_saver&); }; class ios_precision_saver @@ -73,6 +75,8 @@ public: private: state_type & s_save_; aspect_type const a_save_; + + ios_precision_saver& operator=(const ios_precision_saver&); }; class ios_width_saver @@ -96,6 +100,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + ios_width_saver& operator=(const ios_width_saver&); }; @@ -277,6 +282,8 @@ private: state_type & s_save_; aspect_type const a_save_; index_type const i_save_; + + ios_iword_saver& operator=(const ios_iword_saver&); }; class ios_pword_saver @@ -302,6 +309,8 @@ private: state_type & s_save_; aspect_type const a_save_; index_type const i_save_; + + ios_pword_saver operator=(const ios_pword_saver&); }; @@ -332,6 +341,8 @@ private: state_type::fmtflags const a1_save_; ::std::streamsize const a2_save_; ::std::streamsize const a3_save_; + + ios_base_all_saver& operator=(const ios_base_all_saver&); }; template < typename Ch, class Tr > @@ -408,6 +419,8 @@ private: index_type const i_save_; long const a1_save_; void * const a2_save_; + + ios_all_word_saver& operator=(const ios_all_word_saver&); }; From 1c7374e831398f61b36efc820513c1639e5fd576 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 10 Feb 2008 14:56:22 +0000 Subject: [PATCH 08/24] Link to people pages on the website, as they've been removed from the download. [SVN r43209] --- doc/index.html | 2 +- doc/ios_state.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index.html b/doc/index.html index 966c37b..531dfc1 100644 --- a/doc/index.html +++ b/doc/index.html @@ -14,7 +14,7 @@ color="white">Home Libraries - People FAQ diff --git a/doc/ios_state.html b/doc/ios_state.html index 101524d..9be4fa2 100644 --- a/doc/ios_state.html +++ b/doc/ios_state.html @@ -434,7 +434,7 @@ int main()

Contributors

-
Daryle Walker +
Daryle Walker
Started the library. Contributed the initial versions of the format flags, precision, width, and user-defined format flags saver classes. Contributed the initial versions of the success From a720ac89c18b1e2838fbeb45e00ff3faba4bf3e1 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 10 Feb 2008 15:02:17 +0000 Subject: [PATCH 09/24] Point links to the pages that used to be in 'more' to the site. [SVN r43210] --- doc/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.html b/doc/index.html index 531dfc1..4885739 100644 --- a/doc/index.html +++ b/doc/index.html @@ -16,7 +16,7 @@ color="white">Libraries People - FAQ More From 3b31c330d5a1daaf187136306e67350ad28147fc Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Sat, 1 Nov 2008 13:15:41 +0000 Subject: [PATCH 10/24] Continuing merge of CMake build system files into trunk with the encouragement of Doug Gregor [SVN r49510] --- CMakeLists.txt | 22 ++++++++++++++++++++++ test/CMakeLists.txt | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c402de4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + io_fwd.hpp + io +) + +# Add a library target to the build system +boost_library_project( + io + # SRCDIRS + TESTDIRS test + HEADERS ${lib_headers} + # DOCDIRS + # DESCRIPTION + MODULARIZED + # AUTHORS + # MAINTAINERS +) + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..7858642 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,3 @@ +boost_test_run(ios_state_unit_test DEPENDS boost_unit_test_framework) +boost_test_run(ios_state_test DEPENDS boost_test_exec_monitor) + From 25d1746f8aefc91fd63fe7881f761a5be48e8b50 Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:02:56 +0000 Subject: [PATCH 11/24] Updating CMake files to latest trunk. Added dependency information for regression tests and a few new macros for internal use. [SVN r49627] --- test/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7858642..e3484d3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,6 @@ +boost_additional_test_dependencies(io BOOST_DEPENDS test) + + boost_test_run(ios_state_unit_test DEPENDS boost_unit_test_framework) boost_test_run(ios_state_test DEPENDS boost_test_exec_monitor) From 1865f2b8f9bbb514aaa1b0c91a8143f8980c297f Mon Sep 17 00:00:00 2001 From: "Michael A. Jackson" Date: Fri, 7 Nov 2008 17:05:27 +0000 Subject: [PATCH 12/24] Updating dependency information for modularized libraries. [SVN r49628] --- module.cmake | 1 + 1 file changed, 1 insertion(+) create mode 100644 module.cmake diff --git a/module.cmake b/module.cmake new file mode 100644 index 0000000..fd1d4d9 --- /dev/null +++ b/module.cmake @@ -0,0 +1 @@ +boost_module(io DEPENDS detail) \ No newline at end of file From bb80cdd26c1364ac2ea6e8ceb4bc49643367be13 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 30 May 2009 05:59:08 +0000 Subject: [PATCH 13/24] Add private assignment operators. Patch from Richard Webb. This fixes #1414, where msvc complained that default assignment operator could not be generated. This can be fixed either by pragmas, or by declaring (but not defining), private assignment operator. The latter approach seems better, since it's likely to help on other compilers. [SVN r53425] --- include/boost/io/ios_state.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/io/ios_state.hpp b/include/boost/io/ios_state.hpp index 9c45c0b..07cfb34 100644 --- a/include/boost/io/ios_state.hpp +++ b/include/boost/io/ios_state.hpp @@ -128,6 +128,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_iostate_saver& operator=(const basic_ios_iostate_saver&); }; template < typename Ch, class Tr > @@ -156,6 +157,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_exception_saver& operator=(const basic_ios_exception_saver&); }; template < typename Ch, class Tr > @@ -180,6 +182,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_tie_saver& operator=(const basic_ios_tie_saver&); }; template < typename Ch, class Tr > @@ -204,6 +207,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_rdbuf_saver& operator=(const basic_ios_rdbuf_saver&); }; template < typename Ch, class Tr > @@ -228,6 +232,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_fill_saver& operator=(const basic_ios_fill_saver&); }; #ifndef BOOST_NO_STD_LOCALE @@ -253,6 +258,7 @@ public: private: state_type & s_save_; aspect_type const a_save_; + basic_ios_locale_saver& operator=(const basic_ios_locale_saver&); }; #endif @@ -392,6 +398,8 @@ private: #ifndef BOOST_NO_STD_LOCALE ::std::locale const a9_save_; #endif + + basic_ios_all_saver& operator=(const basic_ios_all_saver&); }; class ios_all_word_saver From 3bf1eee7e423c10e7d278c43e208987e6ce6e3f9 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sun, 26 Jul 2009 00:49:56 +0000 Subject: [PATCH 14/24] Copyrights on CMakeLists.txt to keep them from clogging up the inspect reports. This is essentially the same commit as r55095 on the release branch. [SVN r55159] --- CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c402de4..a2d73a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e3484d3..2f1cf09 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(io BOOST_DEPENDS test) From 81458c44a61745dc6c97b93a3df71dd5ae38ccdd Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 02:07:38 +0000 Subject: [PATCH 15/24] rm cmake from trunk. I'm not entirely sure this is necessary to satisfy the inspect script, but I'm not taking any chances, and it is easy to put back [SVN r56942] --- CMakeLists.txt | 28 ---------------------------- module.cmake | 1 - test/CMakeLists.txt | 12 ------------ 3 files changed, 41 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index a2d73a2..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - io_fwd.hpp - io -) - -# Add a library target to the build system -boost_library_project( - io - # SRCDIRS - TESTDIRS test - HEADERS ${lib_headers} - # DOCDIRS - # DESCRIPTION - MODULARIZED - # AUTHORS - # MAINTAINERS -) - - diff --git a/module.cmake b/module.cmake deleted file mode 100644 index fd1d4d9..0000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(io DEPENDS detail) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 2f1cf09..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(io BOOST_DEPENDS test) - - -boost_test_run(ios_state_unit_test DEPENDS boost_unit_test_framework) -boost_test_run(ios_state_test DEPENDS boost_test_exec_monitor) - From df0f93e3b5836d6bf941756a57d4689559024383 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 9 Jun 2010 11:34:33 +0000 Subject: [PATCH 16/24] 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 17/24] 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 18/24] 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 19/24] 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 20/24] 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 21/24] 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
    
    From f1cb359a307700d0d74fb8e7a2b5227932dd8664 Mon Sep 17 00:00:00 2001
    From: Beman Dawes 
    Date: Sun, 20 Jun 2010 12:56:34 +0000
    Subject: [PATCH 22/24] String may be const type so disable assignment
    
    [SVN r63135]
    ---
     include/boost/io/detail/quoted_manip.hpp | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/include/boost/io/detail/quoted_manip.hpp b/include/boost/io/detail/quoted_manip.hpp
    index d915521..13cfc35 100644
    --- a/include/boost/io/detail/quoted_manip.hpp
    +++ b/include/boost/io/detail/quoted_manip.hpp
    @@ -57,6 +57,9 @@ namespace boost
     
             quoted_proxy(String s_, Char escape_, Char delim_)
               : string(s_), escape(escape_), delim(delim_) {}
    +      private:
    +        // String may be a const type, so disable the assignment operator
    +        quoted_proxy& operator=(const quoted_proxy&);  // = deleted
           };
     
           //  abstract away difference between proxies with const or non-const basic_strings
    
    From 14827ce116e19e3e2cd6820830816ee3356c91fd Mon Sep 17 00:00:00 2001
    From: Beman Dawes 
    Date: Sun, 20 Jun 2010 13:41:26 +0000
    Subject: [PATCH 23/24] Use boost::io::quoted I/O manipulator as a better
     solution to embedded spaces. See #3863
    
    [SVN r63136]
    ---
     doc/quoted_manip.html | 5 ++---
     1 file changed, 2 insertions(+), 3 deletions(-)
    
    diff --git a/doc/quoted_manip.html b/doc/quoted_manip.html
    index 220c445..0ccb725 100644
    --- a/doc/quoted_manip.html
    +++ b/doc/quoted_manip.html
    @@ -33,8 +33,7 @@ style="border-collapse: collapse">
         

    "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. + header file is currently located in <boost/io/detail/quoted_manip.hpp> @@ -156,7 +155,7 @@ form of the templates.

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

    Revised -19 June 2010

    +20 June 2010

    \ No newline at end of file From 1962b0b090908d798b81d43781354a6b97e69945 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 20 Jun 2010 18:02:14 +0000 Subject: [PATCH 24/24] Move minimal.css to doc/src. [SVN r63148] --- doc/quoted_manip.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/quoted_manip.html b/doc/quoted_manip.html index 0ccb725..c3e7362 100644 --- a/doc/quoted_manip.html +++ b/doc/quoted_manip.html @@ -6,7 +6,7 @@ Boost "quoted" I/O manipulator - +