timeout.cpp
Go to the documentation of this file.
00001 #include "cpr/timeout.h"
00002 
00003 #include <limits>
00004 #include <stdexcept>
00005 #include <string>
00006 #include <type_traits>
00007 
00008 namespace cpr {
00009 
00010 long Timeout::Milliseconds() const {
00011     static_assert(std::is_same<std::chrono::milliseconds, decltype(ms)>::value,
00012                   "Following casting expects milliseconds.");
00013 
00014     if (ms.count() > std::numeric_limits<long>::max()) {
00015         throw std::overflow_error("cpr::Timeout: timeout value overflow: " +
00016                                   std::to_string(ms.count()) + " ms.");
00017     }
00018     if (ms.count() < std::numeric_limits<long>::min()) {
00019         throw std::underflow_error("cpr::Timeout: timeout value underflow: " +
00020                                    std::to_string(ms.count()) + " ms.");
00021     }
00022 
00023     return static_cast<long>(ms.count());
00024 }
00025 
00026 } // namespace cpr


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06