Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55948 - in sandbox/explore: boost/explore libs/explore/doc libs/explore/doc/html libs/explore/test
From: jmcintyre_at_[hidden]
Date: 2009-08-31 23:17:42


Author: jared
Date: 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
New Revision: 55948
URL: http://svn.boost.org/trac/boost/changeset/55948

Log:
Explore - change assoc manipulators to assoc_item and add assoc_item_begin_end and assoc_item_delimeters.

Text files modified:
   sandbox/explore/boost/explore/container_stream_state.hpp | 30 ++++++++--------
   sandbox/explore/boost/explore/manipulators.hpp | 72 +++++++++++++++++++++++++++++++++------
   sandbox/explore/boost/explore/stream_value.hpp | 2
   sandbox/explore/libs/explore/doc/custom_delimeters.qbk | 14 +++---
   sandbox/explore/libs/explore/doc/html/boostbook.css | 6 +++
   sandbox/explore/libs/explore/test/custom_format_simple.cpp | 35 ++++++++++++++++--
   6 files changed, 119 insertions(+), 40 deletions(-)

Modified: sandbox/explore/boost/explore/container_stream_state.hpp
==============================================================================
--- sandbox/explore/boost/explore/container_stream_state.hpp (original)
+++ sandbox/explore/boost/explore/container_stream_state.hpp 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -28,9 +28,9 @@
         BOOST_EXPLORE_INIT_STRING(separator, ", ")
         BOOST_EXPLORE_INIT_STRING(start, "[")
         BOOST_EXPLORE_INIT_STRING(end, "]")
- BOOST_EXPLORE_INIT_STRING(assoc_separator, ":")
- BOOST_EXPLORE_INIT_STRING(assoc_start, "")
- BOOST_EXPLORE_INIT_STRING(assoc_end, "")
+ BOOST_EXPLORE_INIT_STRING(assoc_item_separator, ":")
+ BOOST_EXPLORE_INIT_STRING(assoc_item_start, "")
+ BOOST_EXPLORE_INIT_STRING(assoc_item_end, "")
 
         struct depth_guard;
 
@@ -127,26 +127,26 @@
             init(m_separator, detail::init_separator<El>());
             init(m_start, detail::init_start<El>());
             init(m_end, detail::init_end<El>());
- init(m_assoc_separator, detail::init_assoc_separator<El>());
- init(m_assoc_start, detail::init_assoc_start<El>());
- init(m_assoc_end, detail::init_assoc_end<El>());
+ init(m_assoc_item_separator, detail::init_assoc_item_separator<El>());
+ init(m_assoc_item_start, detail::init_assoc_item_start<El>());
+ init(m_assoc_item_end, detail::init_assoc_item_end<El>());
         }
 
         // read
         const str_typ& separator() const { return at(m_separator); }
         const str_typ& start(std::size_t index = 0) const { return at(m_start); }
         const str_typ& end() const { return at(m_end); }
- const str_typ& assoc_separator() const { return at(m_assoc_separator); }
- const str_typ& assoc_start() const { return at(m_assoc_start); }
- const str_typ& assoc_end() const { return at(m_assoc_end); }
+ const str_typ& assoc_item_separator() const { return at(m_assoc_item_separator); }
+ const str_typ& assoc_item_start() const { return at(m_assoc_item_start); }
+ const str_typ& assoc_item_end() const { return at(m_assoc_item_end); }
 
         // write
         void set_separator(const str_typ& str) { at(m_separator) = str; }
         void set_start(const str_typ& str) { at(m_start) = str; }
         void set_end(const str_typ& str) { at(m_end) = str; }
- void set_assoc_separator(const str_typ& str) { at(m_assoc_separator) = str; }
- void set_assoc_start(const str_typ& str) { at(m_assoc_start) = str; }
- void set_assoc_end(const str_typ& str) { at(m_assoc_end) = str; }
+ void set_assoc_item_separator(const str_typ& str) { at(m_assoc_item_separator) = str; }
+ void set_assoc_item_start(const str_typ& str) { at(m_assoc_item_start) = str; }
+ void set_assoc_item_end(const str_typ& str) { at(m_assoc_item_end) = str; }
 
     private:
         container_common_stream_state* common()
