Boost logo

Boost-Commit :

From: jmcintyre_at_[hidden]
Date: 2008-03-22 16:05:28


Author: jared
Date: 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
New Revision: 43796
URL: http://svn.boost.org/trac/boost/changeset/43796

Log:
Moved the print() version of explore into its own explore_print directory in preparation for the stream implementation session at BoostCon.
Added:
   sandbox/explore/libs/explore/test/basic_lg_format.hpp (contents, props changed)
   sandbox/explore/libs/explore/test/boost_array.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/boost_range.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/boost_tuple.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/boost_variant.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/c_array.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/columnated.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/custom_format_simple.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/html_table_output.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/is_assoc_iter.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/multi_dim_test.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/simple_types.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_deque.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_list.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_map.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_pair.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_set.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/std_vector.cpp (contents, props changed)
   sandbox/explore/libs/explore/test/user_defined_container.cpp (contents, props changed)
   sandbox/explore_print/
   sandbox/explore_print/boost/
   sandbox/explore_print/boost/explore/
   sandbox/explore_print/boost/explore.hpp (contents, props changed)
   sandbox/explore_print/boost/explore/explore.hpp (contents, props changed)
   sandbox/explore_print/boost/explore/is_assoc_iter.hpp (contents, props changed)
   sandbox/explore_print/libs/
   sandbox/explore_print/libs/explore/
   sandbox/explore_print/libs/explore/build/
   sandbox/explore_print/libs/explore/doc/
   sandbox/explore_print/libs/explore/example/
   sandbox/explore_print/libs/explore/project-root.jam (contents, props changed)
   sandbox/explore_print/libs/explore/test/
   sandbox/explore_print/libs/explore/test/Jamfile.v2 (contents, props changed)
   sandbox/explore_print/libs/explore/test/basic_lg_format.hpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/boost_array.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/boost_range.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/boost_tuple.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/boost_variant.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/c_array.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/columnated.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/custom_format_simple.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/html_table_output.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/is_assoc_iter.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/multi_dim_test.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/simple_types.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_deque.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_list.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_map.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_pair.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_set.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/std_vector.cpp (contents, props changed)
   sandbox/explore_print/libs/explore/test/user_defined_container.cpp (contents, props changed)
Removed:
   sandbox/explore/boost/explore/explore.hpp
   sandbox/explore/boost/explore/html_table_format.hpp
   sandbox/explore/libs/explore/test/print/
   sandbox/explore/libs/explore/test/shared/
   sandbox/explore/libs/explore/test/stream/
Text files modified:
   sandbox/explore/boost/explore.hpp | 2 --
   sandbox/explore/libs/explore/test/Jamfile.v2 | 38 +++++++++++++++++++++++++++++++++++---
   2 files changed, 35 insertions(+), 5 deletions(-)

Modified: sandbox/explore/boost/explore.hpp
==============================================================================
--- sandbox/explore/boost/explore.hpp (original)
+++ sandbox/explore/boost/explore.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -7,7 +7,5 @@
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 //
 
-
-#include <boost/explore/explore.hpp>
 #include <boost/explore/stream_container.hpp>
 #include <boost/explore/iterator_range.hpp>

Deleted: sandbox/explore/boost/explore/explore.hpp
==============================================================================
--- sandbox/explore/boost/explore/explore.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
+++ (empty file)
@@ -1,505 +0,0 @@
-//
-// explore.hpp - container printing.
-//
-// This version is highly untested and should at least be run on more than one
-// compiler before considering for public view.
-//
-// Copyright (c) 2007 Danny Havenith
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-//
-
-#ifndef __EXPLORE_HPP_INCLUDED__
-#define __EXPLORE_HPP_INCLUDED__
-
-#include <iostream>
-#include <iterator>
-#include <boost/functional/detail/container_fwd.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/mpl/list.hpp>
-#include <boost/mpl/front.hpp>
-#include <boost/mpl/push_front.hpp>
-#include <boost/mpl/pop_front.hpp>
-#include <boost/mpl/identity.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/foreach.hpp>
-#include <boost/range/const_iterator.hpp>
-#include <boost/range/functions.hpp>
-#include <boost/range/iterator_range.hpp>
-#include "iterator_range.hpp"
-
-
-namespace explore {
- using namespace boost::mpl;
-
- namespace detail {
-
- //
- // some boilerplate stuff for the is_streamable metafunction
- //
-
- struct AlmostAnything
- {
- template<typename T> AlmostAnything( T const &);
- };
-
- //
- // operator<< cannot have a variable argument list, so we add this
- // one to the overload set, which should have quite low priority.
- //
- char operator<<( std::ostream &, AlmostAnything const &);
-
- template< typename T> T& make_t();
-
- // TODO: cleanup, not using char return type.
- template< typename T>
- struct is_streamable : bool_< sizeof( std::cout << make_t<T>()) != sizeof( char)>
- {
- };
-
- };
-
-
- template< typename T>
- struct is_streamable : detail::is_streamable<T> {};
-
-
- //
- // Generally, if we can stream it, we'll stream it. If not, we'll try
- // to treat it as a container of some kind.
- //
- template< typename T>
- struct print_as_container : not_< is_streamable< T> > {};
-
-
- //
- // Now follow a list exceptions that we want to print using our own functions
- // instead of the provided operator<< for those types.
- //
-
- // treat arrays as containers even though they are streamable
- // (normally they are streamed as pointer-to-void)
- //
- template< typename T, std::size_t size>
- struct print_as_container< T[size]> : true_ {};
-
- //
- // use our own implementation of streaming instead of the one
- // provided for iterator range.
- //
- template< typename T>
- struct print_as_container< boost::iterator_range<T> > : true_ {};
-
- //
- // oh, what the heck. Let's overload for explore::iterator_range
- // as well, just in case somebody uses this one by accident for
- // the print function.
- //
- template< typename T>
- struct print_as_container< explore::iterator_range<T> > : true_ {};
-
-
- //
- // make sure we use streaming for std containers
- //
- template <class T, class Allocator>
- struct print_as_container< std::deque< T, Allocator> > : true_ {};
-
- template <class T, class Allocator>
- struct print_as_container< std::list<T, Allocator> > : true_ {};
-
- template <class T, class Allocator>
- struct print_as_container< std::vector<T, Allocator> > : true_ {};
-
- template <class Key, class T, class Compare, class Allocator>
- struct print_as_container< std::map<Key,T, Compare, Allocator> > : true_ {};
-
- template <class Key, class T, class Compare, class Allocator>
- struct print_as_container< std::multimap<Key,T, Compare, Allocator> > : true_ {};
-
- template <class Key, class Compare, class Allocator>
- struct print_as_container< std::set<Key, Compare, Allocator> > : true_ {};
-
- template <class Key, class Compare, class Allocator>
- struct print_as_container< std::multiset<Key, Compare, Allocator> > : true_ {};
-
- template <class T1, class T2>
- struct print_as_container< std::pair<T1,T2> > : true_ {};
-
-
-
-
- //
- // is_map metafunction, probably needs to be extended for
- // hash_maps etc.
- // explore expects any type T for which is_map<T> is true_ to
- // have std::pair as value_type and will adapt the default formatting of
- // those pairs.
- //
- template< typename T>
- struct is_map : false_ {};
-
- template< typename K, typename V, typename P, typename A>
- struct is_map< std::map< K, V, P, A> > : true_ {};
-
- template< typename K, typename V, typename P, typename A>
- struct is_map< std::multimap< K, V, P, A> > : true_ {};
-
- //
- // A container policy determines whether an item of a certain type
- // gets broken up into items or if its going to be streamed directly
- //
- // by default, delegate to the 'global' metafunction,
- // which normally returns true iff a type cannot be streamed
- //
- struct default_container_policy
- {
- template< typename T>
- struct print_as_container : explore::print_as_container<T> {};
- };
-
-
- //
- // Meta functions that are used by the default implementation of format
- // These mainly deal with the fact that a format is a sequence of range
- // format selector types and that we want to re-use the last element of that
- // range when there are no other elements left.
- //
-
- //
- // metafunction that removes the first element of a sequence unless that would
- // make the sequence empty
- //
- template< typename sequence_type>
- struct pop_front_if :
- eval_if< bool_<size<sequence_type>::value == 1>,
- identity<sequence_type>,
- pop_front< sequence_type>
- >
- {};
-
- //
- // metafunction that replaces the leftmost element of a sequence with another type,
- // except if the sequence contained only 1 element, in which case the new head type is
- // pushed in front of the last one.
- //
- template< typename sequence_type, typename head_type>
- struct replace_head :
- push_front< BOOST_DEDUCED_TYPENAME pop_front_if< sequence_type>::type, head_type> {};
-
-
- //
- // A range format describes how the elements of a range are being
- // formatted.
- // This version supports only simple 'opener', 'delimiter', 'closer'
- // formats.
- struct basic_range_format
- {
- typedef char char_;
-
- //
- // not used currently.
- static char_ *header() { return "";}
- static char_ *footer() { return "";}
-
- //
- // default implementation of the next_format
- // meta function.
- // This defines how the format for the next recursion level is
- // chosen.
- template< typename sequence_type>
- struct next_format : pop_front_if< sequence_type> {};
- };
-
- // TODO: support other char types by making this a template
- struct default_range_format : basic_range_format
- {
- // only for sequences
- static char_ opening() { return '[';}
- static char_ closing() { return ']';}
- static char_ *delimiter() { return ", ";}
-
- // string_ escape( const string_ &);
- };
-
- struct map_pair_format : basic_range_format
- {
- static char_ *opening() { return "";}
- static char_ *closing() { return "";}
- static char_ delimiter() { return ':';}
- // string_ escape( const string_ &);
- };
-
- struct map_pair_format_selector
- {
- template< typename T>
- struct range_format: identity< map_pair_format> {};
- };
-
- struct map_range_format : default_range_format
- {
- template< typename sequence_type>
- struct next_format : replace_head< sequence_type, map_pair_format_selector> {};
- };
-
- // select a range format based on the type of the container
- struct default_range_format_selector
- {
-
- template< typename T>
- struct range_format : if_<
- is_map< T>,
- map_range_format,
- default_range_format>{};
-
- };
-
-
- struct default_format : boost::mpl::list< default_range_format_selector> {};
-
- //
- // Several container printer overloads.
- //
- template< typename format_type,
- typename container_policy_type,
- typename item_type
- >
- std::ostream &print_container( const item_type &item, std::ostream &stream )
- {
- // the first element of the format sequence is our current format-selector
- typedef BOOST_DEDUCED_TYPENAME front<format_type>::type format_selector;
-
- // the format-selector gives us a formatter, based on the type of the thing we need to format
- typedef BOOST_DEDUCED_TYPENAME format_selector::template range_format<item_type>::type formatter;
-
- // the formatter in it's turn tells us what the format for the next depth in the tree will be
- typedef BOOST_DEDUCED_TYPENAME formatter::template next_format< format_type>::type next_format_type;
-
-
- stream << formatter::opening();
- bool printing_first_item = true;
-
- typedef BOOST_DEDUCED_TYPENAME boost::range_const_iterator< const item_type>::type iterator_type;
- typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< iterator_type>::type value_type;
-
- for (
- iterator_type i = boost::const_begin( item);
- i != boost::const_end( item);
- ++i)
- {
- if (!printing_first_item)
- {
- stream << formatter::delimiter();
- }
-
- print( *i, stream, next_format_type(), container_policy_type());
- printing_first_item = false;
- }
- stream << formatter::closing();
-
- return stream;
- }
-
- // TODO: generalize for tuples
- template< typename format_type,
- typename container_policy_type,
- typename F,
- typename S
- >
- std::ostream &print_container( const std::pair<F,S> &item, std::ostream &stream )
- {
- typedef std::pair<F,S> item_type;
-
- // the first element of the format sequence is our current format-selector
- typedef BOOST_DEDUCED_TYPENAME front<format_type>::type format_selector;
-
- // the format-selector gives us a formatter, based on the type of the thing we need to format
- typedef BOOST_DEDUCED_TYPENAME format_selector:: template range_format<item_type>::type formatter;
-
- // the formatter in it's turn tells us what the format for the next depth in the tree will be
- typedef BOOST_DEDUCED_TYPENAME formatter:: template next_format< format_type>::type next_format_type;
-
- stream << formatter::opening();
- print( item.first, stream, next_format_type(), container_policy_type());
- stream << formatter::delimiter();
- print( item.second, stream, next_format_type(), container_policy_type());
- return stream << formatter::closing();
- }
-
- //
- // the print_item methods of this class are called whenever print has deduced that
- // the item to print is some container-type
- //
- struct container_printer
- {
- template<
- typename format_type,
- typename container_policy_type,
- typename item_type
- >
- static std::ostream &print_item( const item_type &item, std::ostream &stream)
- {
- return print_container<format_type, container_policy_type>( item, stream);
- }
-
-
- };
-
- struct pointer_printer
- {
- template< typename format_type,
- typename container_policy_type,
- typename item_type
- >
- static std::ostream &print_item( const item_type *item, std::ostream &stream )
- {
- if( NULL == item )
- {
- return stream << (char *)"null";
- }
- //
- // DH - changed until we figure out what special things to do with pointer types
- // return print(*item, stream, format_type(), container_policy_type());
- return stream << item;
- }
- };
-
- struct item_printer
- {
- template< typename format_type,
- typename container_policy_type,
- typename item_type
- >
- static std::ostream &print_item( const item_type &item, std::ostream &stream )
- {
- return stream << item;
- }
- };
-
- /**
- * This is the main entrance to print.
- * This function tries to stream it's first argument (the item) to the stream given as a second argument.
- * If the item has no stream operator, print will try to treat it as some form of container and call itself recursively
- * on every element of the container.
- *
- * Print ask the container policy whether to treat the item as a container. If directed so, it will delegate to the
- * print_container free function in namespace scope.
- * Otherwise, it will try to stream the item using the expression "stream << item".
- *
- * \param &item the item to stream
- * \param &stream the stream that receives the item or its elements
- * \param &format the format to use (string escaping, delimiters etc.)
- * \param &policy a type that decides when a type needs to be treated as a container.
- * \return the original stream (second argument)
- */
- template< typename format_type,
- typename container_policy_type ,
- typename item_type
- >
- std::ostream &print( const item_type &item,
- std::ostream &stream,
- const format_type &format,
- const container_policy_type &policy)
- {
- typedef typename eval_if<
- typename container_policy_type:: template print_as_container< item_type>::type,
- identity<container_printer>,
- eval_if<
- typename boost::is_pointer<item_type>::type,
- identity<pointer_printer>,
- identity<item_printer>
- >
- >::type printer_type;
-
-
- return printer_type::template print_item< format_type, container_policy_type>( item, stream);
- }
-
- template < typename item_type>
- std::ostream &print( const item_type &item, std::ostream &stream = std::cout)
- {
- return print( item, stream, default_format(), default_container_policy());
- }
-
- template< typename format_type,
- typename container_policy_type ,
- class InputIterator
- >
- std::ostream &print( InputIterator first,
- InputIterator last,
- std::ostream &stream,
- const format_type &format,
- const container_policy_type &policy)
- {
- return print( boost::make_iterator_range(first, last), stream, format, policy );
- }
-
- template<class InputIterator>
- std::ostream &print(InputIterator first, InputIterator last, std::ostream &stream = std::cout)
- {
- return print( boost::make_iterator_range(first, last), stream );
- }
-
-
- //
- // The container_formatter type to allow "inline" streaming like the following
- //
- // std::cout << container_format( my_formatter) % my_container1 << ...
- //
-
- template< typename container, typename formatter>
- struct container_format_class
- {
- container_format_class( const container &c)
- : container_( c)
- {
- // nop
- };
-
- const container &get_container() const
- {
- return container_;
- }
- private:
- const container &container_;
-
- };
-
- template< typename formatter>
- struct unbound_container_format_class
- {
- };
-
- template< typename formatter>
- unbound_container_format_class< formatter> container_format( const formatter &)
- {
- return unbound_container_format_class<formatter>();
- }
-
- unbound_container_format_class< default_format> container_format()
- {
- return unbound_container_format_class< default_format>();
- }
-
- template< typename container, typename formatter>
- container_format_class< container, formatter> operator%( unbound_container_format_class<formatter> &u, const container &c)
- {
- return container_format_class< container, formatter>( c);
- }
-
- template< typename container, typename formatter>
- std::ostream &operator<<( std::ostream &strm, const container_format_class< container, formatter> &cf)
- {
- return print( cf.get_container(), strm);
- }
-
-}
-
-#endif //__EXPLORE_HPP_INCLUDED__
-

Deleted: sandbox/explore/boost/explore/html_table_format.hpp
==============================================================================
--- sandbox/explore/boost/explore/html_table_format.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
+++ (empty file)
@@ -1,52 +0,0 @@
-//
-// explore.hpp - container printing.
-//
-// This version is highly untested and should at least be run on more than one
-// compiler before considering for public view.
-//
-// Copyright (c) 2007 Danny Havenith
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-//
-#ifndef __BOOST_EXPLORE_HTML_TABLE_FORMAT_HPP__
-#define __BOOST_EXPLORE_HTML_TABLE_FORMAT_HPP__
-
-#include <boost/explore/explore.hpp>
-namespace explore
-{
- //
- // support for html-table layout
- struct html_table_1_format : basic_range_format
- {
- static char_ *opening() { return "<table>\n<tr>"; }
- static char_ *closing() { return "</tr>\n</table>\n"; }
- static char_ *delimiter() { return "</tr>\n<tr>"; }
- };
-
- struct html_table_2_format : basic_range_format
- {
- static char_ *opening() { return "<td>"; }
- static char_ *closing() { return "</td>"; }
- static char_ *delimiter() { return "</td><td>"; }
- };
-
- //
- // a format selector that will return the same format
- // for every type.
- //
- template< typename range_format_>
- struct uniform_format_selector
- {
- template< typename T>
- struct range_format : identity<range_format_> {};
- };
-
- struct html_table_format : boost::mpl::list<
- uniform_format_selector< html_table_1_format>,
- uniform_format_selector< html_table_2_format>,
- default_range_format_selector>
- {};
-}
-#endif //__BOOST_EXPLORE_HTML_TABLE_FORMAT_HPP__
\ No newline at end of file

Modified: sandbox/explore/libs/explore/test/Jamfile.v2
==============================================================================
--- sandbox/explore/libs/explore/test/Jamfile.v2 (original)
+++ sandbox/explore/libs/explore/test/Jamfile.v2 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -7,6 +7,38 @@
 
 # For more information, see http://www.boost.org
 
-build-project shared//explore_shared_components ;
-build-project print//explore_print ;
-build-project stream//explore_stream ;
\ No newline at end of file
+# bring in rules for testing
+import testing ;
+
+project
+ : source-location .
+ : requirements
+ ;
+{
+ test-suite explore_stream
+ :
+ [ run is_assoc_iter.cpp ]
+ [ run simple_types.cpp ]
+ [ run c_array.cpp ]
+ [ run user_defined_container.cpp ]
+
+ [ run std_vector.cpp ]
+ [ run std_deque.cpp ]
+ [ run std_list.cpp ]
+ [ run std_map.cpp ]
+ [ run std_set.cpp ]
+ [ run std_pair.cpp ]
+
+ [ run boost_array.cpp ]
+ [ run boost_tuple.cpp ]
+ [ run boost_variant.cpp ]
+
+ [ run boost_range.cpp ]
+
+ [ run custom_format_simple.cpp ]
+ [ run html_table_output.cpp ]
+ [ run multi_dim_test.cpp ]
+
+ [ run columnated.cpp ]
+ ;
+}

