From f452e7f9d2345ac50a0a011d64973068f2853098 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 29 Aug 2014 10:04:13 +0200 Subject: [PATCH] remove implicitly defined inline keywords from header-implemented functions in Util/ headers --- Extractor/ExtractionNode.h | 7 ++-- Util/DataStoreOptions.h | 4 +++ Util/IniFileUtil.h | 2 +- Util/LuaUtil.h | 4 +-- Util/ProgramOptions.h | 16 ++++----- Util/StringUtil.h | 10 +++--- Util/range.hpp | 72 ++++++++++++++++++++++++++++++++++++++ Util/range_algorithms.hpp | 42 ++++++++++++++++++++++ 8 files changed, 137 insertions(+), 20 deletions(-) create mode 100644 Util/range.hpp create mode 100644 Util/range_algorithms.hpp diff --git a/Extractor/ExtractionNode.h b/Extractor/ExtractionNode.h index 44b334ab8..b53321ed5 100644 --- a/Extractor/ExtractionNode.h +++ b/Extractor/ExtractionNode.h @@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EXTRACTION_NODE_H__ -#define EXTRACTION_NODE_H__ +#ifndef EXTRACTION_NODE_H +#define EXTRACTION_NODE_H struct ExtractionNode { @@ -38,5 +38,4 @@ struct ExtractionNode bool traffic_lights; bool barrier; }; - -#endif +#endif // EXTRACTION_NODE_H diff --git a/Util/DataStoreOptions.h b/Util/DataStoreOptions.h index f67b12d72..a591da46b 100644 --- a/Util/DataStoreOptions.h +++ b/Util/DataStoreOptions.h @@ -43,7 +43,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // generate boost::program_options object for the routing part +<<<<<<< HEAD bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &paths) +======= +bool GenerateDataStoreOptions(const int argc, const char *argv[], ServerPaths &paths, bool & springclean) +>>>>>>> remove implicitly defined inline keywords from header-implemented functions in Util/ headers { // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); diff --git a/Util/IniFileUtil.h b/Util/IniFileUtil.h index ea1d7a13b..6e843c8d1 100644 --- a/Util/IniFileUtil.h +++ b/Util/IniFileUtil.h @@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include // support old capitalized option names by down-casing them with a regex replace -inline std::string ReadIniFileAndLowerContents(const boost::filesystem::path &path) +std::string ReadIniFileAndLowerContents(const boost::filesystem::path &path) { boost::filesystem::fstream config_stream(path); std::string ini_file_content((std::istreambuf_iterator(config_stream)), diff --git a/Util/LuaUtil.h b/Util/LuaUtil.h index 5c502c956..d385c39b5 100644 --- a/Util/LuaUtil.h +++ b/Util/LuaUtil.h @@ -43,7 +43,7 @@ extern "C" { template void LUA_print(T output) { std::cout << "[LUA] " << output << std::endl; } // Check if the lua function is defined -inline bool lua_function_exists(lua_State *lua_state, const char *name) +bool lua_function_exists(lua_State *lua_state, const char *name) { luabind::object globals_table = luabind::globals(lua_state); luabind::object lua_function = globals_table[name]; @@ -53,7 +53,7 @@ inline bool lua_function_exists(lua_State *lua_state, const char *name) // Add the folder contain the script to the lua load path, so script can easily require() other lua // scripts inside that folder, or subfolders. // See http://lua-users.org/wiki/PackagePath for details on the package.path syntax. -inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) +void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) { const boost::filesystem::path profile_path(file_name); std::string folder = profile_path.parent_path().string(); diff --git a/Util/ProgramOptions.h b/Util/ProgramOptions.h index bde9766a6..2e0ec4964 100644 --- a/Util/ProgramOptions.h +++ b/Util/ProgramOptions.h @@ -144,14 +144,14 @@ inline void populate_base_path(ServerPaths &server_paths) } // generate boost::program_options object for the routing part -inline unsigned GenerateServerProgramOptions(const int argc, - const char *argv[], - ServerPaths &paths, - std::string &ip_address, - int &ip_port, - int &requested_num_threads, - bool &use_shared_memory, - bool &trial) +unsigned GenerateServerProgramOptions(const int argc, + const char *argv[], + ServerPaths &paths, + std::string &ip_address, + int &ip_port, + int &requested_num_threads, + bool &use_shared_memory, + bool &trial) { // declare a group of options that will be allowed only on command line boost::program_options::options_description generic_options("Options"); diff --git a/Util/StringUtil.h b/Util/StringUtil.h index 3c9375ca7..f0b2f018e 100644 --- a/Util/StringUtil.h +++ b/Util/StringUtil.h @@ -38,7 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // precision: position after decimal point // length: maximum number of digits including comma and decimals // work with negative values to prevent overflowing when taking -value -template static inline char *printInt(char *buffer, int value) +template static char *printInt(char *buffer, int value) { bool minus = true; if (value > 0) @@ -76,7 +76,7 @@ inline void replaceAll(std::string &s, const std::string &sub, const std::string boost::replace_all(s, sub, other); } -inline std::string EscapeJSONString(const std::string &input) +std::string EscapeJSONString(const std::string &input) { std::string output; output.reserve(input.size()); @@ -120,7 +120,7 @@ static std::string originals[] = {"&", "\"", "<", ">", "'", "[", "]", "\\"}; static std::string entities[] = { "&", """, "<", ">", "'", "&91;", "&93;", " \"}; -inline std::size_t URIDecode(const std::string &input, std::string &output) +std::size_t URIDecode(const std::string &input, std::string &output) { auto src_iter = input.begin(); output.resize(input.size() + 1); @@ -144,7 +144,7 @@ inline std::size_t URIDecode(const std::string &input, std::string &output) return decoded_length; } -inline std::size_t URIDecodeInPlace(std::string &URI) { return URIDecode(URI, URI); } +std::size_t URIDecodeInPlace(std::string &URI) { return URIDecode(URI, URI); } // TODO: remove after switch to libosmium inline bool StringStartsWith(const std::string &input, const std::string &prefix) @@ -152,7 +152,7 @@ inline bool StringStartsWith(const std::string &input, const std::string &prefix return boost::starts_with(input, prefix); } -inline std::string GetRandomString() +std::string GetRandomString() { std::string s; s.resize(128); diff --git a/Util/range.hpp b/Util/range.hpp new file mode 100644 index 000000000..a057d7c92 --- /dev/null +++ b/Util/range.hpp @@ -0,0 +1,72 @@ +/* + +Copyright (c) 2013, Project OSRM, Dennis Luxen, others +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef RANGE_HPP_ +#define RANGE_HPP_ + +namespace osrm +{ +namespace util +{ +template class Range +{ + public: + Range(Iterator begin, Iterator end) : begin_(begin), end_(end) {} + + Iterator begin() const { return begin_; } + Iterator end() const { return end_; } + + private: + Iterator begin_; + Iterator end_; +}; + +// Convenience functions for template parameter inference, +// akin to std::make_pair. + +template Range range(Iterator begin, Iterator end) +{ + return Range(begin, end); +} + +template +Range reverse(Reversable *reversable) +{ + return Range(reversable->rbegin(), reversable->rend()); +} + +template +Range +const_reverse(const ConstReversable *const_reversable) +{ + return Range(const_reversable->crbegin(), + const_reversable->crend()); +} +} +} + +#endif // RANGE_HPP_ diff --git a/Util/range_algorithms.hpp b/Util/range_algorithms.hpp new file mode 100644 index 000000000..208236e6c --- /dev/null +++ b/Util/range_algorithms.hpp @@ -0,0 +1,42 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 2010 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +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 Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. + */ + +#ifndef RANGE_ALGORITHMS_HPP +#define RANGE_ALGORITHMS_HPP + +#include + +namespace osrm { + +template +auto max_element(const Container & c) -> decltype(std::max_element(c.begin(), c.end())) +{ + return std::max_element(c.begin(), c.end()); +} + +template +auto max_element(const Container & c) -> decltype(std::max_element(c.cbegin(), c.cend())) +{ + return std::max_element(c.cbegin(), c.cend()); +} + +} + +#endif // RANGE_ALGORITHMS_HPP