@@ -167,9 +167,9 @@
         str_cont_typ m_separator;
         str_cont_typ m_start;
         str_cont_typ m_end;
- str_cont_typ m_assoc_separator;
- str_cont_typ m_assoc_start;
- str_cont_typ m_assoc_end;
+ str_cont_typ m_assoc_item_separator;
+ str_cont_typ m_assoc_item_start;
+ str_cont_typ m_assoc_item_end;
 
         std::ios_base* m_stream;
 

Modified: sandbox/explore/boost/explore/manipulators.hpp
==============================================================================
--- sandbox/explore/boost/explore/manipulators.hpp (original)
+++ sandbox/explore/boost/explore/manipulators.hpp 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -114,23 +114,23 @@
         
         // function ptr for associative separator manipulator
         template<typename Elem>
- void assoc_separatorFn(std::ios_base& ostr, const Elem* sep)
+ void assoc_item_separatorFn(std::ios_base& ostr, const Elem* sep)
         {
- explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_separator(sep);
+ explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_item_separator(sep);
         }
         
         // function ptr for associative start manipulator
         template<typename Elem>
- void assoc_startFn(std::ios_base& ostr, const Elem* start)
+ void assoc_item_startFn(std::ios_base& ostr, const Elem* start)
         {
- explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_start(start);
+ explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_item_start(start);
         }
         
         // function ptr for associative end manipulator
         template<typename Elem>
- void assoc_endFn(std::ios_base& ostr, const Elem* end)
+ void assoc_item_endFn(std::ios_base& ostr, const Elem* end)
         {
- explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_end(end);
+ explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_item_end(end);
         }
 
         void levelFn(std::ios_base& ostr, std::size_t l)
@@ -174,23 +174,23 @@
     
     // manipulator
     template<typename Elem>
- detail::manipfunc<const Elem*> assoc_separator(const Elem* sep)
+ detail::manipfunc<const Elem*> assoc_item_separator(const Elem* sep)
     {
- return detail::manipfunc<const Elem*>(&detail::assoc_separatorFn, sep);
+ return detail::manipfunc<const Elem*>(&detail::assoc_item_separatorFn, sep);
     }
     
     // manipulator
     template<typename Elem>
- detail::manipfunc<const Elem*> assoc_start(const Elem* start)
+ detail::manipfunc<const Elem*> assoc_item_start(const Elem* start)
     {
- return detail::manipfunc<const Elem*>(&detail::assoc_startFn, start);
+ return detail::manipfunc<const Elem*>(&detail::assoc_item_startFn, start);
     }
     
     // manipulator
     template<typename Elem>
- detail::manipfunc<const Elem*> assoc_end(const Elem* end)
+ detail::manipfunc<const Elem*> assoc_item_end(const Elem* end)
     {
- return detail::manipfunc<const Elem*>(&detail::assoc_endFn, end);
+ return detail::manipfunc<const Elem*>(&detail::assoc_item_endFn, end);
     }
 
     detail::manipfunc<std::size_t> level(std::size_t l)
@@ -246,6 +246,15 @@
             T endVal_;
         };
         
+ template<typename T>
+ struct assoc_item_begin_end_manipulator : public detail::begin_end_manipulator<T>
+ {
+ assoc_item_begin_end_manipulator(T& startVal, T& endVal)
+ :begin_end_manipulator<T>(startVal, endVal)
+ {
+ }
+ };
+
         template<typename Elem, typename Tr, typename T>
         std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, const begin_end_manipulator<T>& manip)
         {
@@ -253,6 +262,14 @@
             endFn(ostr, manip.endVal_);
             return ostr;
         }
+
+ template<typename Elem, typename Tr, typename T>
+ std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, const assoc_item_begin_end_manipulator<T>& manip)
+ {
+ assoc_item_startFn(ostr, manip.startVal_);
+ assoc_item_endFn(ostr, manip.endVal_);
+ return ostr;
+ }
     }
     
     template<typename Elem>
@@ -262,6 +279,13 @@
         return detail::begin_end_manipulator<const Elem*>(start, end);
     }
     