Added: sandbox/explore/libs/explore/test/basic_lg_format.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/basic_lg_format.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,21 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <boost/explore.hpp>
+
+// for streaming
+std::ostream& basic_lg_stream_format(std::ostream& ostr)
+{
+ using namespace explore;
+ return ostr << start("<=") << separator("#") << explore::end("=>")
+ << assoc_start("<=") << assoc_separator("#") << assoc_end("=>");
+}

Added: sandbox/explore/libs/explore/test/boost_array.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/boost_array.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,75 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/array.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_array_stream_test )
+{
+ std::stringstream str_out;
+
+ boost::array<int,0> ai0;
+ str_out << ai0;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ boost::array<int,1> ai1 = {1};
+ str_out << ai1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ boost::array<int,3> ai3 = {1, 2, 3};
+ str_out << ai3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ boost::array<int,3>::iterator itr = ai3.begin() + 2;
+
+ str_out << explore::make_iterator_range(ai3.begin(), itr);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_array_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ boost::array<std::vector<int>,0> av0;
+ str_out << av0;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,1> av1 = {vi};
+ str_out << av1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,3> av3 = {vi, vi, vi};
+ str_out << av3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,3>::iterator itr = av3.begin() + 2;
+ str_out << explore::make_iterator_range(av3.begin(), itr);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/boost_range.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/boost_range.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,45 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/range/iterator_range.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( boost_range_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ str_out << explore::make_iterator_range(vi);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ str_out << explore::make_iterator_range(vi);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ str_out << explore::make_iterator_range(vi);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+ str_out << explore::make_iterator_range(vi.begin()+2, vi.end());
+ BOOST_CHECK_EQUAL(str_out.str(), "[3]");
+
+ str_out.str("");
+ str_out << explore::make_iterator_range(vi.rbegin(), vi.rend());
+ BOOST_CHECK_EQUAL(str_out.str(), "[3, 2, 1]");
+}

Added: sandbox/explore/libs/explore/test/boost_tuple.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/boost_tuple.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,27 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/tuple/tuple.hpp>
+#include <boost/tuple/tuple_io.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_tuple_stream_test )
+{
+ std::stringstream str_out;
+
+ boost::tuples::tuple<int, double> t(1, 3.14);
+ str_out << t;
+ // I think things that already have a way to print should not change
+ //BOOST_CHECK_EQUAL(str_out.str(), "[1, 3.14]");
+ BOOST_CHECK_EQUAL(str_out.str(), "(1 3.14)");
+}

Added: sandbox/explore/libs/explore/test/boost_variant.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/boost_variant.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,42 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/variant.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_variant_stream_test )
+{
+ std::stringstream str_out;
+
+ boost::variant< int, std::string, std::vector<int> > varVal;
+
+ varVal = 1;
+ str_out << varVal;
+ BOOST_CHECK_EQUAL(str_out.str(), "1");
+
+ str_out.str("");
+
+ varVal = std::string("some string");
+ str_out << varVal;
+ BOOST_CHECK_EQUAL(str_out.str(), "some string");
+
+ str_out.str("");
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+ varVal = vi;
+ str_out << varVal;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}

Added: sandbox/explore/libs/explore/test/c_array.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/c_array.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,52 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_c_array_stream_test )
+{
+ using namespace explore;
+ std::stringstream str_out;
+
+ int arri1[] = {1};
+ str_out << arri1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ int arri3[] = {1,2,3};
+ str_out << arri3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_stream_test )
+{
+ using namespace explore;
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ str_out << arrvi1;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ str_out << arrvi3;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore/libs/explore/test/columnated.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/columnated.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,70 @@
+// Boost.Explore library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+struct columnated_format
+{
+ columnated_format(std::size_t rows, std::size_t width) : m_rows(rows), m_width(width) {}
+ std::size_t m_rows;
+ std::size_t m_width;
+
+ friend std::ostream& operator<<(std::ostream& ostr, const columnated_format& f)
+ {
+ using namespace explore;
+ ostr << setrows(f.m_rows) << setitemwidth(f.m_width)
+ << separator("") << start("") << explore::end("");
+ return ostr;
+ }
+};
+
+BOOST_AUTO_TEST_CASE( basic_columnate_stream_test )
+{
+ using namespace explore;
+ std::stringstream str_out;
+ std::vector<int> vi;
+
+ for( int i = 0; i < 12; ++i )
+ {
+ vi.push_back(i);
+ }
+
+ str_out << setrows(3) << start("") << explore::end("") << vi;
+
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "0, 1, 2, \n"
+ "3, 4, 5, \n"
+ "6, 7, 8, \n"
+ "9, 10, 11");
+
+ str_out.str("");
+
+ str_out << setrows(3) << setitemwidth(5) << start("") << explore::end("") << vi;
+
+ BOOST_CHECK_EQUAL(str_out.str(),
+ " 0, 1, 2, \n"
+ " 3, 4, 5, \n"
+ " 6, 7, 8, \n"
+ " 9, 10, 11");
+
+ str_out.str("");
+
+ str_out << columnated_format(3, 5) << vi;
+
+ BOOST_CHECK_EQUAL(str_out.str(),
+ " 0 1 2\n"
+ " 3 4 5\n"
+ " 6 7 8\n"
+ " 9 10 11");
+}

Added: sandbox/explore/libs/explore/test/custom_format_simple.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/custom_format_simple.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,79 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+#include "basic_lg_format.hpp"
+
+BOOST_AUTO_TEST_CASE( basic_vector_custom_format_stream_test )
+{
+ std::stringstream str_out;
+ str_out << basic_lg_stream_format;
+
+ std::vector<int> vi;
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1=>");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(vi.begin(), ++(++vi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+
+ str_out.str("");
+
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+}
+
+BOOST_AUTO_TEST_CASE( basic_map_custom_format_stream_test )
+{
+ std::stringstream str_out;
+ str_out << basic_lg_stream_format;
+
+ std::map<int,std::string> mis;
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(1, "first"));
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>=>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(2, "second"));
+ mis.insert(std::make_pair(3, "third"));
+
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(mis.begin(), ++(++mis.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+}

Added: sandbox/explore/libs/explore/test/html_table_output.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/html_table_output.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,61 @@
+// Boost.Explore library
+
+// Copyright Danny Havenith 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+std::ostream& html_table_stream_format(std::ostream& ostr)
+{
+ using namespace explore;
+ ostr << start("<table>\n")
+ << separator("")
+ << explore::end("</table>\n");
+
+ ostr << start("<tr><td>", 1)
+ << separator("</td><td>", 1)
+ << explore::end("</td></tr>\n", 1);
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_html_stream_test )
+{
+ using namespace explore;
+ std::stringstream str_out;
+ str_out << html_table_stream_format;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ str_out << arrvi1;
+
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "<table>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "</table>\n");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ str_out << arrvi3;
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "<table>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "</table>\n");
+}
+

Added: sandbox/explore/libs/explore/test/is_assoc_iter.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/is_assoc_iter.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,38 @@
+// Boost.Print library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <list>
+#include <boost/explore.hpp>
+#include <boost/explore/is_assoc_iter.hpp>
+
+BOOST_AUTO_TEST_CASE( is_assoc_iter_test )
+{
+ bool mapHasAssocIter = explore::is_assoc_iter<std::map<int, double>::iterator>::type();
+ BOOST_CHECK(mapHasAssocIter);
+
+ bool multimapHasAssocIter = explore::is_assoc_iter<std::multimap<std::string, bool>::iterator>::type();
+ BOOST_CHECK(multimapHasAssocIter);
+
+ bool vectorHasAssocIter = explore::is_assoc_iter<std::vector<double>::iterator>::type();
+ BOOST_CHECK(!vectorHasAssocIter);
+
+ bool pointerHasAssocIter = explore::is_assoc_iter<int*>::type();
+ BOOST_CHECK(!pointerHasAssocIter);
+
+ bool pairHasAssocIter = explore::is_assoc_iter<std::pair<int, double> >::type();
+ BOOST_CHECK(!pairHasAssocIter);
+
+ bool listOfPairHasAssocIter = explore::is_assoc_iter<std::list<std::pair<int, double> >::iterator >::type();
+ BOOST_CHECK(!listOfPairHasAssocIter);
+}

Added: sandbox/explore/libs/explore/test/multi_dim_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/multi_dim_test.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,102 @@
+// Boost.Explore library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+std::ostream& format_2d(std::ostream& ostr)
+{
+ using namespace explore;
+
+ // level 0
+ ostr << start("") << explore::end("") << separator("\n");
+
+ // level 1
+ ostr << start("|", 1) << explore::end("|", 1) << separator(" ", 1);
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE( two_dimension_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ std::vector<std::vector<int> > vvi;
+
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+
+ str_out << format_2d << vvi;
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|");
+}
+
+std::ostream& format_3d(std::ostream& ostr)
+{
+ using namespace explore;
+
+ // level 0
+ ostr << start("") << explore::end("") << separator("\n\n");
+
+ // level 1
+ ostr << start("", 1) << explore::end("", 1) << separator("\n", 1);
+
+ // level 2
+ ostr << start("|", 2) << explore::end("|", 2) << separator(" ", 2);
+
+ return ostr;
+}
+
+BOOST_AUTO_TEST_CASE( three_dimension_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ std::vector<std::vector<int> > vvi;
+ std::vector<std::vector<std::vector<int> > > vvvi;
+
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+
+ vvvi.push_back(vvi);
+ vvvi.push_back(vvi);
+ vvvi.push_back(vvi);
+
+ str_out << format_3d << vvvi;
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|"
+ );
+}

Added: sandbox/explore/libs/explore/test/simple_types.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/simple_types.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,99 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <boost/lexical_cast.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( int_stream_test )
+{
+ std::stringstream str_out;
+ int i = 123;
+
+ str_out << i;
+ BOOST_CHECK_EQUAL(str_out.str(), "123");
+
+ str_out.str("");
+ int* pi = &i;
+
+ str_out << pi;
+ // technically, we should force this to be true, though
+ // it is highly unlikely to be false. Otherwise this test is only
+ // telling you whether the following is even valid.
+ //BOOST_CHECK(0 != boost::lexical_cast<std::string>((long)pi).compare("123"));
+ //BOOST_CHECK_EQUAL(str_out.str(), "123");
+}
+
+BOOST_AUTO_TEST_CASE( float_stream_test )
+{
+ std::stringstream str_out;
+ float f = 1.234f;
+
+ str_out << std::setprecision(4) << f;
+ BOOST_CHECK_EQUAL(str_out.str(), "1.234");
+
+ //BOOST_CHECK_MESSAGE(false, "Test min precision");
+ //BOOST_CHECK_MESSAGE(false, "Test max precision");
+}
+
+BOOST_AUTO_TEST_CASE( double_stream_test )
+{
+ std::stringstream str_out;
+ double d = 1.2341234f;
+
+ str_out << std::setprecision(7) << d;
+ BOOST_CHECK_EQUAL(str_out.str(), "1.234123");
+
+ //BOOST_CHECK_MESSAGE(false, "Test min precision");
+ //BOOST_CHECK_MESSAGE(false, "Test max precision");
+}
+
+BOOST_AUTO_TEST_CASE( bool_stream_test )
+{
+ std::stringstream str_out;
+ bool b = true;
+
+ str_out << std::boolalpha << b;
+ BOOST_CHECK_EQUAL(str_out.str(), "true");
+
+ str_out.str("");
+ b = false;
+
+ str_out << std::boolalpha << b;
+ BOOST_CHECK_EQUAL(str_out.str(), "false");
+}
+
+BOOST_AUTO_TEST_CASE( char_stream_test )
+{
+ std::stringstream str_out;
+ char c = 'c';
+
+ str_out << c;
+ BOOST_CHECK_EQUAL(str_out.str(), "c");
+
+ str_out.str("");
+ char* pc = "c";
+
+ str_out << pc;
+ BOOST_CHECK_EQUAL(str_out.str(), "c");
+}
+
+BOOST_AUTO_TEST_CASE( string_stream_test )
+{
+ std::stringstream str_out;
+ std::string s = "some string";
+
+ str_out << s;
+
+ BOOST_CHECK_EQUAL(str_out.str(), "some string");
+}

Added: sandbox/explore/libs/explore/test/std_deque.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_deque.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,74 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <deque>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_deque_stream_test )
+{
+ std::stringstream str_out;
+
+ std::deque<int> di;
+ str_out << di;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ di.push_back(1);
+ str_out << di;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ di.push_back(2);
+ di.push_back(3);
+ str_out << di;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(di.begin(), ++(++di.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( deque_in_deque_stream_test )
+{
+ std::stringstream str_out;
+
+ std::deque<int> di;
+ di.push_back(1);
+ di.push_back(2);
+ di.push_back(3);
+
+ std::deque<std::deque<int> > ddi;
+ str_out << ddi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ ddi.push_back(di);
+ str_out << ddi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ ddi.push_back(di);
+ ddi.push_back(di);
+ str_out << ddi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(ddi.begin(), ++(++ddi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/std_list.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_list.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,75 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <list>
+#include <complex>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_list_stream_test )
+{
+ std::stringstream str_out;
+
+ std::list<std::complex<double> > lc;
+ str_out << lc;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ lc.push_back(std::complex<double>(0,1));
+ str_out << lc;
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1)]");
+
+ str_out.str("");
+
+ lc.push_back(std::complex<double>(2,3));
+ lc.push_back(std::complex<double>(4,5));
+ str_out << lc;
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3), (4,5)]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(lc.begin(), ++(++lc.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3)]");
+}
+
+BOOST_AUTO_TEST_CASE( list_in_list_stream_test )
+{
+ std::stringstream str_out;
+
+ std::list<int> li;
+ li.push_back(1);
+ li.push_back(2);
+ li.push_back(3);
+
+ std::list<std::list<int> > lli;
+ str_out << lli;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ lli.push_back(li);
+ str_out << lli;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ lli.push_back(li);
+ lli.push_back(li);
+ str_out << lli;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(lli.begin(), ++(++lli.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/std_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_map.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,109 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_map_stream_test )
+{
+ std::stringstream str_out;
+
+ std::map<int,std::string> mis;
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(1, "first"));
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(2, "second"));
+ mis.insert(std::make_pair(3, "third"));
+ str_out << mis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second, 3:third]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(mis.begin(), ++(++mis.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second]");
+}
+
+BOOST_AUTO_TEST_CASE( basic_multimap_stream_test )
+{
+ std::stringstream str_out;
+
+ std::multimap<int,std::string> mmis;
+ str_out << mmis;;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(1, "first"));
+ str_out << mmis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(1, "single"));
+ str_out << mmis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(2, "second"));
+ mmis.insert(std::make_pair(3, "third"));
+ mmis.insert(std::make_pair(3, "triple"));
+ str_out << mmis;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single, 2:second, 3:third, 3:triple]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(mmis.begin(), ++(++mmis.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_map_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::map<int,std::vector<int> > mivi;
+ str_out << mivi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mivi.insert(std::make_pair(1, vi));
+ str_out << mivi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3]]");
+
+ str_out.str("");
+
+ mivi.insert(std::make_pair(2, vi));
+ mivi.insert(std::make_pair(3, vi));
+ str_out << mivi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3], 3:[1, 2, 3]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(mivi.begin(), ++(++mivi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/std_pair.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_pair.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,52 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_pair_stream_test )
+{
+ std::stringstream str_out;
+
+ std::pair<int,int> pi = std::make_pair(1,2);
+ str_out << pi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( pair_in_vector_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<std::pair<int,int> > vpi;
+ str_out << vpi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ std::pair<int,int> pi = std::make_pair(1,2);
+
+ vpi.push_back(pi);
+ str_out << vpi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2]]");
+
+ str_out.str("");
+
+ vpi.push_back(pi);
+ vpi.push_back(pi);
+ str_out << vpi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2], [1, 2]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(vpi.begin(), ++(++vpi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2]]");
+}

