Remove the encoder/decoder dependecy from Hint

This commit is contained in:
Patrick Niklaus 2016-03-08 23:46:14 +01:00
parent 5f457bff12
commit 0b3289ea37
3 changed files with 24 additions and 19 deletions

View File

@ -382,7 +382,7 @@ set_property(TARGET osrm-routed PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
file(GLOB VariantGlob third_party/variant/*.hpp) file(GLOB VariantGlob third_party/variant/*.hpp)
file(GLOB LibraryGlob include/osrm/*.hpp) file(GLOB LibraryGlob include/osrm/*.hpp)
file(GLOB ParametersGlob include/engine/api/*.hpp) file(GLOB ParametersGlob include/engine/api/*.hpp)
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/object_encoder.hpp include/engine/phantom_node.hpp) set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/phantom_node.hpp)
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/strong_typedef.hpp) set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/strong_typedef.hpp)
set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp) set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp)

View File

@ -1,18 +1,12 @@
#ifndef ENGINE_HINT_HPP #ifndef ENGINE_HINT_HPP
#define ENGINE_HINT_HPP #define ENGINE_HINT_HPP
#include "engine/object_encoder.hpp"
#include "engine/phantom_node.hpp" #include "engine/phantom_node.hpp"
#include "util/coordinate.hpp" #include "util/coordinate.hpp"
#include "phantom_node.hpp"
#include <boost/assert.hpp>
#include <cstdint>
#include <cmath>
#include <string> #include <string>
#include <cstdint>
namespace osrm namespace osrm
{ {
@ -35,17 +29,8 @@ struct Hint
facade.GetCheckSum() == data_checksum; facade.GetCheckSum() == data_checksum;
} }
std::string ToBase64() const { return encodeBase64(*this); } std::string ToBase64() const;
static Hint FromBase64(const std::string &base64Hint);
static Hint FromBase64(const std::string &base64Hint)
{
BOOST_ASSERT_MSG(base64Hint.size() ==
static_cast<std::size_t>(std::ceil(sizeof(Hint) / 3.) * 4),
"Hint has invalid size");
auto decoded = decodeBase64<Hint>(base64Hint);
return decoded;
}
}; };
#ifndef _MSC_VER #ifndef _MSC_VER

20
src/engine/hint.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "engine/hint.hpp"
#include "engine/object_encoder.hpp"
#include <boost/assert.hpp>
namespace osrm
{
namespace engine
{
std::string Hint::ToBase64() const { return encodeBase64(*this); }
Hint Hint::FromBase64(const std::string &base64Hint)
{
BOOST_ASSERT_MSG(base64Hint.size() == ENCODED_HINT_SIZE, "Hint has invalid size");
auto decoded = decodeBase64<Hint>(base64Hint);
return decoded;
}
}
}