Implemented automatic language detection for plasp application.
This commit is contained in:
50
src/plasp/Language.cpp
Normal file
50
src/plasp/Language.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <plasp/Language.h>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bimap.hpp>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Language
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using LanguageNames = boost::bimap<Language::Type, std::string>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation>
|
||||
(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);
|
||||
|
||||
if (match != languageNames.left.end())
|
||||
return "Unknown";
|
||||
|
||||
return match->second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Language::Type Language::fromString(const std::string &languageName)
|
||||
{
|
||||
const auto match = languageNames.right.find(languageName);
|
||||
|
||||
if (match != languageNames.right.end())
|
||||
return Language::Type::Unknown;
|
||||
|
||||
return match->second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
@@ -33,6 +33,8 @@ Description::Description()
|
||||
|
||||
Description Description::fromParser(utils::Parser &&parser)
|
||||
{
|
||||
parser.setCaseSensitive(false);
|
||||
|
||||
Description description;
|
||||
|
||||
description.m_parser = std::move(parser);
|
||||
|
@@ -30,6 +30,8 @@ Description::Description()
|
||||
|
||||
Description Description::fromParser(utils::Parser &&parser)
|
||||
{
|
||||
parser.setCaseSensitive(true);
|
||||
|
||||
Description description;
|
||||
description.parseContent(parser);
|
||||
|
||||
|
Reference in New Issue
Block a user