src: Updating code style to conform (more or less) to ndn-cxx style
Also, adding .clang-format that describes the applied style. Note that
this style requires a slightly customized version of clang-format.
diff --git a/utils/trie/detail/functor-hook.hpp b/utils/trie/detail/functor-hook.hpp
index f34969c..b0daadd 100644
--- a/utils/trie/detail/functor-hook.hpp
+++ b/utils/trie/detail/functor-hook.hpp
@@ -29,36 +29,43 @@
namespace detail {
template<class BaseHook, class ValueType, int N>
-struct FunctorHook
-{
+struct FunctorHook {
typedef typename BaseHook::template index<N>::type hook_type;
- typedef hook_type* hook_ptr;
- typedef const hook_type* const_hook_ptr;
-
- typedef ValueType value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
-
- //Required static functions
- static hook_ptr to_hook_ptr (value_type &value)
- { return &value.policy_hook_.template get<N> (); }
-
- static const_hook_ptr to_hook_ptr(const value_type &value)
- { return &value.policy_hook_.template get<N> (); }
-
- static pointer to_value_ptr(hook_ptr n)
+ typedef hook_type* hook_ptr;
+ typedef const hook_type* const_hook_ptr;
+
+ typedef ValueType value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+
+ // Required static functions
+ static hook_ptr
+ to_hook_ptr(value_type& value)
{
- return
- boost::intrusive::get_parent_from_member<value_type>
- (static_cast<BaseHook*> (boost::intrusive::get_parent_from_member< wrap<hook_type> >(n, &wrap<hook_type>::value_)),
- &value_type::policy_hook_);
+ return &value.policy_hook_.template get<N>();
}
- static const_pointer to_value_ptr(const_hook_ptr n)
+
+ static const_hook_ptr
+ to_hook_ptr(const value_type& value)
{
- return
- boost::intrusive::get_parent_from_member<value_type>
- (static_cast<const BaseHook*> (boost::intrusive::get_parent_from_member< wrap<hook_type> >(n, &wrap<hook_type>::value_)),
- &value_type::policy_hook_);
+ return &value.policy_hook_.template get<N>();
+ }
+
+ static pointer
+ to_value_ptr(hook_ptr n)
+ {
+ return boost::intrusive::get_parent_from_member<value_type>(
+ static_cast<BaseHook*>(
+ boost::intrusive::get_parent_from_member<wrap<hook_type>>(n, &wrap<hook_type>::value_)),
+ &value_type::policy_hook_);
+ }
+ static const_pointer
+ to_value_ptr(const_hook_ptr n)
+ {
+ return boost::intrusive::get_parent_from_member<value_type>(
+ static_cast<const BaseHook*>(
+ boost::intrusive::get_parent_from_member<wrap<hook_type>>(n, &wrap<hook_type>::value_)),
+ &value_type::policy_hook_);
}
};
diff --git a/utils/trie/detail/multi-policy-container.hpp b/utils/trie/detail/multi-policy-container.hpp
index c1251e9..00bfbf1 100644
--- a/utils/trie/detail/multi-policy-container.hpp
+++ b/utils/trie/detail/multi-policy-container.hpp
@@ -29,144 +29,180 @@
namespace ndnSIM {
namespace detail {
-template< class Base, class Value >
-struct policy_wrap
-{
- policy_wrap (Base &base) : value_ (base) { }
+template<class Base, class Value>
+struct policy_wrap {
+ policy_wrap(Base& base)
+ : value_(base)
+ {
+ }
Value value_;
};
-template< class Base, class Super/*empy_wrap/previous level*/, class Value/*policy_wrap< element in vector >*/ >
-struct inherit_with_base : Super, Value
-{
- inherit_with_base (Base &base) : Super (base), Value (base) { }
+template<class Base, class Super /*empy_wrap/previous level*/,
+ class Value /*policy_wrap< element in vector >*/>
+struct inherit_with_base : Super, Value {
+ inherit_with_base(Base& base)
+ : Super(base)
+ , Value(base)
+ {
+ }
void
- update (typename Base::iterator item)
+ update(typename Base::iterator item)
{
- Value::value_.update (item);
- Super::update (item);
+ Value::value_.update(item);
+ Super::update(item);
}
bool
- insert (typename Base::iterator item)
+ insert(typename Base::iterator item)
{
- bool ok = Value::value_.insert (item);
+ bool ok = Value::value_.insert(item);
if (!ok)
return false;
- ok = Super::insert (item);
- if (!ok)
- {
- Value::value_.erase (item);
- return false;
- }
+ ok = Super::insert(item);
+ if (!ok) {
+ Value::value_.erase(item);
+ return false;
+ }
return true;
}
void
- lookup (typename Base::iterator item)
+ lookup(typename Base::iterator item)
{
- Value::value_.lookup (item);
- Super::lookup (item);
+ Value::value_.lookup(item);
+ Super::lookup(item);
}
void
- erase (typename Base::iterator item)
+ erase(typename Base::iterator item)
{
- Value::value_.erase (item);
- Super::erase (item);
- }
+ Value::value_.erase(item);
+ Super::erase(item);
+ }
void
- clear ()
+ clear()
{
- Value::value_.clear ();
- Super::clear ();
+ Value::value_.clear();
+ Super::clear();
}
};
-template< class Base >
-struct empty_policy_wrap
-{
- empty_policy_wrap (Base &base) { }
+template<class Base>
+struct empty_policy_wrap {
+ empty_policy_wrap(Base& base)
+ {
+ }
- void update (typename Base::iterator item) {}
- bool insert (typename Base::iterator item) { return true; }
- void lookup (typename Base::iterator item) {}
- void erase (typename Base::iterator item) {}
- void clear () {}
+ void
+ update(typename Base::iterator item)
+ {
+ }
+ bool
+ insert(typename Base::iterator item)
+ {
+ return true;
+ }
+ void
+ lookup(typename Base::iterator item)
+ {
+ }
+ void
+ erase(typename Base::iterator item)
+ {
+ }
+ void
+ clear()
+ {
+ }
};
-template< class Base, class Vector >
+template<class Base, class Vector>
struct multi_policy_container
- : public boost::mpl::fold< Vector,
- empty_policy_wrap<Base>,
- inherit_with_base<Base,
- boost::mpl::_1/*empty/previous*/,
- policy_wrap<Base, boost::mpl::_2>/*element in vector*/>
- >::type
-{
- typedef typename boost::mpl::fold< Vector,
- empty_policy_wrap<Base>,
- inherit_with_base<Base,
- boost::mpl::_1/*empty/previous*/,
- policy_wrap<Base, boost::mpl::_2>/*element in vector*/>
- >::type super;
+ : public boost::mpl::
+ fold<Vector, empty_policy_wrap<Base>,
+ inherit_with_base<Base, boost::mpl::_1 /*empty/previous*/,
+ policy_wrap<Base, boost::mpl::_2> /*element in vector*/>>::type {
+ typedef typename boost::mpl::
+ fold<Vector, empty_policy_wrap<Base>,
+ inherit_with_base<Base, boost::mpl::_1 /*empty/previous*/,
+ policy_wrap<Base, boost::mpl::_2> /*element in vector*/>>::type super;
typedef typename boost::mpl::at_c<Vector, 0>::type::iterator iterator;
typedef typename boost::mpl::at_c<Vector, 0>::type::const_iterator const_iterator;
- iterator begin () { return this->get<0> ().begin (); }
- const_iterator begin () const { return this->get<0> ().begin (); }
+ iterator
+ begin()
+ {
+ return this->get<0>().begin();
+ }
+ const_iterator
+ begin() const
+ {
+ return this->get<0>().begin();
+ }
- iterator end () { return this->get<0> ().end (); }
- const_iterator end () const { return this->get<0> ().end (); }
+ iterator
+ end()
+ {
+ return this->get<0>().end();
+ }
+ const_iterator
+ end() const
+ {
+ return this->get<0>().end();
+ }
- size_t size () const { return this->get<0> ().size (); }
-
- multi_policy_container (Base &base)
- : super (base)
- { }
+ size_t
+ size() const
+ {
+ return this->get<0>().size();
+ }
+
+ multi_policy_container(Base& base)
+ : super(base)
+ {
+ }
template<int N>
- struct index
- {
+ struct index {
typedef typename boost::mpl::at_c<Vector, N>::type type;
};
-
+
template<class T>
- T &
- get ()
+ T&
+ get()
{
- return static_cast< policy_wrap<Base, T> &> (*this).value_;
+ return static_cast<policy_wrap<Base, T>&>(*this).value_;
}
template<class T>
- const T &
- get () const
+ const T&
+ get() const
{
- return static_cast< const policy_wrap<Base, T> &> (*this).value_;
+ return static_cast<const policy_wrap<Base, T>&>(*this).value_;
}
template<int N>
- typename boost::mpl::at_c<Vector, N>::type &
- get ()
+ typename boost::mpl::at_c<Vector, N>::type&
+ get()
{
typedef typename boost::mpl::at_c<Vector, N>::type T;
- return static_cast< policy_wrap<Base, T> &> (*this).value_;
+ return static_cast<policy_wrap<Base, T>&>(*this).value_;
}
template<int N>
- const typename boost::mpl::at_c<Vector, N>::type &
- get () const
+ const typename boost::mpl::at_c<Vector, N>::type&
+ get() const
{
typedef typename boost::mpl::at_c<Vector, N>::type T;
- return static_cast< const policy_wrap<Base, T> &> (*this).value_;
+ return static_cast<const policy_wrap<Base, T>&>(*this).value_;
}
};
-
} // detail
} // ndnSIM
} // ndn
diff --git a/utils/trie/detail/multi-type-container.hpp b/utils/trie/detail/multi-type-container.hpp
index d4971c4..56dc89e 100644
--- a/utils/trie/detail/multi-type-container.hpp
+++ b/utils/trie/detail/multi-type-container.hpp
@@ -30,54 +30,51 @@
namespace ndnSIM {
namespace detail {
-template <class T>
-struct wrap
-{
+template<class T>
+struct wrap {
T value_;
};
-template< class Vector >
+template<class Vector>
struct multi_type_container
- : public boost::mpl::inherit_linearly< Vector, boost::mpl::inherit<wrap<boost::mpl::_2>, boost::mpl::_1 >
- >::type
-{
+ : public boost::mpl::inherit_linearly<Vector, boost::mpl::inherit<wrap<boost::mpl::_2>,
+ boost::mpl::_1>>::type {
template<int N>
- struct index
- {
+ struct index {
typedef typename boost::mpl::at_c<Vector, N>::type type;
};
-
+
template<class T>
- T &
- get ()
+ T&
+ get()
{
- return static_cast< wrap<T> &> (*this).value_;
+ return static_cast<wrap<T>&>(*this).value_;
}
template<class T>
- const T &
- get () const
+ const T&
+ get() const
{
- return static_cast< const wrap<T> &> (*this).value_;
- }
-
- template<int N>
- typename boost::mpl::at_c<Vector, N>::type &
- get ()
- {
- typedef typename boost::mpl::at_c<Vector, N>::type T;
- return static_cast< wrap<T> &> (*this).value_;
+ return static_cast<const wrap<T>&>(*this).value_;
}
template<int N>
- const typename boost::mpl::at_c<Vector, N>::type &
- get () const
+ typename boost::mpl::at_c<Vector, N>::type&
+ get()
{
typedef typename boost::mpl::at_c<Vector, N>::type T;
- return static_cast< const wrap<T> &> (*this).value_;
+ return static_cast<wrap<T>&>(*this).value_;
+ }
+
+ template<int N>
+ const typename boost::mpl::at_c<Vector, N>::type&
+ get() const
+ {
+ typedef typename boost::mpl::at_c<Vector, N>::type T;
+ return static_cast<const wrap<T>&>(*this).value_;
}
};
-
+
} // detail
} // ndnSIM
} // ndn