aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-09 23:42:45 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-10 01:52:41 +0100
commit5644993d39a614216c354b59e19b27e258f98a88 (patch)
treebd3bd355d692ff65f4336763329049abeaf87cba
parent4d63e7b76e97c6afbd3c92564cfba6590bb0562c (diff)
downloadpaludis-5644993d39a614216c354b59e19b27e258f98a88.tar.gz
paludis-5644993d39a614216c354b59e19b27e258f98a88.tar.xz
Options<>::highest_bit
-rw-r--r--paludis/util/options.cc8
-rw-r--r--paludis/util/options.hh19
-rw-r--r--paludis/util/options_TEST.cc4
3 files changed, 28 insertions, 3 deletions
diff --git a/paludis/util/options.cc b/paludis/util/options.cc
index a143a15..bba53c3 100644
--- a/paludis/util/options.cc
+++ b/paludis/util/options.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* 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
@@ -121,3 +121,9 @@ OptionsStore::any() const
std::bind2nd(std::not_equal_to<uint8_t>(), 0));
}
+unsigned
+OptionsStore::highest_bit() const
+{
+ return _imp->pool.size() * 8;
+}
+
diff --git a/paludis/util/options.hh b/paludis/util/options.hh
index 1b3756c..ea757ee 100644
--- a/paludis/util/options.hh
+++ b/paludis/util/options.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* 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
@@ -96,6 +96,13 @@ namespace paludis
*/
bool any() const;
+ /**
+ * The highest bit that might be set.
+ *
+ * \since 0.40.1
+ */
+ unsigned highest_bit() const;
+
///\}
};
@@ -201,6 +208,16 @@ namespace paludis
{
return ! _store.any();
}
+
+ /**
+ * Return the value of the highest bit that might be enabled.
+ *
+ * \since 0.40.1
+ */
+ E_ highest_bit() const
+ {
+ return static_cast<E_>(_store.highest_bit());
+ }
};
}
diff --git a/paludis/util/options_TEST.cc b/paludis/util/options_TEST.cc
index 7850c66..2d67f18 100644
--- a/paludis/util/options_TEST.cc
+++ b/paludis/util/options_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2009 Ciaran McCreesh
*
* 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
@@ -91,6 +91,8 @@ namespace test_cases
TEST_CHECK(options.any());
options -= mo_seven;
TEST_CHECK(! options.any());
+ TEST_CHECK(options.highest_bit() >= static_cast<int>(last_mo));
+ TEST_CHECK(options.highest_bit() <= 8 + static_cast<int>(last_mo));
}
} test_options;
}