+ template<typename Elem>
+ detail::assoc_item_begin_end_manipulator<const Elem*> assoc_item_begin_end(const Elem* start, const Elem* end)
+ {
+ // todo: just use delimiters function and fetch seperator?
+ return detail::assoc_item_begin_end_manipulator<const Elem*>(start, end);
+ }
+
     
     // manipulator
     namespace detail
@@ -278,6 +302,15 @@
             T seperatorVal_;
             T endVal_;
         };
+
+ template<typename T>
+ struct assoc_item_delimiters_manipulator : public detail::delimiters_manipulator<T>
+ {
+ assoc_item_delimiters_manipulator(T& startVal, T& seperatorVal, T& endVal)
+ : delimiters_manipulator<T>(startVal, seperatorVal, endVal)
+ {
+ }
+ };
 
         template<typename Elem, typename Tr, typename T>
         std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, const delimiters_manipulator<T>& manip)
@@ -287,6 +320,15 @@
             endFn(ostr, manip.endVal_);
             return ostr;
         }
+
+ template<typename Elem, typename Tr, typename T>
+ std::basic_ostream<Elem, Tr>& operator<<(std::basic_ostream<Elem, Tr>& ostr, const assoc_item_delimiters_manipulator<T>& manip)
+ {
+ assoc_item_startFn(ostr, manip.startVal_);
+ assoc_item_separatorFn(ostr, manip.seperatorVal_);
+ assoc_item_endFn(ostr, manip.endVal_);
+ return ostr;
+ }
     }
     
     template<typename Elem>
@@ -294,6 +336,12 @@
     {
         return detail::delimiters_manipulator<const Elem*>(start, seperator, end);
     }
+
+ template<typename Elem>
+ detail::assoc_item_delimiters_manipulator<const Elem*> assoc_item_delimiters(const Elem* start, const Elem* seperator, const Elem* end)
+ {
+ return detail::assoc_item_delimiters_manipulator<const Elem*>(start, seperator, end);
+ }
 }}
 
 #endif

Modified: sandbox/explore/boost/explore/stream_value.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_value.hpp (original)
+++ sandbox/explore/boost/explore/stream_value.hpp 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -32,7 +32,7 @@
         template<typename Elem, typename Tr, typename T>
         void operator()(std::basic_ostream<Elem, Tr>& ostr, const T& val, container_stream_state<Elem>* state, container_common_stream_state* common_state)
         {
- ostr << state->assoc_start() << val.first << state->assoc_separator() << val.second << state->assoc_end();
+ ostr << state->assoc_item_start() << val.first << state->assoc_item_separator() << val.second << state->assoc_item_end();
         }
     };
 }}

Modified: sandbox/explore/libs/explore/doc/custom_delimeters.qbk
==============================================================================
--- sandbox/explore/libs/explore/doc/custom_delimeters.qbk (original)
+++ sandbox/explore/libs/explore/doc/custom_delimeters.qbk 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -10,13 +10,13 @@
 Explore provides the ability to change the strings used in the container streaming process through the use of several new stream manipulators.
 
 [table Explore Stream Manipulators
- [[Manipulator] [Default][Description]]
- [[start(char*)] ['\['] [Changes the string output at the beginning of a container.]]
- [[end(char*)] ['\]'] [Changes the string output at the end of a container.]]
- [[seperator(char*)] [', '] [Changes the string output in between elements.]]
- [[assoc_start(char*)] [''] [Changes the string output at the front of an association.]]
- [[assoc_end(char*)] [''] [Changes the string output at the end of an association.]]
- [[assoc_seperator(char*)] [':'] [Changes the string output in between elements of an association.]]
+ [[Manipulator] [Default][Description]]
+ [[start(char*)] ['\['] [Changes the string output at the beginning of a container.]]
+ [[end(char*)] ['\]'] [Changes the string output at the end of a container.]]
+ [[seperator(char*)] [', '] [Changes the string output in between elements.]]
+ [[assoc_item_start(char*)] [''] [Changes the string output at the front of an association item.]]
+ [[assoc_item_end(char*)] [''] [Changes the string output at the end of an association item.]]
+ [[assoc_item_seperator(char*)] [':'] [Changes the string output in between elements of an association item.]]
 ]
 
 For example, to change the beginning and end output of a container to be the greater and less than symbols, you would do the following.

