Include bind in ndnboost.
diff --git a/ndnboost/test/utils/runtime/env/environment.hpp b/ndnboost/test/utils/runtime/env/environment.hpp
new file mode 100644
index 0000000..b45f10f
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/environment.hpp
@@ -0,0 +1,172 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : defines and implements inline model of program environment
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
+#define BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+#include <ndnboost/test/utils/runtime/interpret_argument_value.hpp>
+
+#include <ndnboost/test/utils/runtime/env/fwd.hpp>
+#include <ndnboost/test/utils/runtime/env/modifier.hpp>
+#include <ndnboost/test/utils/runtime/env/variable.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/callback.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+// ************************************************************************** //
+// ************** runtime::environment implementation ************** //
+// ************************************************************************** //
+
+namespace environment {
+
+namespace rt_env_detail {
+
+template<typename T, typename Modifiers>
+variable_data&
+init_new_var( cstring var_name, Modifiers m = nfp::no_params )
+{
+ rt_env_detail::variable_data& new_vd = new_var_record( var_name );
+
+ cstring str_value = sys_read_var( new_vd.m_var_name );
+
+ if( !str_value.is_empty() ) {
+ try {
+ ndnboost::optional<T> value;
+
+ if( m.has( interpreter ) )
+ m[interpreter]( str_value, value );
+ else
+ interpret_argument_value( str_value, value, 0 );
+
+ if( !!value ) {
+ new_vd.m_value.reset( new typed_argument<T>( new_vd ) );
+
+ arg_value<T>( *new_vd.m_value ) = *value;
+ }
+ }
+ catch( ... ) { // !! could we do that
+ // !! should we report an error?
+ }
+ }
+
+ if( !new_vd.m_value && m.has( default_value ) ) {
+ new_vd.m_value.reset( new typed_argument<T>( new_vd ) );
+
+ nfp::optionally_assign( arg_value<T>( *new_vd.m_value ), m[default_value] );
+ }
+
+ nfp::optionally_assign( new_vd.m_global_id, m, global_id );
+
+ return new_vd;
+}
+
+//____________________________________________________________________________//
+
+} // namespace rt_env_detail
+
+} // namespace environment
+
+// ************************************************************************** //
+// ************** runtime::environment ************** //
+// ************************************************************************** //
+
+namespace environment {
+
+ // variable access
+ variable_base
+ var( cstring var_name );
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline variable<T>
+ var( cstring var_name )
+ {
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ return environment::variable<T>( !vd ? rt_env_detail::init_new_var<T>( var_name, nfp::no_params ) : *vd );
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T, typename Modifiers>
+ inline variable<T>
+ var( cstring var_name, Modifiers const& m )
+ {
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ return environment::variable<T>( !vd ? rt_env_detail::init_new_var<T>( var_name, m ) : *vd );
+ }
+
+ //________________________________________________________________________//
+
+ // direct variable value access
+ inline cstring
+ get( cstring var_name )
+ {
+ return environment::var<cstring>( var_name ).value();
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline T const&
+ get( cstring var_name )
+ {
+ return environment::var<T>( var_name ).value();
+ }
+
+ //________________________________________________________________________//
+
+ template<typename T>
+ inline void
+ get( cstring var_name, ndnboost::optional<T>& res )
+ {
+ variable<T> const& v = environment::var<T>( var_name );
+ v.value( res );
+ }
+
+ //________________________________________________________________________//
+
+} // namespace environment
+
+namespace env = environment;
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#ifndef BOOST_RT_PARAM_OFFLINE
+
+#define BOOST_RT_PARAM_INLINE inline
+#include <ndnboost/test/utils/runtime/env/environment.ipp>
+
+#endif
+
+#endif // BOOST_RT_ENV_ENVIRONMENT_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/environment.ipp b/ndnboost/test/utils/runtime/env/environment.ipp
new file mode 100644
index 0000000..f2929de
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/environment.ipp
@@ -0,0 +1,125 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 57992 $
+//
+// Description : implements model of program environment
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
+#define BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/validation.hpp>
+
+#include <ndnboost/test/utils/runtime/env/variable.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/basic_cstring/compare.hpp>
+#include <ndnboost/test/utils/basic_cstring/io.hpp>
+
+// STL
+#include <map>
+#include <list>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** runtime::environment ************** //
+// ************************************************************************** //
+
+namespace rt_env_detail {
+
+typedef std::map<cstring,rt_env_detail::variable_data> registry;
+typedef std::list<dstring> keys;
+
+BOOST_RT_PARAM_INLINE registry& s_registry() { static registry instance; return instance; }
+BOOST_RT_PARAM_INLINE keys& s_keys() { static keys instance; return instance; }
+
+BOOST_RT_PARAM_INLINE variable_data&
+new_var_record( cstring var_name )
+{
+ // save the name in list of keys
+ s_keys().push_back( dstring() );
+ dstring& key = s_keys().back();
+ assign_op( key, var_name, 0 );
+
+ // create and return new record
+ variable_data& new_var_data = s_registry()[key];
+
+ new_var_data.m_var_name = key;
+
+ return new_var_data;
+}
+
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE variable_data*
+find_var_record( cstring var_name )
+{
+ registry::iterator it = s_registry().find( var_name );
+
+ return it == s_registry().end() ? 0 : &(it->second);
+}
+
+//____________________________________________________________________________//
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4996) // getenv
+#endif
+
+BOOST_RT_PARAM_INLINE cstring
+sys_read_var( cstring var_name )
+{
+ using namespace std;
+ return BOOST_RT_PARAM_GETENV( var_name.begin() );
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+//____________________________________________________________________________//
+
+BOOST_RT_PARAM_INLINE void
+sys_write_var( cstring var_name, format_stream& var_value )
+{
+ BOOST_RT_PARAM_PUTENV( var_name, cstring( var_value.str() ) );
+}
+
+//____________________________________________________________________________//
+
+} // namespace rt_env_detail
+
+BOOST_RT_PARAM_INLINE variable_base
+var( cstring var_name )
+{
+ rt_env_detail::variable_data* vd = rt_env_detail::find_var_record( var_name );
+
+ BOOST_RT_PARAM_VALIDATE_LOGIC( !!vd,
+ BOOST_RT_PARAM_LITERAL( "First access to the environment variable " )
+ << var_name << BOOST_RT_PARAM_LITERAL( " should be typed" ) );
+
+ return variable_base( *vd );
+}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_ENVIRONMENT_IPP_062904GER
diff --git a/ndnboost/test/utils/runtime/env/fwd.hpp b/ndnboost/test/utils/runtime/env/fwd.hpp
new file mode 100644
index 0000000..b869605
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/fwd.hpp
@@ -0,0 +1,54 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 54633 $
+//
+// Description : environment subsystem forward declarations
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_FWD_HPP_062604GER
+#define BOOST_RT_ENV_FWD_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+class variable_base;
+variable_base var( cstring var_name );
+
+namespace rt_env_detail {
+
+struct variable_data;
+
+variable_data& new_var_record( cstring var_name );
+variable_data* find_var_record( cstring var_name );
+
+cstring sys_read_var( cstring var_name );
+void sys_write_var( cstring var_name, format_stream& var_value );
+
+}
+
+template <typename T> class variable;
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_FWD_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/modifier.hpp b/ndnboost/test/utils/runtime/env/modifier.hpp
new file mode 100644
index 0000000..a760368
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/modifier.hpp
@@ -0,0 +1,47 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// Use, modification, and distribution are 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 49312 $
+//
+// Description : defines variable modifiers
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_MODIFIER_HPP_062604GER
+#define BOOST_RT_ENV_MODIFIER_HPP_062604GER
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+
+// Boost.Test
+#include <ndnboost/test/utils/named_params.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** environment variable modifiers ************** //
+// ************************************************************************** //
+
+namespace {
+
+nfp::typed_keyword<cstring,struct global_id_t> global_id;
+nfp::keyword<struct default_value_t> default_value;
+nfp::keyword<struct interpreter_t> interpreter;
+
+} // local namespace
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_MODIFIER_HPP_062604GER
diff --git a/ndnboost/test/utils/runtime/env/variable.hpp b/ndnboost/test/utils/runtime/env/variable.hpp
new file mode 100644
index 0000000..17a4f39
--- /dev/null
+++ b/ndnboost/test/utils/runtime/env/variable.hpp
@@ -0,0 +1,223 @@
+// (C) Copyright Gennadiy Rozental 2005-2008.
+// 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)
+
+// See http://www.boost.org/libs/test for the library home page.
+//
+// File : $RCSfile$
+//
+// Version : $Revision: 81913 $
+//
+// Description : defines model of program environment variable
+// ***************************************************************************
+
+#ifndef BOOST_RT_ENV_VARIABLE_HPP_062604GER
+#define BOOST_RT_ENV_VARIABLE_HPP_062604GER
+
+#ifdef UNDER_CE
+#error Windows CE does not support environment variables.
+#endif
+
+// Boost.Runtime.Parameter
+#include <ndnboost/test/utils/runtime/config.hpp>
+#include <ndnboost/test/utils/runtime/fwd.hpp>
+#include <ndnboost/test/utils/runtime/parameter.hpp>
+#include <ndnboost/test/utils/runtime/argument.hpp>
+
+#include <ndnboost/test/utils/runtime/env/fwd.hpp>
+
+// Boost
+#include <ndnboost/optional.hpp>
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+// ************************************************************************** //
+// ************** runtime::environment::variable_data ************** //
+// ************************************************************************** //
+
+namespace rt_env_detail {
+
+struct variable_data : public runtime::parameter {
+ cstring m_var_name;
+ dstring m_global_id;
+ argument_ptr m_value;
+};
+
+} // namespace rt_env_detail
+
+// ************************************************************************** //
+// ************** runtime::environment::variable_base ************** //
+// ************************************************************************** //
+
+class variable_base {
+public:
+ explicit variable_base( rt_env_detail::variable_data& data ) : m_data( &data ) {}
+
+ // arguments access
+ template<typename T>
+ T const& value() const
+ {
+ return arg_value<T>( *m_data->m_value );
+ }
+
+ template<typename T>
+ void value( ndnboost::optional<T>& res ) const
+ {
+ if( has_value() )
+ res = arg_value<T>( *m_data->m_value );
+ else
+ res.reset();
+ }
+
+ bool has_value() const { return m_data->m_value!=0; }
+ cstring name() const { return m_data->m_var_name; }
+
+protected:
+ // Data members
+ rt_env_detail::variable_data* m_data;
+} ;
+
+// ************************************************************************** //
+// ************** runtime::environment::variable ************** //
+// ************************************************************************** //
+
+template<typename T = cstring>
+class variable : public variable_base {
+public:
+ // Constructors
+ explicit variable( cstring var_name );
+
+ template<typename Modifiers>
+ explicit variable( cstring var_name, Modifiers const& m );
+
+ explicit variable( rt_env_detail::variable_data& data )
+ : variable_base( data ) {}
+
+ // other variable assignment
+ void operator=( variable const& v ) { m_data = v.m_data; }
+
+ // access methods
+ T const& value() const { return variable_base::value<T>(); }
+
+#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) || \
+ BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0593))
+ template<typename T>
+ void value( ndnboost::optional<T>& res ) const { variable_base::value( res ); }
+#else
+ using variable_base::value;
+#endif
+
+ // Value assignment
+ template<typename V>
+ void operator=( V const& v )
+ {
+ if( !has_value() )
+ m_data->m_value.reset( new typed_argument<T>( *m_data ) );
+
+ arg_value<T>( *m_data->m_value ) = v;
+
+ rt_env_detail::sys_write_var( m_data->m_var_name, format_stream().ref() << value() );
+ }
+}; // class variable
+
+//____________________________________________________________________________//
+
+template<typename CharT, typename Tr,typename T>
+inline std::basic_ostream<CharT,Tr>&
+operator<<( std::basic_ostream<CharT,Tr>& os, variable<T> const& v )
+{
+ os << v.name() << '=';
+
+ if( v.has_value() )
+ os << v.value();
+
+ return os;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator==( variable<T> ev, V const& v )
+{
+ return ev.has_value() && ev.value() == v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator==( V const& v, variable<T> ev )
+{
+ return ev.has_value() && ev.value() == v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator!=( variable<T> ev, V const& v )
+{
+ return !ev.has_value() || ev.value() != v;
+}
+
+//____________________________________________________________________________//
+
+template<typename T, typename V>
+inline bool
+operator!=( V const& v, variable<T> ev )
+{
+ return !ev.has_value() || ev.value() != v;
+}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+// ************************************************************************** //
+// ************************************************************************** //
+// Implementation
+
+#include <ndnboost/test/utils/runtime/env/environment.hpp>
+
+// ************************************************************************** //
+// ************** runtime::environment::variable ************** //
+// ************************************************************************** //
+
+namespace ndnboost {
+
+namespace BOOST_RT_PARAM_NAMESPACE {
+
+namespace environment {
+
+template<typename T>
+variable<T>::variable( cstring var_name )
+: variable_base( environment::var<T>( var_name ) )
+{}
+
+//____________________________________________________________________________//
+
+template<typename T>
+template<typename Modifiers>
+variable<T>::variable( cstring var_name, Modifiers const& m )
+: variable_base( environment::var<T>( var_name, m ) )
+{}
+
+//____________________________________________________________________________//
+
+} // namespace environment
+
+} // namespace BOOST_RT_PARAM_NAMESPACE
+
+} // namespace ndnboost
+
+#endif // BOOST_RT_ENV_VARIABLE_HPP_062604GER