diff options
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/exception.hpp | 9 | ||||
-rw-r--r-- | host/include/uhd/utils/CMakeLists.txt | 4 | ||||
-rw-r--r-- | host/include/uhd/utils/assert_has.hpp (renamed from host/include/uhd/utils/assert.hpp) | 14 | ||||
-rw-r--r-- | host/include/uhd/utils/assert_has.ipp (renamed from host/include/uhd/utils/assert.ipp) | 7 |
4 files changed, 19 insertions, 15 deletions
diff --git a/host/include/uhd/exception.hpp b/host/include/uhd/exception.hpp index 71836e22e..9acc768ed 100644 --- a/host/include/uhd/exception.hpp +++ b/host/include/uhd/exception.hpp @@ -114,6 +114,15 @@ namespace uhd{ #define UHD_THROW_INVALID_CODE_PATH() \ throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path")) + /*! + * Assert the result of the code evaluation. + * If the code evaluates to false, throw an assertion error. + * \param code the code that resolved to a boolean + */ + #define UHD_ASSERT_THROW(code) if (not (code)) \ + throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \ + else void(0) + } //namespace uhd #endif /* INCLUDED_UHD_UTILS_EXCEPTION_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index b638431d3..4ed7ca460 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -17,8 +17,8 @@ INSTALL(FILES algorithm.hpp - assert.hpp - assert.ipp + assert_has.hpp + assert_has.ipp byteswap.hpp byteswap.ipp gain_group.hpp diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert_has.hpp index 1be4237d6..eae7652ad 100644 --- a/host/include/uhd/utils/assert.hpp +++ b/host/include/uhd/utils/assert_has.hpp @@ -15,20 +15,14 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#ifndef INCLUDED_UHD_UTILS_ASSERT_HPP -#define INCLUDED_UHD_UTILS_ASSERT_HPP +#ifndef INCLUDED_UHD_UTILS_ASSERT_HAS_HPP +#define INCLUDED_UHD_UTILS_ASSERT_HAS_HPP #include <uhd/config.hpp> -#include <uhd/exception.hpp> #include <string> namespace uhd{ - //! Throw an assert error with throw-site information - #define UHD_ASSERT_THROW(_x) if (not (_x)) throw uhd::assertion_error( \ - UHD_THROW_SITE_INFO("assertion failed: " + std::string(#_x)) \ - ); else void(0) - /*! * Check that an element is found in a container. * If not, throw a meaningful assertion error. @@ -48,6 +42,6 @@ namespace uhd{ }//namespace uhd -#include <uhd/utils/assert.ipp> +#include <uhd/utils/assert_has.ipp> -#endif /* INCLUDED_UHD_UTILS_ASSERT_HPP */ +#endif /* INCLUDED_UHD_UTILS_ASSERT_HAS_HPP */ diff --git a/host/include/uhd/utils/assert.ipp b/host/include/uhd/utils/assert_has.ipp index 4374fff67..a46d172f4 100644 --- a/host/include/uhd/utils/assert.ipp +++ b/host/include/uhd/utils/assert_has.ipp @@ -15,10 +15,11 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#ifndef INCLUDED_UHD_UTILS_ASSERT_IPP -#define INCLUDED_UHD_UTILS_ASSERT_IPP +#ifndef INCLUDED_UHD_UTILS_ASSERT_HAS_IPP +#define INCLUDED_UHD_UTILS_ASSERT_HAS_IPP #include <uhd/utils/algorithm.hpp> +#include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> @@ -49,4 +50,4 @@ namespace uhd{ }//namespace uhd -#endif /* INCLUDED_UHD_UTILS_ASSERT_IPP */ +#endif /* INCLUDED_UHD_UTILS_ASSERT_HAS_IPP */ |