$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: chochlik_at_[hidden]
Date: 2008-04-25 05:19:32
Author: matus.chochlik
Date: 2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
New Revision: 44761
URL: http://svn.boost.org/trac/boost/changeset/44761
Log:
When querying the base_name of array types the size of the array is printed too.
Added:
   sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp   (contents, props changed)
   sandbox/mirror/boost/mirror/detail/static_log10.hpp   (contents, props changed)
   sandbox/mirror/boost/mirror/detail/static_pow10.hpp   (contents, props changed)
Text files modified: 
   sandbox/mirror/boost/char_type_switch/string.hpp       |    12 ++++++++++++                            
   sandbox/mirror/boost/mirror/detail/array_type_name.hpp |    17 +++++++++++++++--                       
   sandbox/mirror/libs/doc/xml/mirror/_library.xml        |     9 +++++++++                               
   sandbox/mirror/libs/examples/special/std_pair.cpp      |     2 +-                                      
   4 files changed, 37 insertions(+), 3 deletions(-)
Modified: sandbox/mirror/boost/char_type_switch/string.hpp
==============================================================================
--- sandbox/mirror/boost/char_type_switch/string.hpp	(original)
+++ sandbox/mirror/boost/char_type_switch/string.hpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -57,6 +57,18 @@
 
 /** string compare
  */
+
+inline size_t bstrlen(const bchar* str)
+{
+#ifdef BOOST_USE_WIDE_CHARS
+	return ::std::wcslen(str);
+#else
+	return ::std::strlen(str);
+#endif
+}
+
+
+	
 inline int bstrcmp(const bchar* a, const bchar* b)
 {
 #ifdef BOOST_USE_WIDE_CHARS
Modified: sandbox/mirror/boost/mirror/detail/array_type_name.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/array_type_name.hpp	(original)
+++ sandbox/mirror/boost/mirror/detail/array_type_name.hpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -12,6 +12,7 @@
 
 #include <assert.h>
 #include <boost/mirror/detail/nontrivial_type_name.hpp>
+#include <boost/mirror/detail/static_int_to_str.hpp>
 
 namespace boost {
 namespace mirror {
@@ -21,10 +22,17 @@
 template <class meta_type, size_t array_size>
 struct static_array_type_name_base
 {
+protected:
+	typedef detail::static_int_to_str<array_size>
+		size_as_string;
+public:
         BOOST_MIRROR_CONST_MEMBER_ATTRIB(
                 size_t,
                 base_name_length,
-		(meta_type::base_name_length + 3)
+		(
+			meta_type::base_name_length + 3 +
+			size_as_string::length::value
+		)
         )
 
 protected:
@@ -36,9 +44,14 @@
                 bstrcpy(cur_pos, meta_type::base_name());
                 cur_pos += meta_type::base_name_length;
                 //
-		// append the " [N]" 
+		// append the " [" 
                 *(cur_pos++) = BOOST_STR_LIT(' ');
                 *(cur_pos++) = BOOST_STR_LIT('[');
+		// append the index$
+		assert((cur_pos + size_as_string::length::value) < (the_base_name + base_name_length));
+		size_as_string::convert(cur_pos, size_as_string::length::value + 1);
+		cur_pos += size_as_string::length::value;
+		// append the "]" 
                 *(cur_pos++) = BOOST_STR_LIT(']');
                 //
                 // finalize the string
Added: sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/static_int_to_str.hpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -0,0 +1,67 @@
+/**
+ * \file boost/mirror/detail/static_int_to_str.hpp
+ * 
+ * Templates that allow to query the required length of a string
+ * that should hold a given decadic compile time integral value
+ * and conversion of compile-time integers to strings.
+ *
+ *  Copyright 2008 Matus Chochlik. 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_MIRROR_META_DETAIL_STATIC_INT_TO_STR_HPP
+#define BOOST_MIRROR_META_DETAIL_STATIC_INT_TO_STR_HPP
+
+#include <assert.h>
+#include <boost/mirror/detail/static_log10.hpp>
+#include <boost/mirror/detail/static_pow10.hpp>
+#include <boost/char_type_switch/string.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <int I>
+struct static_int_to_str 
+{
+	// the length of the string needed to hold the given integer
+	typedef typename mpl::next<
+		typename static_log10<I>::type
+	>::type length;
+	//
+	//
+	template <int J>
+	static inline bchar get_digit(mpl::int_<J> pos)
+	{
+		static const bchar zero = BOOST_STR_LIT('0');
+		typedef typename static_pow10<
+			length::value - mpl::int_<J>::value
+		>::type K;
+		return zero + (I / K::value) % 10;
+	}
+	//
+	static inline void do_copy_to(bchar* _str, mpl::int_<0>){	}
+	//
+	template <int J>
+	static inline void do_copy_to(bchar* _str, mpl::int_<J> pos)
+	{
+		_str[J-1] = get_digit(pos);
+		do_copy_to(_str, mpl::int_<J - 1>());
+	}
+	//
+	static bchar* convert(bchar* _str, size_t _max_len)
+	{
+		assert(_max_len > length::value);
+		do_copy_to(_str, length());
+		_str[length::value] = BOOST_STR_LIT('\0');
+		return _str;
+	}
+};
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/static_log10.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/static_log10.hpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -0,0 +1,60 @@
+/**
+ * \file boost/mirror/detail/static_log10.hpp
+ * Template that allows to calculate the "integral decadic
+ * logarithm" from the given compile-time integral constant.
+ *
+ *  Copyright 2008 Matus Chochlik. 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_MIRROR_META_DETAIL_STATIC_LOG10_HPP
+#define BOOST_MIRROR_META_DETAIL_STATIC_LOG10_HPP
+
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/find_if.hpp>
+#include <boost/mpl/comparison.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+typedef mpl::vector<
+	mpl::pair<mpl::int_<1000000000>, mpl::int_<9> >,
+	mpl::pair<mpl::int_< 100000000>, mpl::int_<8> >,
+	mpl::pair<mpl::int_<  10000000>, mpl::int_<7> >,
+	mpl::pair<mpl::int_<   1000000>, mpl::int_<6> >,
+	mpl::pair<mpl::int_<    100000>, mpl::int_<5> >,
+	mpl::pair<mpl::int_<     10000>, mpl::int_<4> >,
+	mpl::pair<mpl::int_<      1000>, mpl::int_<3> >, 
+	mpl::pair<mpl::int_<       100>, mpl::int_<2> >, 
+	mpl::pair<mpl::int_<        10>, mpl::int_<1> >, 
+	mpl::pair<mpl::int_<         1>, mpl::int_<0> >
+> static_log10_boundaries;
+
+
+template <int I>
+struct static_log10
+{
+	typedef typename mpl::find_if<
+		static_log10_boundaries, 
+		mpl::less_equal<
+			mpl::first<mpl::_1>,
+			mpl::int_<I>
+		>
+	>::type position;
+
+
+	typedef typename mpl::second<
+			typename mpl::deref<
+				position
+		>::type 
+	>::type type;
+};
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Added: sandbox/mirror/boost/mirror/detail/static_pow10.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/detail/static_pow10.hpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -0,0 +1,44 @@
+/**
+ * \file boost/mirror/detail/static_pow10.hpp
+ * Template that allows to calculate the "integral power of 10"
+ * from the given compile-time integral constant.
+ *
+ *  Copyright 2008 Matus Chochlik. 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_MIRROR_META_DETAIL_STATIC_POW10_HPP
+#define BOOST_MIRROR_META_DETAIL_STATIC_POW10_HPP
+
+#include <boost/mirror/detail/static_log10.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <int I>
+struct static_pow10
+{
+	typedef typename mpl::find_if<
+		static_log10_boundaries, 
+		mpl::equal_to<
+			mpl::second<mpl::_1>,
+			mpl::int_<I>
+		>
+	>::type position;
+
+	typedef typename mpl::first<
+			typename mpl::deref<
+				position
+		>::type 
+	>::type type;
+
+};
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+
Modified: sandbox/mirror/libs/doc/xml/mirror/_library.xml
==============================================================================
--- sandbox/mirror/libs/doc/xml/mirror/_library.xml	(original)
+++ sandbox/mirror/libs/doc/xml/mirror/_library.xml	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -51,5 +51,14 @@
                         - Added example on cooperation with Boost.Serialization
                           (will not compile with gcc)
                 </revision>
+		<revision id="20080424" major="0" minor="1" micro="8" author="m_ch">
+			- Added support for base name querying for non trivial types
+			- Added meta_type for std::pair
+			- NOTE: tested only with MSVC++ 2008 EE
+		</revision>
+		<revision id="20080425_1116CET" major="0" minor="1" micro="9" author="m_ch">
+			- Added the index to the base name of static arrays
+			- NOTE: tested only with MSVC++ 2008 EE
+		</revision>
         </revisions>
 </library>
Modified: sandbox/mirror/libs/examples/special/std_pair.cpp
==============================================================================
--- sandbox/mirror/libs/examples/special/std_pair.cpp	(original)
+++ sandbox/mirror/libs/examples/special/std_pair.cpp	2008-04-25 05:19:31 EDT (Fri, 25 Apr 2008)
@@ -28,7 +28,7 @@
         using namespace ::boost::mirror;
         //
         //
-	typedef ::std::pair<const int*, double [3]> T1;
+	typedef ::std::pair<const int*, double [321]> T1;
         typedef ::std::pair<float, const long&> T2;
         typedef ::std::pair<T1 const volatile, T2 volatile const> T3;
         typedef ::std::pair<T2, T1 volatile> T4;