Modified: sandbox/explore/libs/explore/doc/html/boostbook.css
==============================================================================
--- sandbox/explore/libs/explore/doc/html/boostbook.css (original)
+++ sandbox/explore/libs/explore/doc/html/boostbook.css 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -304,6 +304,11 @@
     Variable Lists
 =============================================================================*/
 
+ div.variablelist
+ {
+ margin: 1em 0;
+ }
+
     /* Make the terms in definition lists bold */
     div.variablelist dl dt,
     span.term
@@ -374,6 +379,7 @@
     {
         body {
             background-color: #FFFFFF;
+ color: #000000;
         }
         
     /* Links */

Modified: sandbox/explore/libs/explore/test/custom_format_simple.cpp
==============================================================================
--- sandbox/explore/libs/explore/test/custom_format_simple.cpp (original)
+++ sandbox/explore/libs/explore/test/custom_format_simple.cpp 2009-08-31 23:17:41 EDT (Mon, 31 Aug 2009)
@@ -21,14 +21,14 @@
 {
     using namespace boost::explore;
     return ostr << start("<=") << separator("#") << end("=>")
- << assoc_start("<=") << assoc_separator("#") << assoc_end("=>");
+ << assoc_item_start("\\") << assoc_item_separator("**") << assoc_item_end("//");
 }
 
 std::wostream& basic_stream_format(std::wostream& ostr)
 {
     using namespace boost::explore;
     return ostr << start(L"<=") << separator(L"#") << end(L"=>")
- << assoc_start(L"<=") << assoc_separator(L"#") << assoc_end(L"=>");
+ << assoc_item_start(L"\\") << assoc_item_separator(L"**") << assoc_item_end(L"//");
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE( basic_vector_custom_format_stream_test, C, test_types )
@@ -78,7 +78,7 @@
 
     mis.insert(std::make_pair(1, str_to<C>("first")));
     str_out << mis;
- BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=\\1**first//=>");
 
     reset(str_out);
 
@@ -86,12 +86,12 @@
     mis.insert(std::make_pair(3, str_to<C>("third")));
 
     str_out << mis;
- BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=\\1**first//#\\2**second//#\\3**third//=>");
 
     reset(str_out);
 
     str_out << boost::explore::make_iterator_range(mis.begin(), ++(++mis.begin()));
- BOOST_CHECK_EQUAL(output(str_out), "<=<=1#first=>#<=2#second=>=>");
+ BOOST_CHECK_EQUAL(output(str_out), "<=\\1**first//#\\2**second//=>");
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE( begin_end_helper_test, C, test_types )
@@ -117,3 +117,28 @@
     str_out << boost::explore::delimiters(str_to<C>("F "), str_to<C>(" - "), str_to<C>(" L")) << vi;
     BOOST_CHECK_EQUAL(output(str_out), "F 1 - 2 - 3 L");
 }
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( assoc_item_begin_end_helper_test, C, test_types )
+{
+ typename test_traits<C>::stream_type str_out;
+
+ std::map<int,int> mii;
+ mii.insert( std::make_pair(1,10) );
+ mii.insert( std::make_pair(2,20) );
+ mii.insert( std::make_pair(3,30) );
+ str_out << boost::explore::assoc_item_begin_end(str_to<C>("\\"), str_to<C>("//")) << mii;
+ BOOST_CHECK_EQUAL(output(str_out), "[\\1:10//, \\2:20//, \\3:30//]");
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE( assoc_item_delimeters_helper_test, C, test_types )
+{
+ typename test_traits<C>::stream_type str_out;
+
+ std::map<int,int> mii;
+ mii.insert( std::make_pair(1,10) );
+ mii.insert( std::make_pair(2,20) );
+ mii.insert( std::make_pair(3,30) );
+ str_out << boost::explore::assoc_item_delimiters(str_to<C>("\\"), str_to<C>("--"), str_to<C>("//")) << mii;
+ BOOST_CHECK_EQUAL(output(str_out), "[\\1--10//, \\2--20//, \\3--30//]");
+}
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk