return ptr(new DirectoryNode());
}
+prefix_ bool senf::console::DirectoryNode::hasChild(std::string const & name)
+ const
+{
+ ChildMap::const_iterator i (children_.find(name));
+ return i != children_.end();
+}
+
prefix_ senf::console::DirectoryNode &
senf::console::DirectoryNode::getDirectory(std::string const & name)
const
//#include "Node.mpp"
///////////////////////////////hh.p////////////////////////////////////////
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
-
namespace senf {
namespace console {
be saved and/or re-attached at some other place in the
tree. */
+ bool hasChild(std::string const & name) const;
+ ///< \c true, if there is a child with name \a name
+
GenericNode & get(std::string const & name) const;
///< Get child node
/**< \throws UnknownNodeNameException if a child \a name
friend DirectoryNode & root();
};
- BOOST_TYPEOF_REGISTER_TYPE(DirectoryNode);
-
/// Exception: Unknown node name
struct UnknownNodeNameException : public senf::Exception
{ UnknownNodeNameException() : senf::Exception("Unknown node name") {}};
Function const & fn, ...);
#endif
- BOOST_TYPEOF_REGISTER_TYPE(SimpleCommandNode);
-
DirectoryNode & root();
}}
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TYPE(senf::console::DirectoryNode)
+BOOST_TYPEOF_REGISTER_TYPE(senf::console::SimpleCommandNode)
+
+
///////////////////////////////hh.e////////////////////////////////////////
#include "Node.cci"
#include "Node.ct"
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParseParameter inline template implementation */
+
+//#include "ParseParameter.ih"
+
+// Custom includes
+#include "../Utils/TypeInfo.hh"
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::detail::ParameterInfoBase
+
+prefix_ senf::console::detail::ParameterInfoBase::ParameterInfoBase(std::string const & type_)
+ : type (type_), name (), hasDefault (false)
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::detail::ParameterInfo<ParameterType>
+
+template <class ParameterType>
+prefix_ typename senf::console::detail::ParameterInfo<ParameterType>::ptr
+senf::console::detail::ParameterInfo<ParameterType>::create()
+{
+ return ptr(new ParameterInfo());
+}
+
+template <class ParameterType>
+prefix_ senf::console::detail::ParameterInfo<ParameterType>::ParameterInfo()
+ : ParameterInfoBase ( ParameterTraits<ParameterType>::typeDescription() ),
+ defaultValue ()
+{}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::detail::ReturnValueTraits<Type>
+
+template <class Type>
+template <class Fn>
+prefix_ void senf::console::detail::ReturnValueTraits<Type>::callAndWrite(Fn const & fn,
+ std::ostream & os)
+{
+ os << fn() << "\n";
+}
+
+template <class Fn>
+prefix_ void senf::console::detail::ReturnValueTraits<void>::callAndWrite(Fn const & fn,
+ std::ostream & os)
+{
+ fn();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::detail::ParameterTraits<Type>
+
+template <class Type>
+prefix_ void senf::console::detail::ParameterTraits<Type>::
+parse(ParseCommandInfo::TokensRange const & tokens, Type & out)
+{
+ if (tokens.size() != 1)
+ throw SyntaxErrorException("parameter syntax error");
+ try {
+ out = boost::lexical_cast<Type>(tokens.begin()[0].value());
+ }
+ catch (std::bad_cast & ex) {
+ throw SyntaxErrorException("parameter syntax error");
+ }
+}
+
+template <class Type>
+prefix_ std::string senf::console::detail::ParameterTraits<Type>::typeDescription()
+{
+ return prettyName(typeid(Type));
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParseParameter public header */
+
+#ifndef HH_ParseParameter_
+#define HH_ParseParameter_ 1
+
+// Custom includes
+#include <iostream>
+#include <boost/intrusive_ptr.hpp>
+#include "../Utils/intrusive_refcount.hh"
+#include "Parse.hh"
+#include "Node.hh"
+
+//#include "ParseParameter.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace console {
+namespace detail {
+
+ struct ParameterInfoBase
+ : public intrusive_refcount
+ {
+ typedef boost::intrusive_ptr<ParameterInfoBase> ptr;
+
+ std::string type;
+ std::string name;
+ bool hasDefault;
+
+ ParameterInfoBase(std::string const & type);
+ };
+
+ template <class ParameterType>
+ struct ParameterInfo
+ : public ParameterInfoBase
+ {
+ typedef boost::intrusive_ptr<ParameterInfo> ptr;
+
+ static ptr create();
+ ParameterInfo();
+
+ ParameterType defaultValue;
+ };
+
+ template <class Type>
+ struct ReturnValueTraits
+ {
+ typedef Type type;
+
+ template <class Fn>
+ static void callAndWrite(Fn const & fn, std::ostream & os);
+ };
+
+ template <>
+ struct ReturnValueTraits<void>
+ {
+ typedef void type;
+
+ template <class Fn>
+ static void callAndWrite(Fn const & fn, std::ostream & os);
+ };
+
+ template <class Type>
+ struct ParameterTraits
+ {
+ typedef Type type;
+ static void parse(ParseCommandInfo::TokensRange const & tokens, Type & out);
+ static std::string typeDescription();
+ };
+
+}}}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "ParseParameter.cci"
+//#include "ParseParameter.ct"
+#include "ParseParameter.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParseParameter.test unit tests */
+
+//#include "ParseParameter.test.hh"
+//#include "ParseParameter.test.ih"
+
+// Custom includes
+#include "ParseParameter.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(parseParameter)
+{}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand non-inline non-template implementation */
+
+#include "ParsedCommand.hh"
+#include "ParsedCommand.ih"
+
+// Custom includes
+
+#include "ParsedCommand.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ParsedCommandOverloadBase
+
+prefix_ void senf::console::ParsedCommandOverloadBase::v_help(std::ostream & os)
+ const
+{}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+#include "ParsedCommand.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand inline non-template implementation */
+
+#include "ParsedCommand.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ParsedCommandOverloadBase
+
+prefix_ senf::console::ParsedCommandOverloadBase::ParsedCommandOverloadBase()
+{}
+
+prefix_ senf::console::detail::ParameterInfoBase &
+senf::console::ParsedCommandOverloadBase::arg(unsigned n)
+ const
+{
+ BOOST_ASSERT(n < parameters_.size());
+ return * parameters_[n];
+}
+
+///////////////////////////////cci.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand non-inline template implementation */
+
+#include "ParsedCommand.ih"
+
+// Custom includes
+
+#define prefix_
+///////////////////////////////ct.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ParsedCommandOverload<FunctionTraits,n>
+
+#define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \
+ SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \
+ 3))
+#include BOOST_PP_ITERATE()
+
+///////////////////////////////ct.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand inline template implementation */
+
+#include "ParsedCommand.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ParsedCommandOverloadBase
+
+template <class Type>
+prefix_ senf::console::detail::ParameterInfo<Type> &
+senf::console::ParsedCommandOverloadBase::arg(unsigned n)
+ const
+{
+ return static_cast<detail::ParameterInfo<Type> &>(arg(n));
+}
+
+template <class Type>
+prefix_ void senf::console::ParsedCommandOverloadBase::addParameter()
+{
+ parameters_.push_back(detail::ParameterInfo<Type>::create());
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ParsedCommandOverload<FunctionTraits,n>
+
+#define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \
+ SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \
+ 2))
+#include BOOST_PP_ITERATE()
+
+///////////////////////////////////////////////////////////////////////////
+// namespace members
+
+namespace {
+
+ // What is THIS about ??
+
+ // Ok, here's the dope: parsed commands may optionally have an std::ostream & first argument. If
+ // this argument is given, then the function will be called with the console output stream as
+ // it's first argument.
+ //
+ // This is implemented in the following way: ParsedCommandOverload (the class responsible for
+ // calling the callback) will ALWAYS pass the stream as first argument. If the user callback
+ // expects os as it's first argument, 'ignoreOneArg' will be false and the user supplied
+ // function will be directly passed to ParsedCommandOverload.
+ //
+ // If however, it does NOT take an std::ostream first argument, 'ignoreOneArg' will be true and
+ // the create member will use boost::bind to DROP the first argument.
+
+ template <class Traits, bool ignoreOneArg, unsigned arity=Traits::arity>
+ struct CreateParsedCommandOverload
+ {};
+
+ template <class Traits, unsigned arity>
+ struct CreateParsedCommandOverload<Traits, false, arity>
+ {
+ typedef Traits traits;
+
+ template <class Function>
+ static typename senf::console::ParsedCommandOverload<traits>::ptr create(Function fn)
+ { return senf::console::ParsedCommandOverload<traits>::create(fn); };
+ };
+
+# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \
+ SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \
+ 4))
+# include BOOST_PP_ITERATE()
+
+}
+
+template <class Function>
+prefix_ senf::console::ParsedCommandOverload<
+ typename senf::console::detail::ParsedCommandTraits<Function>::traits> &
+senf::console::senf_console_add_node(DirectoryNode & node, std::string const & name,
+ Function fn, int)
+{
+ OverloadedCommandNode & cmdNode (
+ node.hasChild(name)
+ ? dynamic_cast<OverloadedCommandNode &>(node(name))
+ : node.add(name, OverloadedCommandNode::create()) );
+
+ typedef senf::console::detail::ParsedCommandTraits<Function> CmdTraits;
+
+ return cmdNode.add( CreateParsedCommandOverload<
+ typename CmdTraits::traits, ! CmdTraits::has_ostream_arg>::create(fn) );
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand public header */
+
+#ifndef HH_ParsedCommand_
+#define HH_ParsedCommand_ 1
+
+// Custom includes
+#include <vector>
+#include <boost/type_traits/function_traits.hpp>
+#include <boost/type_traits/is_member_pointer.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/if.hpp>
+#include "../config.hh"
+#include "OverloadedCommand.hh"
+#include "ParseParameter.hh"
+#include "../Utils/type_traits.hh"
+
+#include "ParsedCommand.ih"
+#include "ParsedCommand.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+namespace console {
+
+ class ParsedCommandOverloadBase
+ : public CommandOverload
+ {
+ public:
+ typedef boost::intrusive_ptr<ParsedCommandOverloadBase> ptr;
+
+ protected:
+ ParsedCommandOverloadBase();
+
+ detail::ParameterInfoBase & arg(unsigned n) const;
+ template <class Type> detail::ParameterInfo<Type> & arg(unsigned n) const;
+
+ template <class Type>
+ void addParameter();
+
+ private:
+ virtual void v_help(std::ostream & os) const;
+
+ typedef std::vector<detail::ParameterInfoBase::ptr> Parameters;
+ Parameters parameters_;
+ };
+
+ template <class FunctionTraits, unsigned arity=FunctionTraits::arity>
+ class ParsedCommandOverload {};
+
+# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \
+ SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \
+ 1))
+# include BOOST_PP_ITERATE()
+
+ template <class Function>
+ ParsedCommandOverload<typename detail::ParsedCommandTraits<Function>::traits> &
+ senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int);
+
+}}
+
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(senf::console::ParsedCommandOverload, (class,unsigned))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function_traits, 1)
+
+///////////////////////////////hh.e////////////////////////////////////////
+#include "ParsedCommand.cci"
+#include "ParsedCommand.ct"
+#include "ParsedCommand.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand internal header */
+
+#ifndef IH_ParsedCommand_
+#define IH_ParsedCommand_ 1
+
+// Custom includes
+
+///////////////////////////////ih.p////////////////////////////////////////
+
+namespace senf {
+namespace console {
+namespace detail {
+
+ template <class Function, bool isFN=senf::is_any_function<Function>::value>
+ struct ParsedCommandTraits
+ {};
+
+ template <class Traits, bool flag=(Traits::arity>0)>
+ struct FirstArgType
+ {
+ typedef void type;
+ };
+
+ template <class Traits>
+ struct FirstArgType<Traits,true>
+ {
+ typedef typename Traits::arg1_type type;
+ };
+
+ template <class Function>
+ struct ParsedCommandTraits<Function, true>
+ {
+ typedef Function base_type;
+ typedef typename senf::remove_member_pointer<
+ typename boost::remove_pointer<base_type>::type>::type function_type;
+ typedef boost::function_traits<function_type> base_traits;
+
+ typedef typename FirstArgType<base_traits>::type first_arg_type;
+
+ static const bool has_ostream_arg = boost::is_same<first_arg_type, std::ostream &>::value;
+
+ typedef typename boost::mpl::if_c<
+ has_ostream_arg,
+ typename function_traits_remove_arg<base_traits>::type,
+ base_traits>
+ ::type traits;
+
+ static const bool is_member = boost::is_member_pointer<base_type>::value;
+
+ typedef typename senf::member_class<base_type>::type class_type;
+ };
+
+}}}
+
+///////////////////////////////ih.e////////////////////////////////////////
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand Boost.Preprocesser external iteration include */
+
+#if !BOOST_PP_IS_ITERATING && !defined(MPP_ParsedCommand_)
+#define MPP_ParsedCommand_ 1
+
+// Custom includes
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/bind.hpp>
+
+// ///////////////////////////mpp.p////////////////////////////////////////
+#elif BOOST_PP_IS_ITERATING // ////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+// Local Macros
+
+#define mpp_ArgTypeN(n) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type)
+#define mpp_ArgN(n) BOOST_PP_CAT(arg, BOOST_PP_INC(n))
+
+#define mpp_ArgTypes_(z,n,d) typename traits::mpp_ArgTypeN(n)
+#define mpp_TrailingArgTypes() BOOST_PP_ENUM_TRAILING( BOOST_PP_ITERATION(), mpp_ArgTypes_, _ )
+
+#define mpp_Args_(z,n,d) boost::cref(mpp_ArgN(n))
+#define mpp_TrailingArgs() BOOST_PP_ENUM_TRAILING( BOOST_PP_ITERATION(), mpp_Args_, _ )
+
+#define mpp_BindArgs_(z,n,d) BOOST_PP_CAT( _, BOOST_PP_INC(BOOST_PP_INC(n)))
+#define mpp_TrailingBindArgs() BOOST_PP_ENUM_TRAILING( BOOST_PP_ITERATION(), mpp_BindArgs_, _ )
+
+// ////////////////////////////////////////////////////////////////////////
+#if BOOST_PP_ITERATION_FLAGS()==1 // //////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+
+// Header file (.hh)
+
+template <class FunctionTraits>
+class ParsedCommandOverload<FunctionTraits, BOOST_PP_ITERATION() >
+ : public ParsedCommandOverloadBase
+{
+public:
+ typedef boost::intrusive_ptr<ParsedCommandOverload> ptr;
+ typedef FunctionTraits traits;
+ typedef boost::function<typename traits::result_type(std::ostream &
+ mpp_TrailingArgTypes())> Function;
+
+# define mpp_l(z,n,d) \
+ typedef typename boost::remove_reference<typename traits::mpp_ArgTypeN(n)>::type \
+ mpp_ArgTypeN(n);
+ BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ )
+# undef mpp_l
+
+ static ptr create(Function fn);
+
+protected:
+
+private:
+ ParsedCommandOverload(Function fn);
+
+ virtual void v_execute(std::ostream & os, ParseCommandInfo const & command) const;
+
+ Function function_;
+};
+
+// ////////////////////////////////////////////////////////////////////////
+#elif BOOST_PP_ITERATION_FLAGS()==2 // ////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+
+// inline template implementation (.cti)
+
+template <class FunctionTraits>
+prefix_ typename senf::console::ParsedCommandOverload<FunctionTraits, BOOST_PP_ITERATION() >::ptr
+senf::console::ParsedCommandOverload<FunctionTraits, BOOST_PP_ITERATION() >::create(Function fn)
+{
+ return ptr(new ParsedCommandOverload(fn));
+}
+
+template <class FunctionTraits>
+prefix_
+senf::console::ParsedCommandOverload<FunctionTraits,BOOST_PP_ITERATION()>::
+ParsedCommandOverload(Function fn)
+ : function_ (fn)
+{
+# define mpp_l(z,n,d) addParameter< mpp_ArgTypeN(n) >();
+ BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ )
+# undef mpp_l
+}
+
+// ////////////////////////////////////////////////////////////////////////
+#elif BOOST_PP_ITERATION_FLAGS()==3 // ////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+
+// non-inline template implementation (.ct)
+
+template <class FunctionTraits>
+prefix_ void senf::console::ParsedCommandOverload<FunctionTraits, BOOST_PP_ITERATION() >::
+v_execute(std::ostream & os, ParseCommandInfo const & command)
+ const
+{
+ if ( command.arguments().size() > BOOST_PP_ITERATION()
+ || (command.arguments().size() < BOOST_PP_ITERATION()
+ && ! arg( BOOST_PP_ITERATION()-1 ).hasDefault) )
+ throw SyntaxErrorException("invalid number of arguments");
+
+ // First define local variables argN for the parameters. The variables are initialized to their
+ // default values
+# define mpp_l(z,n,d) mpp_ArgTypeN(n) mpp_ArgN(n) (arg< mpp_ArgTypeN(n) >( n ).defaultValue);
+ BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ )
+# undef mpp_l
+
+ ParseCommandInfo::argument_iterator i (command.arguments().begin());
+ ParseCommandInfo::argument_iterator const i_end (command.arguments().end());
+
+ // Now parse the arguments which are provided leaving the trailing arguments at their default
+ // value. We have already checked above, whether those default values are valid. Be aware, that
+ // the following cases do NOT have 'break' statements !
+
+ switch (BOOST_PP_ITERATION() - command.arguments().size()) {
+
+# define mpp_l(z,n,d) \
+ case n : \
+ detail::ParameterTraits< mpp_ArgTypeN(n) >::parse( *(i++), mpp_ArgN(n) );
+ BOOST_PP_REPEAT( BOOST_PP_ITERATION(), mpp_l, _ )
+# undef mpp_l
+
+ default : // This happens, if ALL arguments are defaulted
+ ;
+ }
+
+ // Now call the function binding the arguments to the values parsed above. callAndWrite is
+ // specialized to ignore a 'void' return value but automatically write all other values to the
+ // output stream.
+ detail::ReturnValueTraits<typename traits::result_type>::callAndWrite(
+ boost::bind(function_, boost::ref(os)
+ mpp_TrailingArgs()),
+ os );
+}
+
+// ////////////////////////////////////////////////////////////////////////
+#elif BOOST_PP_ITERATION_FLAGS()==4 // ////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+
+// CreateParsedCommandOverload
+
+template <class Traits>
+struct CreateParsedCommandOverload<Traits, true, BOOST_PP_ITERATION()>
+{
+ typedef Traits traits;
+
+ template <class Function>
+ static typename senf::console::ParsedCommandOverload<traits>::ptr create(Function fn)
+ {
+ return senf::console::ParsedCommandOverload<traits>::create(
+ boost::bind(fn mpp_TrailingBindArgs()) );
+ }
+
+};
+
+// ////////////////////////////////////////////////////////////////////////
+#endif // /////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+// Undefine local Macros
+
+#undef mpp_TrailingArgs
+#undef mpp_Args_
+
+#undef mpp_TrailingArgTypes
+#undef mpp_ArgTypes_
+
+#undef mpp_ArgN
+#undef mpp_ArgTypeN
+
+// ////////////////////////////////////////////////////////////////////////
+#endif // /////////////////////////////////////////////////////////////////
+// ///////////////////////////mpp.e////////////////////////////////////////
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief ParsedCommand.test unit tests */
+
+//#include "ParsedCommand.test.hh"
+//#include "ParsedCommand.test.ih"
+
+// Custom includes
+#include <sstream>
+#include "ParsedCommand.hh"
+#include "Executor.hh"
+#include "Parse.hh"
+#include "ScopedDirectory.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+namespace {
+
+ int cb1(int a, double b) { return int(a+b); }
+ double cb2() { return 1.2; }
+ void cb3(int) {}
+ std::string cb4(std::ostream & os) { os << "text\n"; return "value"; }
+ void cb5(std::ostream & os, int v) { os << "Value: " << v << "\n"; }
+}
+
+BOOST_AUTO_UNIT_TEST(parsedCommand)
+{
+ senf::console::Executor executor;
+ senf::console::CommandParser parser;
+ senf::console::ScopedDirectory<> dir;
+ senf::console::root().add("test", dir);
+
+ {
+ std::stringstream ss;
+ dir.add("cb1", &cb1);
+ parser.parse("test/cb1 2 3.2",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
+ BOOST_CHECK_EQUAL( ss.str(), "5\n" );
+ }
+
+ {
+ std::stringstream ss;
+ dir.add("cb2", &cb2);
+ parser.parse("test/cb2",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
+ BOOST_CHECK_EQUAL( ss.str(), "1.2\n" );
+ }
+
+ {
+ std::stringstream ss;
+ dir.add("cb3", &cb3);
+ parser.parse("test/cb3 234",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
+ BOOST_CHECK_EQUAL( ss.str(), "" );
+ }
+
+ {
+ std::stringstream ss;
+ dir.add("cb4", &cb4);
+ parser.parse("test/cb4",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
+ BOOST_CHECK_EQUAL( ss.str(), "text\n" "value\n" );
+ }
+
+ {
+ std::stringstream ss;
+ dir.add("cb5", &cb5);
+ parser.parse("test/cb5 1234",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 ));
+ BOOST_CHECK_EQUAL( ss.str(), "Value: 1234\n" );
+ }
+
+ {
+ std::stringstream ss;
+
+ BOOST_CHECK_THROW(
+ parser.parse("test/cb1 2 3.2 foo",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
+ senf::console::SyntaxErrorException );
+
+ BOOST_CHECK_THROW(
+ parser.parse("test/cb1 2",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
+ senf::console::SyntaxErrorException );
+
+ BOOST_CHECK_THROW(
+ parser.parse("test/cb1 2 foo",
+ boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )),
+ senf::console::SyntaxErrorException );
+ }
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
return node().remove(name);
}
+prefix_ bool senf::console::ScopedDirectoryBase::hasChild(std::string const & name)
+ const
+{
+ return node().hasChild(name);
+}
+
prefix_ senf::console::DirectoryNode &
senf::console::ScopedDirectoryBase::getDirectory(std::string const & name)
const
///\{
GenericNode::ptr remove(std::string const & name);
+ bool hasChild(std::string const & name) const;
DirectoryNode & getDirectory(std::string const & name) const;
DirectoryNode & operator[](std::string const & name) const;
CommandNode & getCommand(std::string const & name) const;
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief type_traits public header */
+
+#ifndef HH_type_traits_
+#define HH_type_traits_ 1
+
+// Custom includes
+#include <boost/type_traits/function_traits.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/type_traits/is_function.hpp>
+#include <boost/bind.hpp>
+
+#include "type_traits.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ template <class Traits, unsigned arity=Traits::arity>
+ struct function_traits_remove_arg {};
+
+ template <class MemberPointer>
+ struct remove_member_pointer
+ {
+ typedef MemberPointer type;
+ };
+
+ template <class C, class T>
+ struct remove_member_pointer<T (C::*)>
+ {
+ typedef T type;
+ };
+
+ template <class MemberPointer>
+ struct member_class
+ {
+ typedef void type;
+ };
+
+ template <class C, class T>
+ struct member_class<T (C::*)>
+ {
+ typedef C type;
+ };
+
+ template <class T>
+ struct remove_any_pointer
+ : public remove_member_pointer<typename boost::remove_pointer<T>::type>
+ {};
+
+ template <class T>
+ struct is_any_function
+ : public boost::is_function<typename senf::remove_any_pointer<T>::type>
+ {};
+
+# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, 10, \
+ SENF_ABSOLUTE_INCLUDE_PATH(Utils/type_traits.mpp), \
+ 1))
+# include BOOST_PP_ITERATE()
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "type_traits.cci"
+//#include "type_traits.ct"
+//#include "type_traits.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief type_traits Boost.Preprocesser external iteration include */
+
+#if !BOOST_PP_IS_ITERATING && !defined(MPP_type_traits_)
+#define MPP_type_traits_ 1
+
+// Custom includes
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/arithmetic/inc.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/arithmetic/dec.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
+
+// ///////////////////////////mpp.p////////////////////////////////////////
+#elif BOOST_PP_IS_ITERATING // ////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+// Local Macros
+
+#define mpp_Arg(n) BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type)
+
+#define mpp_OtherArgs_(z,n,d) BOOST_PP_COMMA_IF( BOOST_PP_DEC(n) ) typename traits::mpp_Arg(n)
+#define mpp_OtherArgs() BOOST_PP_REPEAT_FROM_TO( 1, BOOST_PP_ITERATION(), mpp_OtherArgs_, _ )
+
+// ////////////////////////////////////////////////////////////////////////
+#if BOOST_PP_ITERATION_FLAGS()==1 // //////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+
+template <class Traits>
+struct function_traits_remove_arg<Traits, BOOST_PP_ITERATION()>
+{
+ typedef Traits traits;
+ typedef boost::function_traits<typename traits::result_type( mpp_OtherArgs() )> type;
+};
+
+template < class C, class RV
+ BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A ) >
+struct remove_member_pointer<RV (C::*)(BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ))>
+{
+ typedef RV type (BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ));
+};
+
+template < class C, class RV
+ BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_ITERATION(), class A ) >
+struct member_class<RV (C::*)(BOOST_PP_ENUM_PARAMS( BOOST_PP_ITERATION(), A ))>
+{
+ typedef C type;
+};
+
+// ////////////////////////////////////////////////////////////////////////
+#endif // /////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////
+// Undefine local Macros
+
+#undef mpp_Args
+#undef mpp_Args_
+
+#undef mpp_Arg
+
+// ////////////////////////////////////////////////////////////////////////
+#endif // /////////////////////////////////////////////////////////////////
+// ///////////////////////////mpp.e////////////////////////////////////////
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
# ifndef SENF_DEBUG_BACKTRACE_NUMCALLERS
# define SENF_DEBUG_BACKTRACE_NUMCALLERS 64
# endif
+#
+# ifndef SENF_CONSOLE_MAX_COMMAND_ARITY
+# define SENF_CONSOLE_MAX_COMMAND_ARITY 6
+# endif
#
# ///////////////////////////////hh.e////////////////////////////////////////
# endif
if doc.name == "search.idx" ]
def writeTemplate(target = None, source = None, env = None):
- file(target[0].abspath,"w").write(yaptu.process(str(env['TEMPLATE']), globals(), env.Dictionary()))
+ file(target[0].abspath,"w").write(source[0].read())
writeTemplate = env.Action(writeTemplate, varlist = [ 'TEMPLATE' ])
}
?>"""
-env.Command('doxy-header.html', 'SConscript', writeTemplate,
- TEMPLATE = Literal(HEADER),
- TITLE = "Documentation and API reference")
-env.Command('doxy-footer.html', 'SConscript', writeTemplate,
- TEMPLATE = Literal(FOOTER))
+header = yaptu.process(HEADER, globals(), env.Dictionary(),
+ TITLE = "Documentation and API reference")
+
+footer = yaptu.process(FOOTER, globals(), env.Dictionary())
+
+search_php = yaptu.process(HEADER + SEARCH_PHP.replace('<?','[[').replace('?>',']]') + FOOTER,
+ globals(), env.Dictionary(),
+ TITLE = "Search results")
+
+search_paths_php = yaptu.process(SEARCH_PATHS_PHP, globals(), env.Dictionary())
+
+env.Command('doxy-header.html', Value(header), writeTemplate)
+env.Command('doxy-footer.html', Value(footer), writeTemplate)
+
env.Alias('all_docs',
- env.Command('search.php', [ 'html-munge.xsl', 'SConscript' ],
+ env.Command('search.php', [ Value(search_php), 'html-munge.xsl' ],
[ writeTemplate,
'xsltproc --nonet --html --stringparam topdir .. -o - $SOURCE $TARGET 2>/dev/null'
+ "| sed"
+ r" -e 's/\$$projectname/Overview/g'"
+ r" -e 's/\$$title/Search results/g'"
+ "> ${TARGETS[0]}.tmp",
- 'mv ${TARGET}.tmp ${TARGET}' ],
- TEMPLATE = Literal(HEADER
- + SEARCH_PHP.replace('<?','[[').replace('?>',']]')
- + FOOTER),
- TITLE = "Search results"))
+ 'mv ${TARGET}.tmp ${TARGET}' ] ))
+
env.Alias('all_docs',
- env.Command('search_paths.php', 'SConscript', writeTemplate,
- TEMPLATE = Literal(SEARCH_PATHS_PHP)))
+ env.Command('search_paths.php', Value(search_paths_php), writeTemplate))
env.Alias('install_all',
env.Install( '$DOCINSTALLDIR/doclib', [ 'favicon.ico',
_RE_END = re.compile('}}')
_RE_CONT = re.compile(r'\|\|')
-def process(text,*args):
+def process(text,*args,**kw):
vardict = {}
for arg in args : vardict.update(arg)
+ vardict.update(kw)
output = StringIO()
c = copier(_RE_EXPR, vardict, _RE_BEGIN, _RE_END, _RE_CONT,
ouf = output)
--- /dev/null
+../../Console
\ No newline at end of file
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "Console/Console.hh"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End: