LogCabin
Client/Util.cc
Go to the documentation of this file.
00001 /* Copyright (c) 2015 Diego Ongaro
00002  *
00003  * Permission to use, copy, modify, and distribute this software for any
00004  * purpose with or without fee is hereby granted, provided that the above
00005  * copyright notice and this permission notice appear in all copies.
00006  *
00007  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
00008  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00009  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR
00010  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00011  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00012  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00013  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00014  */
00015 
00016 #include "Core/Time.h"
00017 #include "include/LogCabin/Client.h"
00018 #include "include/LogCabin/Util.h"
00019 
00020 namespace LogCabin {
00021 namespace Client {
00022 namespace Util {
00023 
00024 int64_t
00025 parseSignedDuration(const std::string& description)
00026 {
00027     try {
00028         return Core::Time::parseSignedDuration(description);
00029     } catch (const std::runtime_error& e) {
00030         throw Client::InvalidArgumentException(e.what());
00031     }
00032 }
00033 
00034 uint64_t
00035 parseNonNegativeDuration(const std::string& description)
00036 {
00037     try {
00038         return Core::Time::parseNonNegativeDuration(description);
00039     } catch (const std::runtime_error& e) {
00040         throw Client::InvalidArgumentException(e.what());
00041     }
00042 }
00043 
00044 } // namespace LogCabin::Util
00045 } // namespace LogCabin::Client
00046 } // namespace LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines