Removed Boost dependency in language distinction.

As Boost isn’t used in the rest of this project anymore, this commit
removes the unnecessary dependency to boost::bimap just for language
detection, and replaces it with a simple std::map instead.
This commit is contained in:
Patrick Lühne 2017-10-28 15:44:37 +02:00
parent 1631a70a0b
commit 72fc7493b2
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
4 changed files with 10 additions and 31 deletions

View File

@ -23,7 +23,6 @@ class Language
SAS SAS
}; };
static std::string toString(Type language);
static Language::Type fromString(const std::string &languageName); static Language::Type fromString(const std::string &languageName);
public: public:

View File

@ -13,7 +13,6 @@ file(GLOB sas_sources "plasp/sas/*.cpp")
file(GLOB sas_headers "../include/plasp/sas/*.h") file(GLOB sas_headers "../include/plasp/sas/*.h")
set(includes set(includes
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/lib/tokenize/include ${PROJECT_SOURCE_DIR}/lib/tokenize/include
${PROJECT_SOURCE_DIR}/lib/colorlog/include ${PROJECT_SOURCE_DIR}/lib/colorlog/include
@ -48,7 +47,6 @@ set(sources
) )
set(libraries set(libraries
${Boost_LIBRARIES}
colorlog colorlog
pddl pddl
pthread pthread

View File

@ -1,7 +1,6 @@
#include <plasp/Language.h> #include <plasp/Language.h>
#include <boost/assign.hpp> #include <map>
#include <boost/bimap.hpp>
namespace plasp namespace plasp
{ {
@ -12,38 +11,23 @@ namespace plasp
// //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
using LanguageNames = boost::bimap<Language::Type, std::string>; static const std::map<std::string, Language::Type> languageNames =
////////////////////////////////////////////////////////////////////////////////////////////////////
const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation>
(Language::Type::Automatic, "auto")
(Language::Type::PDDL, "pddl")
(Language::Type::SAS, "sas")
(Language::Type::Unknown, "unknown");
////////////////////////////////////////////////////////////////////////////////////////////////////
std::string Language::toString(Language::Type language)
{ {
const auto match = languageNames.left.find(language); {"auto", Language::Type::Automatic},
{"pddl", Language::Type::PDDL},
if (match == languageNames.left.end()) {"sas", Language::Type::SAS},
return "unknown"; };
return match->second;
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
Language::Type Language::fromString(const std::string &languageName) Language::Type Language::fromString(const std::string &languageName)
{ {
const auto match = languageNames.right.find(languageName); const auto matchingLanguageName = languageNames.find(languageName);
if (match == languageNames.right.end()) if (matchingLanguageName == languageNames.cend())
return Language::Type::Unknown; return Language::Type::Unknown;
return match->second; return matchingLanguageName->second;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -3,7 +3,6 @@ set(target tests)
file(GLOB core_sources "*.cpp") file(GLOB core_sources "*.cpp")
set(includes set(includes
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/lib/catch/single_include ${PROJECT_SOURCE_DIR}/lib/catch/single_include
${PROJECT_SOURCE_DIR}/lib/tokenize/include ${PROJECT_SOURCE_DIR}/lib/tokenize/include
@ -14,7 +13,6 @@ set(includes
set(libraries set(libraries
stdc++fs stdc++fs
${Boost_LIBRARIES}
plasp plasp
) )