aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/CMakeLists.txt2
-rw-r--r--host/docs/build.rst2
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/assert.hpp21
-rw-r--r--host/include/uhd/utils/exception.hpp38
-rw-r--r--host/include/uhd/utils/props.hpp13
-rw-r--r--host/include/uhd/utils/safe_main.hpp3
-rw-r--r--host/lib/utils.cpp9
-rw-r--r--host/test/error_test.cpp14
9 files changed, 74 insertions, 29 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt
index c309af7e5..f2725e4b3 100644
--- a/host/CMakeLists.txt
+++ b/host/CMakeLists.txt
@@ -75,7 +75,7 @@ ENDIF(WIN32)
# Setup Boost
########################################################################
SET(Boost_ADDITIONAL_VERSIONS "1.42.0" "1.42")
-FIND_PACKAGE(Boost 1.37 REQUIRED COMPONENTS
+FIND_PACKAGE(Boost 1.36 REQUIRED COMPONENTS
date_time
filesystem
program_options
diff --git a/host/docs/build.rst b/host/docs/build.rst
index 81e61475e..d28682764 100644
--- a/host/docs/build.rst
+++ b/host/docs/build.rst
@@ -40,7 +40,7 @@ CMake
^^^^^^^^^^^^^^^^
Boost
^^^^^^^^^^^^^^^^
-* **Version:** at least 3.7 unix, at least 4.0 windows
+* **Version:** at least 3.6 unix, at least 4.0 windows
* **Required for:** build time + run time
* **Download URL:** http://www.boost.org/users/download/
* **Download URL (windows installer):** http://www.boostpro.com/download
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index 2831ab0b0..f588c6310 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -18,6 +18,7 @@
INSTALL(FILES
algorithm.hpp
assert.hpp
+ exception.hpp
gain_handler.hpp
props.hpp
safe_main.hpp
diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert.hpp
index ed0a95535..2f0ed4ff1 100644
--- a/host/include/uhd/utils/assert.hpp
+++ b/host/include/uhd/utils/assert.hpp
@@ -19,26 +19,24 @@
#define INCLUDED_UHD_UTILS_ASSERT_HPP
#include <uhd/config.hpp>
+#include <uhd/utils/exception.hpp>
#include <uhd/utils/algorithm.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/exception/info.hpp>
#include <stdexcept>
#include <string>
namespace uhd{
//! The exception to throw when assertions fail
- struct UHD_API assert_error : virtual std::exception, virtual boost::exception{};
-
- //! The assertion info, the code that failed
- typedef boost::error_info<struct tag_assert_info, std::string> assert_info;
+ struct UHD_API assert_error : std::runtime_error{
+ assert_error(const std::string &what);
+ };
//! Throw an assert error with throw-site information
#define UHD_ASSERT_THROW(_x) if (not (_x)) \
- BOOST_THROW_EXCEPTION(uhd::assert_error() << uhd::assert_info(#_x))
+ throw uhd::assert_error(UHD_THROW_SITE_INFO("assertion failed: " + std::string(#_x)))
/*!
* Check that an element is found in a container.
@@ -63,13 +61,14 @@ namespace uhd{
if (i++ > 0) possible_values += ", ";
possible_values += boost::lexical_cast<std::string>(v);
}
- boost::throw_exception(uhd::assert_error() << assert_info(str(boost::format(
- "Error: %s is not a valid %s. "
- "Possible values are: [%s]."
+ throw uhd::assert_error(str(boost::format(
+ "assertion failed:\n"
+ " %s is not a valid %s.\n"
+ " possible values are: [%s].\n"
)
% boost::lexical_cast<std::string>(value)
% what % possible_values
- )));
+ ));
}
}//namespace uhd
diff --git a/host/include/uhd/utils/exception.hpp b/host/include/uhd/utils/exception.hpp
new file mode 100644
index 000000000..40e81fae0
--- /dev/null
+++ b/host/include/uhd/utils/exception.hpp
@@ -0,0 +1,38 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_EXCEPTION_HPP
+#define INCLUDED_UHD_UTILS_EXCEPTION_HPP
+
+#include <uhd/config.hpp>
+#include <boost/current_function.hpp>
+#include <stdexcept>
+#include <string>
+
+/*!
+ * Create a formated string with throw-site information.
+ * Fills in the function name, file name, and line number.
+ * \param what the std::exeption message
+ * \return the formatted exception message
+ */
+#define UHD_THROW_SITE_INFO(what) std::string( \
+ std::string(what) + "\n" + \
+ " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
+ " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
+)
+
+#endif /* INCLUDED_UHD_UTILS_EXCEPTION_HPP */
diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp
index 516102a5f..f376d2612 100644
--- a/host/include/uhd/utils/props.hpp
+++ b/host/include/uhd/utils/props.hpp
@@ -20,9 +20,8 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
+#include <uhd/utils/exception.hpp>
#include <boost/tuple/tuple.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/exception/info.hpp>
#include <stdexcept>
#include <vector>
#include <string>
@@ -59,25 +58,19 @@ namespace uhd{
const std::string &name = ""
);
- //! The exception to throw for property errors
- struct UHD_API prop_error : virtual std::exception, virtual boost::exception{};
-
- //! The property error info (verbose or message)
- typedef boost::error_info<struct tag_prop_info, std::string> prop_info;
-
/*!
* Throw when getting a not-implemented or write-only property.
* Throw-site information will be included with this error.
*/
#define UHD_THROW_PROP_GET_ERROR() \
- BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot get this property"))
+ throw std::runtime_error(UHD_THROW_SITE_INFO("cannot get this property"))
/*!
* Throw when setting a not-implemented or read-only property.
* Throw-site information will be included with this error.
*/
#define UHD_THROW_PROP_SET_ERROR() \
- BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot set this property"))
+ throw std::runtime_error(UHD_THROW_SITE_INFO("cannot set this property"))
} //namespace uhd
diff --git a/host/include/uhd/utils/safe_main.hpp b/host/include/uhd/utils/safe_main.hpp
index a4e4e06e8..b682aa540 100644
--- a/host/include/uhd/utils/safe_main.hpp
+++ b/host/include/uhd/utils/safe_main.hpp
@@ -19,7 +19,6 @@
#define INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
#include <uhd/config.hpp>
-#include <boost/exception/diagnostic_information.hpp>
#include <iostream>
#include <stdexcept>
@@ -34,8 +33,6 @@
int main(int argc, char *argv[]){ \
try { \
return _main(argc, argv); \
- } catch(const boost::exception &e){ \
- std::cerr << "Error: " << boost::diagnostic_information(e) << std::endl; \
} catch(const std::exception &e) { \
std::cerr << "Error: " << e.what() << std::endl; \
} catch(...) { \
diff --git a/host/lib/utils.cpp b/host/lib/utils.cpp
index 3a1e5aa3f..d2f4dfc6e 100644
--- a/host/lib/utils.cpp
+++ b/host/lib/utils.cpp
@@ -15,11 +15,20 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include <uhd/utils/assert.hpp>
#include <uhd/utils/props.hpp>
+#include <stdexcept>
using namespace uhd;
/***********************************************************************
+ * Assert
+ **********************************************************************/
+assert_error::assert_error(const std::string &what) : std::runtime_error(what){
+ /* NOP */
+}
+
+/***********************************************************************
* Props
**********************************************************************/
named_prop_t::named_prop_t(
diff --git a/host/test/error_test.cpp b/host/test/error_test.cpp
index c5b0af45e..c76a15ab7 100644
--- a/host/test/error_test.cpp
+++ b/host/test/error_test.cpp
@@ -17,7 +17,6 @@
#include <boost/test/unit_test.hpp>
#include <uhd/utils/assert.hpp>
-#include <boost/exception/diagnostic_information.hpp>
#include <vector>
#include <iostream>
@@ -34,7 +33,16 @@ BOOST_AUTO_TEST_CASE(test_assert_has){
std::cout << "The output of the assert_has error:" << std::endl;
try{
uhd::assert_has(vec, 1, "prime");
- }catch(const boost::exception &e){
- std::cout << boost::diagnostic_information(e) << std::endl;
+ }catch(const std::exception &e){
+ std::cout << e.what() << std::endl;
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_assert_throw){
+ std::cout << "The output of the assert throw error:" << std::endl;
+ try{
+ UHD_ASSERT_THROW(2 + 2 == 5);
+ }catch(const std::exception &e){
+ std::cout << e.what() << std::endl;
}
}