aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-09 16:44:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-09 16:44:21 +0000
commitdee716a164a48efaee7f70c24779ca27664cf390 (patch)
tree259ad8b78af2fea53e557864c8e7a70add846242
parent854f343c0da76c1a5259bee1868607da55ddcb30 (diff)
downloadpaludis-dee716a164a48efaee7f70c24779ca27664cf390.tar.gz
paludis-dee716a164a48efaee7f70c24779ca27664cf390.tar.xz
Remove deleter, it's only used by test cases. Clean up some more public interfaces and doxygen blocks.
-rw-r--r--paludis/dep_list.cc1
-rw-r--r--paludis/util/counted_ptr.hh148
-rw-r--r--paludis/util/deleter.cc32
-rw-r--r--paludis/util/deleter.hh57
-rw-r--r--paludis/util/deleter_TEST.cc85
-rw-r--r--paludis/util/destringify.hh10
-rw-r--r--paludis/util/dir_iterator.cc80
-rw-r--r--paludis/util/dir_iterator.hh68
-rw-r--r--paludis/util/exception.hh23
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/iterator_TEST.cc24
-rw-r--r--paludis/util/strip.cc1
-rw-r--r--paludis/util/visitor_TEST.cc138
-rw-r--r--paludis/version_spec.cc1
14 files changed, 272 insertions, 397 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 5348392..56de0bb 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -21,7 +21,6 @@
#include <paludis/dep_atom_flattener.hh>
#include <paludis/dep_list.hh>
#include <paludis/match_package.hh>
-#include <paludis/util/container_entry.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
diff --git a/paludis/util/counted_ptr.hh b/paludis/util/counted_ptr.hh
index cb816f2..46a4adc 100644
--- a/paludis/util/counted_ptr.hh
+++ b/paludis/util/counted_ptr.hh
@@ -41,10 +41,12 @@ namespace paludis
class CountedPtrError : public Exception
{
public:
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
CountedPtrError() throw ();
+
+ ///\}
};
/**
@@ -138,9 +140,9 @@ namespace paludis
*/
T_ * _ptr;
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
CountedPtrBase(T_ * ptr) :
ComparisonPolicy<CountedPtrBase<T_, dereference_policy::UncheckedDereferenceTag>,
comparison_mode::EqualityComparisonTag,
@@ -150,46 +152,35 @@ namespace paludis
{
}
- /**
- * Destructor.
- */
~CountedPtrBase()
{
}
+ ///\}
+
public:
- /**
- * Dereference operator (const).
- */
- inline const T_ & operator* () const;
+ ///\name Dereference operators
+ ///\{
- /**
- * Dereference to member operator (const).
- */
+ inline const T_ & operator* () const;
inline const T_ * operator-> () const;
-
- /**
- * Dereference operator (non const).
- */
T_ & operator* ();
-
- /**
- * Dereference to member operator (non const).
- */
T_ * operator-> ();
/**
- * Not null?
+ * Fetch our raw pointer.
*/
- operator bool() const
+ T_ * raw_pointer() const
{
return _ptr;
}
+ ///\}
+
/**
- * Fetch our raw pointer.
+ * Not null?
*/
- T_ * raw_pointer() const
+ operator bool() const
{
return _ptr;
}
@@ -240,9 +231,9 @@ namespace paludis
*/
T_ * _ptr;
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
CountedPtrBase(T_ * ptr) :
ComparisonPolicy<CountedPtrBase<T_, dereference_policy::CheckedDereferenceTag>,
comparison_mode::EqualityComparisonTag,
@@ -252,46 +243,35 @@ namespace paludis
{
}
- /**
- * Destructor.
- */
~CountedPtrBase()
{
}
+ ///\}
+
public:
- /**
- * Dereference operator (const).
- */
- inline const T_ & operator* () const;
+ ///\name Dereference operators
+ ///\{
- /**
- * Dereference to member operator (const).
- */
+ inline const T_ & operator* () const;
inline const T_ * operator-> () const;
-
- /**
- * Dereference operator (non const).
- */
T_ & operator* ();
-
- /**
- * Dereference to member operator (non const).
- */
T_ * operator-> ();
/**
- * Not null?
+ * Fetch our raw pointer.
*/
- operator bool() const
+ T_ * raw_pointer() const
{
return _ptr;
}
+ ///\}
+
/**
- * Fetch our raw pointer.
+ * Not null?
*/
- T_ * raw_pointer() const
+ operator bool() const
{
return _ptr;
}
@@ -360,18 +340,15 @@ namespace paludis
unsigned * _ref_count;
public:
- /**
- * Constructor, from a raw pointer.
- */
+ ///\name Basic operations
+ ///\{
+
explicit CountedPtr(T_ * const ptr) :
counted_ptr_internals::CountedPtrBase<T_, DereferencePolicy_>(ptr),
_ref_count(new unsigned(1))
{
}
- /**
- * Constructor, from another CountedPtr.
- */
CountedPtr(const CountedPtr & other) :
counted_ptr_internals::CountedPtrBase<T_, DereferencePolicy_>(other.raw_pointer()),
_ref_count(other._ref_count)
@@ -391,9 +368,6 @@ namespace paludis
++*_ref_count;
}
- /**
- * Destructor.
- */
~CountedPtr()
{
if (0 == --(*_ref_count))
@@ -439,6 +413,11 @@ namespace paludis
return operator= (CountedPtr<T_, count_policy::ExternalCountTag>(0));
}
+ ///\}
+
+ ///\name Pointer operations
+ ///\{
+
/**
* Fetch our reference count pointer.
*/
@@ -446,6 +425,8 @@ namespace paludis
{
return _ref_count;
}
+
+ ///\}
};
/**
@@ -458,9 +439,9 @@ namespace paludis
public counted_ptr_internals::CountedPtrBase<T_, DereferencePolicy_>
{
public:
- /**
- * Constructor, from a raw pointer.
- */
+ ///\name Basic operations
+ ///\{
+
explicit CountedPtr(T_ * const ptr) :
counted_ptr_internals::CountedPtrBase<T_, DereferencePolicy_>(ptr)
{
@@ -468,9 +449,6 @@ namespace paludis
++*this->_ptr->reference_count_pointer();
}
- /**
- * Constructor, from another CountedPtr.
- */
CountedPtr(const CountedPtr & other) :
counted_ptr_internals::CountedPtrBase<T_, DereferencePolicy_>(other._ptr)
{
@@ -491,14 +469,8 @@ namespace paludis
++*this->_ptr->reference_count_pointer();
}
- /**
- * Destructor.
- */
~CountedPtr();
- /**
- * Assignment, from another CountedPtr.
- */
const CountedPtr & operator= (const CountedPtr & other)
{
if (other._ptr != this->_ptr)
@@ -530,6 +502,11 @@ namespace paludis
return operator= (CountedPtr<T_, count_policy::InternalCountTag>(0));
}
+ ///\}
+
+ ///\name Pointer operations
+ ///\{
+
/**
* Fetch our reference count pointer.
*/
@@ -540,6 +517,8 @@ namespace paludis
else
return 0;
}
+
+ ///\}
};
template <typename T_, typename DereferencePolicy_>
@@ -569,22 +548,24 @@ namespace paludis
mutable unsigned _ref_count;
protected:
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
InternalCounted() :
_ref_count(0)
{
}
- /**
- * Destructor.
- */
~InternalCounted()
{
}
+ ///\}
+
public:
+ ///\name Pointer types
+ ///\{
+
/**
* A CountedPtr to us.
*/
@@ -595,6 +576,11 @@ namespace paludis
*/
typedef CountedPtr<const T_, count_policy::InternalCountTag, DereferencePolicy_> ConstPointer;
+ ///\}
+
+ ///\name Pointer operations
+ ///\{
+
/**
* Fetch a pointer to our reference count (may be zero).
*/
@@ -602,6 +588,8 @@ namespace paludis
{
return & _ref_count;
}
+
+ ///\}
};
}
diff --git a/paludis/util/deleter.cc b/paludis/util/deleter.cc
deleted file mode 100644
index 76e7ff7..0000000
--- a/paludis/util/deleter.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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 <paludis/util/deleter.hh>
-
-/** \file
- * Implementation for Deleter.
- *
- * \ingroup grpdeleter
- */
-
-using namespace paludis;
-
-Deleter::Deleter()
-{
-}
diff --git a/paludis/util/deleter.hh b/paludis/util/deleter.hh
deleted file mode 100644
index 8ae9bee..0000000
--- a/paludis/util/deleter.hh
+++ /dev/null
@@ -1,57 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_DELETER_HH
-#define PALUDIS_GUARD_PALUDIS_DELETER_HH 1
-
-/** \file
- * Declarations for the Deleter class.
- *
- * \ingroup grpdeleter
- */
-
-namespace paludis
-{
- /**
- * A Deleter is a functor that deletes something.
- *
- * See \ref EffSTL item 7.
- *
- * \ingroup grpdeleter
- */
- class Deleter
- {
- public:
- /**
- * Constructor.
- */
- Deleter();
-
- /**
- * Delete an item.
- */
- template <typename T_>
- void operator() (T_ t)
- {
- delete t;
- }
- };
-}
-
-#endif
diff --git a/paludis/util/deleter_TEST.cc b/paludis/util/deleter_TEST.cc
deleted file mode 100644
index 05b6006..0000000
--- a/paludis/util/deleter_TEST.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis 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 <algorithm>
-#include <paludis/util/deleter.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-#include <vector>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for deleter.hh.
- *
- * \ingroup grptestcases
- */
-
-namespace
-{
- /**
- * Test class to be deleted, with an instance count.
- *
- * \ingroup grptestcases
- */
- struct MyClass
- {
- static int instances;
-
- MyClass()
- {
- ++instances;
- }
-
- ~MyClass()
- {
- --instances;
- }
- };
-}
-
-int MyClass::instances = 0;
-
-namespace test_cases
-{
- /**
- * Test Deleter.
- *
- * \ingroup grptestcases
- */
- struct DeleterTest : TestCase
- {
- DeleterTest() : TestCase("deleter") { }
-
- void run()
- {
- std::vector<MyClass *> v;
- TEST_CHECK_EQUAL(MyClass::instances, 0);
- v.push_back(new MyClass);
- TEST_CHECK_EQUAL(MyClass::instances, 1);
- v.push_back(new MyClass);
- TEST_CHECK_EQUAL(MyClass::instances, 2);
- v.push_back(new MyClass);
- TEST_CHECK_EQUAL(MyClass::instances, 3);
- std::for_each(v.begin(), v.end(), Deleter());
- TEST_CHECK_EQUAL(MyClass::instances, 0);
- }
- } test_deleter;
-}
diff --git a/paludis/util/destringify.hh b/paludis/util/destringify.hh
index 1303de7..4dd6eea 100644
--- a/paludis/util/destringify.hh
+++ b/paludis/util/destringify.hh
@@ -41,10 +41,12 @@ namespace paludis
class DestringifyError : public Exception
{
public:
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
DestringifyError(const std::string & str) throw ();
+
+ ///\}
};
/**
@@ -112,7 +114,7 @@ namespace paludis
i = Destringifier<int, Exception_>::do_destringify(s);
return i > 0;
}
- catch (DestringifyError &)
+ catch (const DestringifyError &)
{
bool b;
std::istringstream ss(s);
diff --git a/paludis/util/dir_iterator.cc b/paludis/util/dir_iterator.cc
index 4e94931..5d95c63 100644
--- a/paludis/util/dir_iterator.cc
+++ b/paludis/util/dir_iterator.cc
@@ -31,49 +31,70 @@
using namespace paludis;
+namespace paludis
+{
+ template<>
+ struct Implementation<DirIterator> :
+ InternalCounted<Implementation<DirIterator> >
+ {
+ FSEntry base;
+ bool ignore_dotfiles;
+ CountedPtr<std::set<FSEntry>, count_policy::ExternalCountTag> items;
+ std::set<FSEntry>::iterator iter;
+
+ Implementation(const FSEntry & b, bool i, CountedPtr<std::set<FSEntry>,
+ count_policy::ExternalCountTag> ii) :
+ base(b),
+ ignore_dotfiles(i),
+ items(ii)
+ {
+ }
+ };
+}
+
DirOpenError::DirOpenError(const FSEntry & location, const int errno_value) throw () :
FSError("Error opening directory '" + stringify(location) + "': " + strerror(errno_value))
{
}
DirIterator::DirIterator(const FSEntry & base, bool ignore_dotfiles) :
- _base(base),
- _ignore_dotfiles(ignore_dotfiles),
- _items(new std::set<FSEntry>)
+ PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(
+ base, ignore_dotfiles, CountedPtr<std::set<FSEntry>,
+ count_policy::ExternalCountTag>(new std::set<FSEntry>)))
{
- DIR * d(opendir(stringify(base).c_str()));
+ DIR * d(opendir(stringify(_imp->base).c_str()));
if (0 == d)
- throw DirOpenError(base, errno);
+ throw DirOpenError(_imp->base, errno);
struct dirent * de;
while (0 != ((de = readdir(d))))
- if (ignore_dotfiles)
+ if (_imp->ignore_dotfiles)
{
if ('.' != de->d_name[0])
- _items->insert(_base / std::string(de->d_name));
+ _imp->items->insert(_imp->base / std::string(de->d_name));
}
else if (! (de->d_name[0] == '.' &&
(de->d_name[1] == '\0' || (de->d_name[1] == '.' && de->d_name[2] == '\0'))))
- _items->insert(_base / std::string(de->d_name));
+ _imp->items->insert(_imp->base / std::string(de->d_name));
- _iter = _items->begin();
+ _imp->iter = _imp->items->begin();
closedir(d);
}
DirIterator::DirIterator(const DirIterator & other) :
- _base(other._base),
- _ignore_dotfiles(other._ignore_dotfiles),
- _items(other._items),
- _iter(other._iter)
+ PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(
+ other._imp->base, other._imp->ignore_dotfiles, other._imp->items))
{
+ _imp->iter = other._imp->iter;
}
DirIterator::DirIterator() :
- _base(""),
- _items(new std::set<FSEntry>),
- _iter(_items->end())
+ PrivateImplementationPattern<DirIterator>(new Implementation<DirIterator>(
+ FSEntry(""), true, CountedPtr<std::set<FSEntry>,
+ count_policy::ExternalCountTag>(new std::set<FSEntry>)))
{
+ _imp->iter = _imp->items->end();
}
DirIterator::~DirIterator()
@@ -85,9 +106,10 @@ DirIterator::operator= (const DirIterator & other)
{
if (this != &other)
{
- _base = other._base;
- _items = other._items;
- _iter = other._iter;
+ _imp->base = other._imp->base;
+ _imp->items = other._imp->items;
+ _imp->iter = other._imp->iter;
+ _imp->ignore_dotfiles = other._imp->ignore_dotfiles;
}
return *this;
}
@@ -95,19 +117,19 @@ DirIterator::operator= (const DirIterator & other)
const FSEntry &
DirIterator::operator* () const
{
- return *_iter;
+ return *_imp->iter;
}
const FSEntry *
DirIterator::operator-> () const
{
- return &*_iter;
+ return &*_imp->iter;
}
DirIterator &
DirIterator::operator++ ()
{
- ++_iter;
+ ++_imp->iter;
return *this;
}
@@ -115,24 +137,24 @@ DirIterator
DirIterator::operator++ (int)
{
DirIterator c(*this);
- _iter++;
+ _imp->iter++;
return c;
}
bool
DirIterator::operator== (const DirIterator & other) const
{
- if (other._iter == other._items->end())
- return _iter == _items->end();
+ if (other._imp->iter == other._imp->items->end())
+ return _imp->iter == _imp->items->end();
- if (_iter == _items->end())
- return other._iter == other._items->end();
+ if (_imp->iter == _imp->items->end())
+ return other._imp->iter == other._imp->items->end();
- if (other._items != _items)
+ if (other._imp->items != _imp->items)
throw InternalError(PALUDIS_HERE,
"comparing two different DirIterators.");
- return other._iter == _iter;
+ return other._imp->iter == _imp->iter;
}
bool
diff --git a/paludis/util/dir_iterator.hh b/paludis/util/dir_iterator.hh
index 43062ea..7865e55 100644
--- a/paludis/util/dir_iterator.hh
+++ b/paludis/util/dir_iterator.hh
@@ -23,6 +23,7 @@
#include <iterator>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/private_implementation_pattern.hh>
#include <set>
/** \file
@@ -42,10 +43,12 @@ namespace paludis
class DirOpenError : public FSError
{
public:
- /**
- * Constructor.
- */
+ ///\name Basic operations
+ ///\{
+
DirOpenError(const FSEntry & location, const int errno_value) throw ();
+
+ ///\}
};
/**
@@ -57,24 +60,20 @@ namespace paludis
*
* \ingroup grpfilesystem
*/
- class DirIterator : public std::iterator<std::forward_iterator_tag, FSEntry>
+ class DirIterator :
+ public std::iterator<std::forward_iterator_tag, FSEntry>,
+ private PrivateImplementationPattern<DirIterator>
{
- private:
- FSEntry _base;
- bool _ignore_dotfiles;
- CountedPtr<std::set<FSEntry>, count_policy::ExternalCountTag> _items;
- std::set<FSEntry>::iterator _iter;
-
public:
+ ///\name Basic operations
+ ///\{
+
/**
* Constructor, to an FSEntry which must be a directory, with an
* option to not ignore dotfiles.
*/
explicit DirIterator(const FSEntry & base, bool ignore_dotfiles = true);
- /**
- * Copy constructor.
- */
DirIterator(const DirIterator & other);
/**
@@ -82,45 +81,36 @@ namespace paludis
*/
DirIterator();
- /**
- * Destructor.
- */
~DirIterator();
- /**
- * Assign.
- */
const DirIterator & operator= (const DirIterator & other);
- /**
- * Dereference.
- */
+ ///\}
+
+ ///\name Dereference operators
+ ///\{
+
const FSEntry & operator* () const;
- /**
- * Dereference.
- */
const FSEntry * operator-> () const;
- /**
- * Increment.
- */
- DirIterator & operator++ ();
+ ///\}
- /**
- * Increment.
- */
+ ///\name Increment, decrement operators
+ ///\{
+
+ DirIterator & operator++ ();
DirIterator operator++ (int);
- /**
- * Compare.
- */
- bool operator== (const DirIterator & other) const;
+ ///\}
- /**
- * Inverse compare.
- */
+ ///\name Comparison operators
+ ///\{
+
+ bool operator== (const DirIterator & other) const;
bool operator!= (const DirIterator & other) const;
+
+ ///\}
};
}
diff --git a/paludis/util/exception.hh b/paludis/util/exception.hh
index 6f93ba8..ac41ae1 100644
--- a/paludis/util/exception.hh
+++ b/paludis/util/exception.hh
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_EXCEPTION_HH 1
#include <paludis/util/attributes.hh>
-#include <paludis/util/stringify.hh>
#include <string>
#include <exception>
@@ -144,15 +143,19 @@ namespace paludis
*/
ConfigurationError(const std::string & msg) throw ();
};
-}
-/** \def PALUDIS_HERE
- * Expands to the current function name, file and line, for use with
- * paludis::InternalError.
- *
- * \ingroup grpexceptions
- */
-#define PALUDIS_HERE (paludis::stringify(__PRETTY_FUNCTION__) + " at " + \
- paludis::stringify(__FILE__) + ":" + paludis::stringify(__LINE__))
+ template <typename T_>
+ std::string
+ stringify(const T_ & item);
+
+ /** \def PALUDIS_HERE
+ * Expands to the current function name, file and line, for use with
+ * paludis::InternalError.
+ *
+ * \ingroup grpexceptions
+ */
+#define PALUDIS_HERE (std::string(__PRETTY_FUNCTION__) + " at " + \
+ std::string(__FILE__) + ":" + paludis::stringify(__LINE__))
+}
#endif
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index f2f07d3..8b14ccf 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -13,7 +13,6 @@ add(`collection', `hh')
add(`compare', `hh')
add(`comparison_policy', `hh', `test')
add(`counted_ptr', `hh', `cc', `test')
-add(`deleter', `hh', `cc', `test')
add(`destringify', `hh', `cc', `test')
add(`dir_iterator', `hh', `cc', `test', `testscript')
add(`exception', `hh', `cc')
diff --git a/paludis/util/iterator_TEST.cc b/paludis/util/iterator_TEST.cc
index 06e7d70..e946e11 100644
--- a/paludis/util/iterator_TEST.cc
+++ b/paludis/util/iterator_TEST.cc
@@ -20,7 +20,6 @@
#include <algorithm>
#include <list>
#include <paludis/util/counted_ptr.hh>
-#include <paludis/util/deleter.hh>
#include <paludis/util/iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -36,6 +35,29 @@ using namespace paludis;
* \ingroup grptestcases
*/
+namespace
+{
+ class Deleter
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Deleter()
+ {
+ }
+
+ /**
+ * Delete an item.
+ */
+ template <typename T_>
+ void operator() (T_ t)
+ {
+ delete t;
+ }
+ };
+}
+
namespace test_cases
{
/**
diff --git a/paludis/util/strip.cc b/paludis/util/strip.cc
index 3a220a1..0be0927 100644
--- a/paludis/util/strip.cc
+++ b/paludis/util/strip.cc
@@ -19,6 +19,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/strip.hh>
+#include <paludis/util/stringify.hh>
/** \file
* Implementation of strip things.
diff --git a/paludis/util/visitor_TEST.cc b/paludis/util/visitor_TEST.cc
index 25e020e..45c5369 100644
--- a/paludis/util/visitor_TEST.cc
+++ b/paludis/util/visitor_TEST.cc
@@ -18,7 +18,6 @@
*/
#include <algorithm>
-#include <paludis/util/deleter.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/visitor.hh>
#include <test/test_framework.hh>
@@ -36,78 +35,101 @@ using namespace test;
#ifndef DOXYGEN
-class Node;
-class FooNode;
-class BarNode;
-
-typedef VisitorTypes<FooNode *, BarNode *> NodeVisitorTypes;
-
-struct Node :
- virtual VisitableInterface<NodeVisitorTypes>
-{
-};
-
-struct FooNode :
- Node,
- Visitable<FooNode, NodeVisitorTypes>
+namespace
{
- std::string c_foo() const
+ class Deleter
{
- return "c_foo";
- }
-
- std::string foo()
+ public:
+ /**
+ * Constructor.
+ */
+ Deleter()
+ {
+ }
+
+ /**
+ * Delete an item.
+ */
+ template <typename T_>
+ void operator() (T_ t)
+ {
+ delete t;
+ }
+ };
+
+ class Node;
+ class FooNode;
+ class BarNode;
+
+ typedef VisitorTypes<FooNode *, BarNode *> NodeVisitorTypes;
+
+ struct Node :
+ virtual VisitableInterface<NodeVisitorTypes>
{
- return "foo";
- }
-};
+ };
-struct BarNode :
- Node,
- Visitable<BarNode, NodeVisitorTypes>
-{
- std::string c_bar() const
+ struct FooNode :
+ Node,
+ Visitable<FooNode, NodeVisitorTypes>
{
- return "c_bar";
- }
+ std::string c_foo() const
+ {
+ return "c_foo";
+ }
- std::string bar()
+ std::string foo()
+ {
+ return "foo";
+ }
+ };
+
+ struct BarNode :
+ Node,
+ Visitable<BarNode, NodeVisitorTypes>
{
- return "bar";
- }
-};
+ std::string c_bar() const
+ {
+ return "c_bar";
+ }
-struct NodeCVisitor :
- NodeVisitorTypes::ConstVisitor
-{
- std::string r;
+ std::string bar()
+ {
+ return "bar";
+ }
+ };
- virtual void visit(const FooNode * const f)
+ struct NodeCVisitor :
+ NodeVisitorTypes::ConstVisitor
{
- r.append(f->c_foo());
- }
+ std::string r;
- virtual void visit(const BarNode * const b)
- {
- r.append(b->c_bar());
- }
-};
+ virtual void visit(const FooNode * const f)
+ {
+ r.append(f->c_foo());
+ }
-struct NodeVisitor :
- NodeVisitorTypes::Visitor
-{
- std::string r;
+ virtual void visit(const BarNode * const b)
+ {
+ r.append(b->c_bar());
+ }
+ };
- virtual void visit(FooNode * const f)
+ struct NodeVisitor :
+ NodeVisitorTypes::Visitor
{
- r.append(f->foo());
- }
+ std::string r;
- virtual void visit(BarNode * const b)
- {
- r.append(b->bar());
- }
-};
+ virtual void visit(FooNode * const f)
+ {
+ r.append(f->foo());
+ }
+
+ virtual void visit(BarNode * const b)
+ {
+ r.append(b->bar());
+ }
+ };
+}
#endif
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 480eca9..d446e41 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -20,6 +20,7 @@
#include <algorithm>
#include <paludis/util/exception.hh>
#include <paludis/util/smart_record.hh>
+#include <paludis/util/stringify.hh>
#include <paludis/version_spec.hh>
#include <vector>
#include <limits>