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/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