Added: sandbox/explore/libs/explore/test/std_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_set.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,108 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <set>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_set_stream_test )
+{
+ std::stringstream str_out;
+
+ std::set<int> si;
+ str_out << si;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ si.insert(1);
+ str_out << si;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ si.insert(2);
+ si.insert(3);
+ str_out << si;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(si.begin(), ++(++si.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( basic_multiset_stream_test )
+{
+ std::stringstream str_out;
+
+ std::multiset<int> msi;
+ str_out << msi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ msi.insert(1);
+ str_out << msi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ msi.insert(1);
+ str_out << msi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+
+ str_out.str("");
+
+ msi.insert(2);
+ msi.insert(3);
+ msi.insert(3);
+ str_out << msi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1, 2, 3, 3]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(msi.begin(), ++(++msi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_set_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::multiset<std::vector<int> > svi;
+ str_out << svi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ svi.insert(vi);
+ str_out << svi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ svi.insert(vi);
+ svi.insert(vi);
+ str_out << svi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(svi.begin(), ++(++svi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/std_vector.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/std_vector.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,85 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_vector_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ str_out << vi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(vi.begin(), ++(++vi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_vector_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<std::vector<int> > vvi;
+ str_out << vvi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vvi.push_back(vi);
+ str_out << vvi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ str_out << vvi;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ str_out << explore::make_iterator_range(vvi.begin(), ++(++vvi.begin()));
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_with_ugly_string_case_stream_test )
+{
+ std::stringstream str_out;
+
+ std::vector<std::string> vs;
+ vs.push_back("[1, 2, 3], [1, 2, 3], [1, 2, 3]");
+ str_out << vs;
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}

Added: sandbox/explore/libs/explore/test/user_defined_container.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore/libs/explore/test/user_defined_container.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,53 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+class user_vector
+{
+public:
+ user_vector()
+ {
+ m_vec.push_back(1);
+ m_vec.push_back(2);
+ m_vec.push_back(3);
+ }
+
+ std::vector<int>::const_iterator start() const
+ {
+ return m_vec.begin();
+ }
+
+ std::vector<int>::const_iterator finish() const
+ {
+ return m_vec.end();
+ }
+
+private:
+ std::vector<int> m_vec;
+};
+
+std::ostream& operator<<(std::ostream& ostr, const user_vector& u)
+{
+ return explore::stream_container(ostr, u.start(), u.finish());
+}
+
+BOOST_AUTO_TEST_CASE( user_defined_stream_test )
+{
+ std::stringstream str_out;
+
+ user_vector v;
+ str_out << v;
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+

Added: sandbox/explore_print/boost/explore.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/boost/explore.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,12 @@
+//
+// explore.hpp -- conviencence header
+//
+// Copyright (C) 2007, Jeff Garland
+// Copyright (C) 2008, Jared McIntyre
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+
+#include <boost/explore/explore.hpp>

Added: sandbox/explore_print/boost/explore/explore.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/boost/explore/explore.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,504 @@
+//
+// explore.hpp - container printing.
+//
+// This version is highly untested and should at least be run on more than one
+// compiler before considering for public view.
+//
+// Copyright (c) 2007 Danny Havenith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+
+#ifndef __EXPLORE_HPP_INCLUDED__
+#define __EXPLORE_HPP_INCLUDED__
+
+#include <iostream>
+#include <iterator>
+#include <boost/functional/detail/container_fwd.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/list.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/push_front.hpp>
+#include <boost/mpl/pop_front.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/foreach.hpp>
+#include <boost/range/const_iterator.hpp>
+#include <boost/range/functions.hpp>
+#include <boost/range/iterator_range.hpp>
+
+
+namespace explore {
+ using namespace boost::mpl;
+
+ namespace detail {
+
+ //
+ // some boilerplate stuff for the is_streamable metafunction
+ //
+
+ struct AlmostAnything
+ {
+ template<typename T> AlmostAnything( T const &);
+ };
+
+ //
+ // operator<< cannot have a variable argument list, so we add this
+ // one to the overload set, which should have quite low priority.
+ //
+ char operator<<( std::ostream &, AlmostAnything const &);
+
+ template< typename T> T& make_t();
+
+ // TODO: cleanup, not using char return type.
+ template< typename T>
+ struct is_streamable : bool_< sizeof( std::cout << make_t<T>()) != sizeof( char)>
+ {
+ };
+
+ };
+
+
+ template< typename T>
+ struct is_streamable : detail::is_streamable<T> {};
+
+
+ //
+ // Generally, if we can stream it, we'll stream it. If not, we'll try
+ // to treat it as a container of some kind.
+ //
+ template< typename T>
+ struct print_as_container : not_< is_streamable< T> > {};
+
+
+ //
+ // Now follow a list exceptions that we want to print using our own functions
+ // instead of the provided operator<< for those types.
+ //
+
+ // treat arrays as containers even though they are streamable
+ // (normally they are streamed as pointer-to-void)
+ //
+ template< typename T, std::size_t size>
+ struct print_as_container< T[size]> : true_ {};
+
+ //
+ // use our own implementation of streaming instead of the one
+ // provided for iterator range.
+ //
+ template< typename T>
+ struct print_as_container< boost::iterator_range<T> > : true_ {};
+
+ //
+ // oh, what the heck. Let's overload for explore::iterator_range
+ // as well, just in case somebody uses this one by accident for
+ // the print function.
+ //
+ template< typename T>
+ struct print_as_container< explore::iterator_range<T> > : true_ {};
+
+
+ //
+ // make sure we use streaming for std containers
+ //
+ template <class T, class Allocator>
+ struct print_as_container< std::deque< T, Allocator> > : true_ {};
+
+ template <class T, class Allocator>
+ struct print_as_container< std::list<T, Allocator> > : true_ {};
+
+ template <class T, class Allocator>
+ struct print_as_container< std::vector<T, Allocator> > : true_ {};
+
+ template <class Key, class T, class Compare, class Allocator>
+ struct print_as_container< std::map<Key,T, Compare, Allocator> > : true_ {};
+
+ template <class Key, class T, class Compare, class Allocator>
+ struct print_as_container< std::multimap<Key,T, Compare, Allocator> > : true_ {};
+
+ template <class Key, class Compare, class Allocator>
+ struct print_as_container< std::set<Key, Compare, Allocator> > : true_ {};
+
+ template <class Key, class Compare, class Allocator>
+ struct print_as_container< std::multiset<Key, Compare, Allocator> > : true_ {};
+
+ template <class T1, class T2>
+ struct print_as_container< std::pair<T1,T2> > : true_ {};
+
+
+
+
+ //
+ // is_map metafunction, probably needs to be extended for
+ // hash_maps etc.
+ // explore expects any type T for which is_map<T> is true_ to
+ // have std::pair as value_type and will adapt the default formatting of
+ // those pairs.
+ //
+ template< typename T>
+ struct is_map : false_ {};
+
+ template< typename K, typename V, typename P, typename A>
+ struct is_map< std::map< K, V, P, A> > : true_ {};
+
+ template< typename K, typename V, typename P, typename A>
+ struct is_map< std::multimap< K, V, P, A> > : true_ {};
+
+ //
+ // A container policy determines whether an item of a certain type
+ // gets broken up into items or if its going to be streamed directly
+ //
+ // by default, delegate to the 'global' metafunction,
+ // which normally returns true iff a type cannot be streamed
+ //
+ struct default_container_policy
+ {
+ template< typename T>
+ struct print_as_container : explore::print_as_container<T> {};
+ };
+
+
+ //
+ // Meta functions that are used by the default implementation of format
+ // These mainly deal with the fact that a format is a sequence of range
+ // format selector types and that we want to re-use the last element of that
+ // range when there are no other elements left.
+ //
+
+ //
+ // metafunction that removes the first element of a sequence unless that would
+ // make the sequence empty
+ //
+ template< typename sequence_type>
+ struct pop_front_if :
+ eval_if< bool_<size<sequence_type>::value == 1>,
+ identity<sequence_type>,
+ pop_front< sequence_type>
+ >
+ {};
+
+ //
+ // metafunction that replaces the leftmost element of a sequence with another type,
+ // except if the sequence contained only 1 element, in which case the new head type is
+ // pushed in front of the last one.
+ //
+ template< typename sequence_type, typename head_type>
+ struct replace_head :
+ push_front< BOOST_DEDUCED_TYPENAME pop_front_if< sequence_type>::type, head_type> {};
+
+
+ //
+ // A range format describes how the elements of a range are being
+ // formatted.
+ // This version supports only simple 'opener', 'delimiter', 'closer'
+ // formats.
+ struct basic_range_format
+ {
+ typedef char char_;
+
+ //
+ // not used currently.
+ static char_ *header() { return "";}
+ static char_ *footer() { return "";}
+
+ //
+ // default implementation of the next_format
+ // meta function.
+ // This defines how the format for the next recursion level is
+ // chosen.
+ template< typename sequence_type>
+ struct next_format : pop_front_if< sequence_type> {};
+ };
+
+ // TODO: support other char types by making this a template
+ struct default_range_format : basic_range_format
+ {
+ // only for sequences
+ static char_ opening() { return '[';}
+ static char_ closing() { return ']';}
+ static char_ *delimiter() { return ", ";}
+
+ // string_ escape( const string_ &);
+ };
+
+ struct map_pair_format : basic_range_format
+ {
+ static char_ *opening() { return "";}
+ static char_ *closing() { return "";}
+ static char_ delimiter() { return ':';}
+ // string_ escape( const string_ &);
+ };
+
+ struct map_pair_format_selector
+ {
+ template< typename T>
+ struct range_format: identity< map_pair_format> {};
+ };
+
+ struct map_range_format : default_range_format
+ {
+ template< typename sequence_type>
+ struct next_format : replace_head< sequence_type, map_pair_format_selector> {};
+ };
+
+ // select a range format based on the type of the container
+ struct default_range_format_selector
+ {
+
+ template< typename T>
+ struct range_format : if_<
+ is_map< T>,
+ map_range_format,
+ default_range_format>{};
+
+ };
+
+
+ struct default_format : boost::mpl::list< default_range_format_selector> {};
+
+ //
+ // Several container printer overloads.
+ //
+ template< typename format_type,
+ typename container_policy_type,
+ typename item_type
+ >
+ std::ostream &print_container( const item_type &item, std::ostream &stream )
+ {
+ // the first element of the format sequence is our current format-selector
+ typedef BOOST_DEDUCED_TYPENAME front<format_type>::type format_selector;
+
+ // the format-selector gives us a formatter, based on the type of the thing we need to format
+ typedef BOOST_DEDUCED_TYPENAME format_selector::template range_format<item_type>::type formatter;
+
+ // the formatter in it's turn tells us what the format for the next depth in the tree will be
+ typedef BOOST_DEDUCED_TYPENAME formatter::template next_format< format_type>::type next_format_type;
+
+
+ stream << formatter::opening();
+ bool printing_first_item = true;
+
+ typedef BOOST_DEDUCED_TYPENAME boost::range_const_iterator< const item_type>::type iterator_type;
+ typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< iterator_type>::type value_type;
+
+ for (
+ iterator_type i = boost::const_begin( item);
+ i != boost::const_end( item);
+ ++i)
+ {
+ if (!printing_first_item)
+ {
+ stream << formatter::delimiter();
+ }
+
+ print( *i, stream, next_format_type(), container_policy_type());
+ printing_first_item = false;
+ }
+ stream << formatter::closing();
+
+ return stream;
+ }
+
+ // TODO: generalize for tuples
+ template< typename format_type,
+ typename container_policy_type,
+ typename F,
+ typename S
+ >
+ std::ostream &print_container( const std::pair<F,S> &item, std::ostream &stream )
+ {
+ typedef std::pair<F,S> item_type;
+
+ // the first element of the format sequence is our current format-selector
+ typedef BOOST_DEDUCED_TYPENAME front<format_type>::type format_selector;
+
+ // the format-selector gives us a formatter, based on the type of the thing we need to format
+ typedef BOOST_DEDUCED_TYPENAME format_selector:: template range_format<item_type>::type formatter;
+
+ // the formatter in it's turn tells us what the format for the next depth in the tree will be
+ typedef BOOST_DEDUCED_TYPENAME formatter:: template next_format< format_type>::type next_format_type;
+
+ stream << formatter::opening();
+ print( item.first, stream, next_format_type(), container_policy_type());
+ stream << formatter::delimiter();
+ print( item.second, stream, next_format_type(), container_policy_type());
+ return stream << formatter::closing();
+ }
+
+ //
+ // the print_item methods of this class are called whenever print has deduced that
+ // the item to print is some container-type
+ //
+ struct container_printer
+ {
+ template<
+ typename format_type,
+ typename container_policy_type,
+ typename item_type
+ >
+ static std::ostream &print_item( const item_type &item, std::ostream &stream)
+ {
+ return print_container<format_type, container_policy_type>( item, stream);
+ }
+
+
+ };
+
+ struct pointer_printer
+ {
+ template< typename format_type,
+ typename container_policy_type,
+ typename item_type
+ >
+ static std::ostream &print_item( const item_type *item, std::ostream &stream )
+ {
+ if( NULL == item )
+ {
+ return stream << (char *)"null";
+ }
+ //
+ // DH - changed until we figure out what special things to do with pointer types
+ // return print(*item, stream, format_type(), container_policy_type());
+ return stream << item;
+ }
+ };
+
+ struct item_printer
+ {
+ template< typename format_type,
+ typename container_policy_type,
+ typename item_type
+ >
+ static std::ostream &print_item( const item_type &item, std::ostream &stream )
+ {
+ return stream << item;
+ }
+ };
+
+ /**
+ * This is the main entrance to print.
+ * This function tries to stream it's first argument (the item) to the stream given as a second argument.
+ * If the item has no stream operator, print will try to treat it as some form of container and call itself recursively
+ * on every element of the container.
+ *
+ * Print ask the container policy whether to treat the item as a container. If directed so, it will delegate to the
+ * print_container free function in namespace scope.
+ * Otherwise, it will try to stream the item using the expression "stream << item".
+ *
+ * \param &item the item to stream
+ * \param &stream the stream that receives the item or its elements
+ * \param &format the format to use (string escaping, delimiters etc.)
+ * \param &policy a type that decides when a type needs to be treated as a container.
+ * \return the original stream (second argument)
+ */
+ template< typename format_type,
+ typename container_policy_type ,
+ typename item_type
+ >
+ std::ostream &print( const item_type &item,
+ std::ostream &stream,
+ const format_type &format,
+ const container_policy_type &policy)
+ {
+ typedef typename eval_if<
+ typename container_policy_type:: template print_as_container< item_type>::type,
+ identity<container_printer>,
+ eval_if<
+ typename boost::is_pointer<item_type>::type,
+ identity<pointer_printer>,
+ identity<item_printer>
+ >
+ >::type printer_type;
+
+
+ return printer_type::template print_item< format_type, container_policy_type>( item, stream);
+ }
+
+ template < typename item_type>
+ std::ostream &print( const item_type &item, std::ostream &stream = std::cout)
+ {
+ return print( item, stream, default_format(), default_container_policy());
+ }
+
+ template< typename format_type,
+ typename container_policy_type ,
+ class InputIterator
+ >
+ std::ostream &print( InputIterator first,
+ InputIterator last,
+ std::ostream &stream,
+ const format_type &format,
+ const container_policy_type &policy)
+ {
+ return print( boost::make_iterator_range(first, last), stream, format, policy );
+ }
+
+ template<class InputIterator>
+ std::ostream &print(InputIterator first, InputIterator last, std::ostream &stream = std::cout)
+ {
+ return print( boost::make_iterator_range(first, last), stream );
+ }
+
+
+ //
+ // The container_formatter type to allow "inline" streaming like the following
+ //
+ // std::cout << container_format( my_formatter) % my_container1 << ...
+ //
+
+ template< typename container, typename formatter>
+ struct container_format_class
+ {
+ container_format_class( const container &c)
+ : container_( c)
+ {
+ // nop
+ };
+
+ const container &get_container() const
+ {
+ return container_;
+ }
+ private:
+ const container &container_;
+
+ };
+
+ template< typename formatter>
+ struct unbound_container_format_class
+ {
+ };
+
+ template< typename formatter>
+ unbound_container_format_class< formatter> container_format( const formatter &)
+ {
+ return unbound_container_format_class<formatter>();
+ }
+
+ unbound_container_format_class< default_format> container_format()
+ {
+ return unbound_container_format_class< default_format>();
+ }
+
+ template< typename container, typename formatter>
+ container_format_class< container, formatter> operator%( unbound_container_format_class<formatter> &u, const container &c)
+ {
+ return container_format_class< container, formatter>( c);
+ }
+
+ template< typename container, typename formatter>
+ std::ostream &operator<<( std::ostream &strm, const container_format_class< container, formatter> &cf)
+ {
+ return print( cf.get_container(), strm);
+ }
+
+}
+
+#endif //__EXPLORE_HPP_INCLUDED__
+

Added: sandbox/explore_print/boost/explore/is_assoc_iter.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/boost/explore/is_assoc_iter.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,84 @@
+//
+// is_assoc_iter.hpp - meta function to see if an iterator is for an associative
+// container, which we assume is true if value_type is a pair.
+//
+// Copyright (c) 2007 Danny Havenith
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+
+#ifndef STREAM_IS_ASSOC_ITER_INCLUDED
+#define STREAM_IS_ASSOC_ITER_INCLUDED
+
+#include <map>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+namespace explore
+{
+ namespace detail
+ {
+ struct false_type
+ {
+ char member[100];
+ };
+
+ // crude SFINAE-and-sizeof. uses the fact that a pointer to a value type
+ // is probably different from than that of false_type. Cleaning this up would take
+ // some more LOC.
+ template< typename T>
+ typename T::value_type* has_value_func( const T &);
+
+ false_type has_value_func(...);
+
+ template <typename T>
+ T& make_t();
+
+ template< typename T>
+ struct has_value_type : boost::mpl::bool_<
+ sizeof(false_type)
+ !=
+ sizeof(has_value_func(make_t<T>()))>
+ {};
+
+ //
+ // returns true if the value_t could be the value_type
+ // of a map or multimap of which the iterator matches iterator_t
+ //
+ template< typename value_t, typename iterator_t>
+ struct pair_matches_map : boost::mpl::false_ {};
+
+ template< typename F, typename S, typename iterator_t>
+ struct pair_matches_map< std::pair< F, S>, iterator_t> :
+ boost::mpl::or_<
+ boost::is_same<
+ iterator_t,
+ typename std::map<typename boost::remove_const<F>::type, S >::iterator
+ >,
+ boost::is_same<
+ iterator_t,
+ typename std::multimap<typename boost::remove_const<F>::type, S >::iterator
+ > >
+ {};
+
+ template <typename T>
+ struct value_matches_map :
+ pair_matches_map< typename T::value_type, T> {};
+ }
+
+ // an associative iterator has a value type of pair<>
+ template <typename T>
+ struct is_assoc_iter :
+ boost::mpl::eval_if<
+ detail::has_value_type<T>,
+ detail::value_matches_map<T>,
+ boost::mpl::false_
+ > {};
+}
+
+#endif

Added: sandbox/explore_print/libs/explore/project-root.jam
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/project-root.jam 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,61 @@
+#
+# Copyright (c) 2006 João Abecasis
+#
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+#
+
+##
+## IMPORTANT NOTE: This file MUST NOT be copied over a boost installation
+##
+
+path-constant top : . ;
+
+import modules ;
+import path ;
+
+local boost-root = [ modules.peek : BOOST_ROOT ] ;
+local explore-header-include = $(top)/../.. ;
+
+if ! $(boost-root)
+{
+ local boost-search-dirs = [ modules.peek : BOOST_BUILD_PATH ] ;
+
+ for local dir in $(boost-search-dirs)
+ {
+ if [ path.glob $(dir)/../../../ : boost/version.hpp ]
+ {
+ boost-root += $(dir)/../../../ ;
+ }
+ }
+
+ if $(boost-root)
+ {
+ boost-root = [ path.make $(boost-root[1]) ] ;
+ }
+ else
+ {
+ ECHO "Warning: couldn't find BOOST_ROOT in" $(boost-root) ;
+ }
+}
+
+use-project /boost/regex : $(boost-root)/libs/regex/build ;
+use-project /boost/unit_test : $(boost-root)/libs/test/build ;
+
+project explore
+ : requirements
+ <include>$(boost-root)
+ <include>$(explore-header-include)
+ <library>$(boost-root)/libs/test/build//boost_unit_test_framework/<link>static
+ : # build everything in ./bin.v2
+ build-dir bin.v2
+ ;
+
+
+
+
+
+
+
+

Added: sandbox/explore_print/libs/explore/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/Jamfile.v2 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,43 @@
+# Boost.Explore Library
+
+# Copyright Jared McIntyre 2007. Use, modification and
+# distribution is subject to the Boost Software License, Version
+# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+# For more information, see http://www.boost.org
+
+# bring in rules for testing
+import testing ;
+
+project
+ : source-location .
+ : requirements
+ ;
+{
+ test-suite explore_print
+ :
+ [ run simple_types.cpp ]
+ [ run c_array.cpp ]
+ [ run user_defined_container.cpp ]
+
+ [ run std_vector.cpp ]
+ [ run std_deque.cpp ]
+ [ run std_list.cpp ]
+ [ run std_map.cpp ]
+ [ run std_set.cpp ]
+ [ run std_pair.cpp ]
+
+ [ run boost_array.cpp ]
+ [ run boost_tuple.cpp ]
+ [ run boost_variant.cpp ]
+
+ [ run boost_range.cpp ]
+
+ [ run custom_format_simple.cpp ]
+ [ run html_table_output.cpp ]
+ [ run multi_dim_test.cpp ]
+
+ [ run columnated.cpp ]
+ ;
+}

Added: sandbox/explore_print/libs/explore/test/basic_lg_format.hpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/basic_lg_format.hpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,31 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/list.hpp>
+
+#include <boost/explore.hpp>
+
+struct basic_lg_range_format : explore::basic_range_format
+{
+ static char_ *opening() { return "<=";}
+ static char_ *closing() { return "=>";}
+ static char_ delimiter() { return '#';}
+};
+
+struct basic_lg_range_format_selector
+{
+ template< typename T>
+ struct range_format
+ {
+ typedef basic_lg_range_format type;
+ };
+};
+
+struct basic_lg_format : boost::mpl::list< basic_lg_range_format_selector> {};
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/boost_array.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/boost_array.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,86 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/array.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_array_print_test )
+{
+ std::stringstream str_out;
+
+ boost::array<int,0> ai0;
+ explore::print(ai0, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ boost::array<int,1> ai1 = {1};
+ explore::print(ai1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ boost::array<int,3> ai3 = {1, 2, 3};
+ explore::print(ai3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ boost::array<int,3>::iterator itr = ai3.begin() + 2;
+
+ explore::print(ai3.begin(), itr, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(ai3.begin(), itr), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_array_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ boost::array<std::vector<int>,0> av0;
+ explore::print(av0, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,1> av1 = {vi};
+ explore::print(av1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,3> av3 = {vi, vi, vi};
+ explore::print(av3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ boost::array<std::vector<int>,3>::iterator itr = av3.begin() + 2;
+
+ explore::print(av3.begin(), itr, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(av3.begin(), itr), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/boost_range.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/boost_range.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,45 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/range/iterator_range.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( boost_range_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ explore::print(boost::make_iterator_range(vi), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ explore::print(boost::make_iterator_range(vi), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ explore::print(boost::make_iterator_range(vi), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+ explore::print(boost::make_iterator_range(vi.begin()+2, vi.end()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[3]");
+
+ str_out.str("");
+ explore::print(boost::make_iterator_range(vi.rbegin(), vi.rend()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[3, 2, 1]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/boost_tuple.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/boost_tuple.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,28 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/tuple/tuple.hpp>
+#include <boost/tuple/tuple_io.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_tuple_print_test )
+{
+ std::stringstream str_out;
+
+ boost::tuples::tuple<int, double> t(1, 3.14);
+ explore::print(t, str_out);
+
+ // I think things that already have a way to print should not change
+ //BOOST_CHECK_EQUAL(str_out.str(), "[1, 3.14]");
+ BOOST_CHECK_EQUAL(str_out.str(), "(1 3.14)");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/boost_variant.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/boost_variant.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,42 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <boost/variant.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_variant_print_test )
+{
+ std::stringstream str_out;
+
+ boost::variant< int, std::string, std::vector<int> > varVal;
+
+ varVal = 1;
+ explore::print(varVal, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "1");
+
+ str_out.str("");
+
+ varVal = std::string("some string");
+ explore::print(varVal, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "some string");
+
+ str_out.str("");
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+ varVal = vi;
+ explore::print(varVal, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/c_array.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/c_array.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,50 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_c_array_print_test )
+{
+ std::stringstream str_out;
+
+ int arri1[] = {1};
+ explore::print(arri1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ int arri3[] = {1,2,3};
+ explore::print(arri3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ explore::print(arrvi1, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ explore::print(arrvi3, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/columnated.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/columnated.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,35 @@
+// Boost.Explore library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_columnate_print_test )
+{
+ //BOOST_FAIL("Test not implemented");
+}
+
+struct columnated_format
+{
+ columnated_format(std::size_t rows, std::size_t width) : m_rows(rows), m_width(width) {}
+ std::size_t m_rows;
+ std::size_t m_width;
+
+ friend std::ostream& operator<<(std::ostream& ostr, const columnated_format& f)
+ {
+ using namespace explore;
+ ostr << setrows(f.m_rows) << setitemwidth(f.m_width)
+ << separator("") << start("") << explore::end("");
+ return ostr;
+ }
+};
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/custom_format_simple.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/custom_format_simple.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,86 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+#include "basic_lg_format.hpp"
+
+BOOST_AUTO_TEST_CASE( basic_vector_custom_format_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1=>");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+
+ str_out.str("");
+
+ explore::print(vi.begin(), ++(++vi.begin()), str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(vi.begin(), ++(++vi.begin())), str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2=>");
+
+ str_out.str("");
+
+ explore::print(vi, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=1#2#3=>");
+}
+
+BOOST_AUTO_TEST_CASE( basic_map_custom_format_print_test )
+{
+ std::stringstream str_out;
+
+ std::map<int,std::string> mis;
+ explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<==>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(1, "first"));
+ explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>=>");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(2, "second"));
+ mis.insert(std::make_pair(3, "third"));
+ explore::print(mis, str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>#<=3#third=>=>");
+
+ str_out.str("");
+
+ explore::print(mis.begin(), ++(++mis.begin()), str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(mis.begin(), ++(++mis.begin())), str_out, basic_lg_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(), "<=<=1#first=>#<=2#second=>=>");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/html_table_output.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/html_table_output.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,45 @@
+// Boost.Explore library
+
+// Copyright Danny Havenith 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+#include <boost/explore/html_table_format.hpp>
+
+BOOST_AUTO_TEST_CASE( vector_in_c_array_html_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<int> arrvi1[] = {vi};
+ explore::print(arrvi1, str_out, explore::html_table_format(), explore::default_container_policy());
+
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "<table>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "</table>\n");
+
+ str_out.str("");
+
+ std::vector<int> arrvi3[] = {vi,vi,vi};
+ explore::print(arrvi3, str_out, explore::html_table_format(), explore::default_container_policy());
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "<table>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "<tr><td>1</td><td>2</td><td>3</td></tr>\n"
+ "</table>\n");
+}

Added: sandbox/explore_print/libs/explore/test/is_assoc_iter.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/is_assoc_iter.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,38 @@
+// Boost.Print library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <list>
+#include <boost/explore.hpp>
+#include <boost/explore/is_assoc_iter.hpp>
+
+BOOST_AUTO_TEST_CASE( is_assoc_iter_test )
+{
+ bool mapHasAssocIter = explore::is_assoc_iter<std::map<int, double>::iterator>::type();
+ BOOST_CHECK(mapHasAssocIter);
+
+ bool multimapHasAssocIter = explore::is_assoc_iter<std::multimap<std::string, bool>::iterator>::type();
+ BOOST_CHECK(multimapHasAssocIter);
+
+ bool vectorHasAssocIter = explore::is_assoc_iter<std::vector<double>::iterator>::type();
+ BOOST_CHECK(!vectorHasAssocIter);
+
+ bool pointerHasAssocIter = explore::is_assoc_iter<int*>::type();
+ BOOST_CHECK(!pointerHasAssocIter);
+
+ bool pairHasAssocIter = explore::is_assoc_iter<std::pair<int, double> >::type();
+ BOOST_CHECK(!pairHasAssocIter);
+
+ bool listOfPairHasAssocIter = explore::is_assoc_iter<std::list<std::pair<int, double> >::iterator >::type();
+ BOOST_CHECK(!listOfPairHasAssocIter);
+}

Added: sandbox/explore_print/libs/explore/test/multi_dim_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/multi_dim_test.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,73 @@
+// Boost.Explore library
+
+// Copyright Jeffrey Faust 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( two_dimension_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ std::vector<std::vector<int> > vvi;
+
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+
+ explore::print(vvi, str_out/*, ??? */);
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|");
+}
+
+BOOST_AUTO_TEST_CASE( three_dimension_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ std::vector<std::vector<int> > vvi;
+ std::vector<std::vector<std::vector<int> > > vvvi;
+
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+
+ vvvi.push_back(vvi);
+ vvvi.push_back(vvi);
+ vvvi.push_back(vvi);
+
+ explore::print(vvvi, str_out/*, ??? */);
+ BOOST_CHECK_EQUAL(str_out.str(),
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "\n"
+ "|1 2 3|\n"
+ "|1 2 3|\n"
+ "|1 2 3|"
+ );
+}

Added: sandbox/explore_print/libs/explore/test/simple_types.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/simple_types.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,123 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <boost/lexical_cast.hpp>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( int_print_test )
+{
+ std::stringstream str_out;
+ int i = 123;
+
+ explore::print(i, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "123");
+
+ str_out.str("");
+
+ int* pi = NULL;
+ explore::print(pi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "null");
+
+ str_out.str("");
+
+ //pi = &i;
+ //explore::print(pi, str_out);
+ // technically, we should force this to be true, though
+ // it is highly unlikely to be false. Otherwise this test is only
+ // telling you whether the following is even valid.
+ //BOOST_CHECK(0 != boost::lexical_cast<std::string>((long)pi).compare("123"));
+
+ // this is not a useful test. pointers should print out as pointers.
+ //BOOST_CHECK_EQUAL(str_out.str(), "123");
+}
+
+BOOST_AUTO_TEST_CASE( float_print_test )
+{
+ std::stringstream str_out;
+ float f = 1.234f;
+
+ explore::print(f, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "1.234");
+
+ // are these needed?
+ //BOOST_CHECK_MESSAGE(false, "Test min precision");
+ //BOOST_CHECK_MESSAGE(false, "Test max precision");
+}
+
+BOOST_AUTO_TEST_CASE( double_print_test )
+{
+ std::stringstream str_out;
+ double d = 1.2341234f;
+
+ str_out << std::setprecision(7);
+ explore::print(d, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "1.234123");
+
+ // are these needed?
+ //BOOST_CHECK_MESSAGE(false, "Test min precision");
+ //BOOST_CHECK_MESSAGE(false, "Test max precision");
+}
+
+BOOST_AUTO_TEST_CASE( bool_print_test )
+{
+ std::stringstream str_out;
+ bool b = true;
+
+ str_out << std::boolalpha;
+ explore::print(b, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "true");
+
+ str_out.str("");
+ b = false;
+
+ explore::print(b, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "false");
+}
+
+BOOST_AUTO_TEST_CASE( char_print_test )
+{
+ std::stringstream str_out;
+ char c = 'c';
+
+ explore::print(c, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "c");
+
+ str_out.str("");
+
+ char* pc = NULL;
+ explore::print(pc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "null");
+
+ str_out.str("");
+
+ pc = "c";
+ explore::print(pc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "c");
+
+ str_out.str("");
+
+ pc = "cat";
+ explore::print(pc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "cat");
+}
+
+BOOST_AUTO_TEST_CASE( string_print_test )
+{
+ std::stringstream str_out;
+ std::string s = "some string";
+
+ explore::print(s, str_out);
+
+ BOOST_CHECK_EQUAL(str_out.str(), "some string");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/std_deque.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_deque.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,84 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <deque>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_deque_print_test )
+{
+ std::stringstream str_out;
+
+ std::deque<int> di;
+ explore::print(di, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ di.push_back(1);
+ explore::print(di, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ di.push_back(2);
+ di.push_back(3);
+ explore::print(di, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ explore::print(di.begin(), ++(++di.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(di.begin(), ++(++di.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( deque_in_deque_print_test )
+{
+ std::stringstream str_out;
+
+ std::deque<int> di;
+ di.push_back(1);
+ di.push_back(2);
+ di.push_back(3);
+
+ std::deque<std::deque<int> > ddi;
+ explore::print(ddi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ ddi.push_back(di);
+ explore::print(ddi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ ddi.push_back(di);
+ ddi.push_back(di);
+ explore::print(ddi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(ddi.begin(), ++(++ddi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(ddi.begin(), ++(++ddi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/std_list.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_list.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,85 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <list>
+#include <complex>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_list_print_test )
+{
+ std::stringstream str_out;
+
+ std::list<std::complex<double> > lc;
+ explore::print(lc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ lc.push_back(std::complex<double>(0,1));
+ explore::print(lc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1)]");
+
+ str_out.str("");
+
+ lc.push_back(std::complex<double>(2,3));
+ lc.push_back(std::complex<double>(4,5));
+ explore::print(lc, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3), (4,5)]");
+
+ str_out.str("");
+
+ explore::print(lc.begin(), ++(++lc.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3)]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(lc.begin(), ++(++lc.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[(0,1), (2,3)]");
+}
+
+BOOST_AUTO_TEST_CASE( list_in_list_print_test )
+{
+ std::stringstream str_out;
+
+ std::list<int> li;
+ li.push_back(1);
+ li.push_back(2);
+ li.push_back(3);
+
+ std::list<std::list<int> > lli;
+ explore::print(lli, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ lli.push_back(li);
+ explore::print(lli, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ lli.push_back(li);
+ lli.push_back(li);
+ explore::print(lli, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(lli.begin(), ++(++lli.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(lli.begin(), ++(++lli.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/std_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_map.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,124 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <map>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_map_print_test )
+{
+ std::stringstream str_out;
+
+ std::map<int,std::string> mis;
+ explore::print(mis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(1, "first"));
+ explore::print(mis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+
+ str_out.str("");
+
+ mis.insert(std::make_pair(2, "second"));
+ mis.insert(std::make_pair(3, "third"));
+ explore::print(mis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second, 3:third]");
+
+ str_out.str("");
+
+ explore::print(mis.begin(), ++(++mis.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second]");
+
+ str_out.str("");
+
+ explore::print(explore::make_iterator_range(mis.begin(), ++(++mis.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 2:second]");
+}
+
+BOOST_AUTO_TEST_CASE( basic_multimap_print_test )
+{
+ std::stringstream str_out;
+
+ std::multimap<int,std::string> mmis;
+ explore::print(mmis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(1, "first"));
+ explore::print(mmis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(1, "single"));
+ explore::print(mmis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+
+ str_out.str("");
+
+ mmis.insert(std::make_pair(2, "second"));
+ mmis.insert(std::make_pair(3, "third"));
+ mmis.insert(std::make_pair(3, "triple"));
+ explore::print(mmis, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single, 2:second, 3:third, 3:triple]");
+
+ str_out.str("");
+
+ explore::print(mmis.begin(), ++(++mmis.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+
+ str_out.str("");
+
+ explore::print(explore::make_iterator_range(mmis.begin(), ++(++mmis.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:first, 1:single]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_map_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::map<int,std::vector<int> > mivi;
+ explore::print(mivi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ mivi.insert(std::make_pair(1, vi));
+ explore::print(mivi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3]]");
+
+ str_out.str("");
+
+ mivi.insert(std::make_pair(2, vi));
+ mivi.insert(std::make_pair(3, vi));
+ explore::print(mivi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3], 3:[1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(mivi.begin(), ++(++mivi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(explore::make_iterator_range(mivi.begin(), ++(++mivi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1:[1, 2, 3], 2:[1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/std_pair.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_pair.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,60 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_pair_print_test )
+{
+ std::stringstream str_out;
+
+ std::pair<int,int> pi = std::make_pair(1,2);
+ explore::print(pi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+// This is an interesting case as it shows a stylistic difference between a vector of
+// pairs and a map. It also shows that if we allow this syntax, simple type and depth
+// formatters will need to be enhanced to meet this requirement.
+BOOST_AUTO_TEST_CASE( pair_in_vector_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<std::pair<int,int> > vpi;
+ explore::print(vpi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ std::pair<int,int> pi = std::make_pair(1,2);
+
+ vpi.push_back(pi);
+ explore::print(vpi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2]]");
+
+ str_out.str("");
+
+ vpi.push_back(pi);
+ vpi.push_back(pi);
+ explore::print(vpi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2], [1, 2]]");
+
+ str_out.str("");
+
+ explore::print(vpi.begin(), ++(++vpi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(vpi.begin(), ++(++vpi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2], [1, 2]]");
+}

Added: sandbox/explore_print/libs/explore/test/std_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_set.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,123 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <string>
+#include <sstream>
+#include <set>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( basic_set_print_test )
+{
+ std::stringstream str_out;
+
+ std::set<int> si;
+ explore::print(si, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ si.insert(1);
+ explore::print(si, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ si.insert(2);
+ si.insert(3);
+ explore::print(si, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ explore::print(si.begin(), ++(++si.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(si.begin(), ++(++si.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+}
+
+BOOST_AUTO_TEST_CASE( basic_multiset_print_test )
+{
+ std::stringstream str_out;
+
+ std::multiset<int> msi;
+ explore::print(msi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ msi.insert(1);
+ explore::print(msi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ msi.insert(1);
+ explore::print(msi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+
+ str_out.str("");
+
+ msi.insert(2);
+ msi.insert(3);
+ msi.insert(3);
+ explore::print(msi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1, 2, 3, 3]");
+
+ str_out.str("");
+
+ explore::print(msi.begin(), ++(++msi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(msi.begin(), ++(++msi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 1]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_set_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::multiset<std::vector<int> > svi;
+ explore::print(svi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ svi.insert(vi);
+ explore::print(svi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ svi.insert(vi);
+ svi.insert(vi);
+ explore::print(svi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(svi.begin(), ++(++svi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(svi.begin(), ++(++svi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/std_vector.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/std_vector.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,102 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+BOOST_AUTO_TEST_CASE( vector_custom_format_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ explore::print(vi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vi.push_back(1);
+ explore::print(vi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1]");
+
+ str_out.str("");
+
+ vi.push_back(2);
+ vi.push_back(3);
+ explore::print(vi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+
+ str_out.str("");
+
+ explore::print(vi.begin(), ++(++vi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(vi.begin(), ++(++vi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2]");
+
+ str_out.str("");
+
+ explore::print(vi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+
+BOOST_AUTO_TEST_CASE( vector_in_vector_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<int> vi;
+ vi.push_back(1);
+ vi.push_back(2);
+ vi.push_back(3);
+
+ std::vector<std::vector<int> > vvi;
+ explore::print(vvi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[]");
+
+ str_out.str("");
+
+ vvi.push_back(vi);
+ explore::print(vvi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3]]");
+
+ str_out.str("");
+
+ vvi.push_back(vi);
+ vvi.push_back(vi);
+ explore::print(vvi, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(vvi.begin(), ++(++vvi.begin()), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+
+ str_out.str("");
+
+ explore::print(boost::make_iterator_range(vvi.begin(), ++(++vvi.begin())), str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3]]");
+}
+
+// This test shows that you can use a string to cause the same outputs
+// as other print statements.
+BOOST_AUTO_TEST_CASE( vector_with_ugly_string_case_print_test )
+{
+ std::stringstream str_out;
+
+ std::vector<std::string> vs;
+ vs.push_back("[1, 2, 3], [1, 2, 3], [1, 2, 3]");
+ explore::print(vs, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]");
+}
\ No newline at end of file

Added: sandbox/explore_print/libs/explore/test/user_defined_container.cpp
==============================================================================
--- (empty file)
+++ sandbox/explore_print/libs/explore/test/user_defined_container.cpp 2008-03-22 16:05:24 EDT (Sat, 22 Mar 2008)
@@ -0,0 +1,48 @@
+// Boost.Explore library
+
+// Copyright Jared McIntyre 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// For more information, see http://www.boost.org
+
+#define BOOST_TEST_MODULE PrintLib
+#include <boost/test/unit_test.hpp>
+#include <sstream>
+#include <vector>
+#include <boost/explore.hpp>
+
+class user_vector
+{
+public:
+ user_vector()
+ {
+ m_vec.push_back(1);
+ m_vec.push_back(2);
+ m_vec.push_back(3);
+ }
+
+ std::vector<int>::const_iterator start() const
+ {
+ return m_vec.begin();
+ }
+
+ std::vector<int>::const_iterator finish() const
+ {
+ return m_vec.end();
+ }
+
+private:
+ std::vector<int> m_vec;
+};
+
+BOOST_AUTO_TEST_CASE( user_defined_print_test )
+{
+ std::stringstream str_out;
+
+ user_vector v;
+ explore::print(v, str_out);
+ BOOST_CHECK_EQUAL(str_out.str(), "[1, 2, 3]");
+}
+


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