Refactored color output of headings.
This commit is contained in:
parent
583ec78eef
commit
1e21457efb
@ -39,9 +39,6 @@ class TranslatorASP
|
||||
void translateLiteral(const Expression &literal) const;
|
||||
void translatePredicate(const expressions::Predicate &predicate) const;
|
||||
|
||||
void printHeading1(const std::string &heading) const;
|
||||
void printHeading2(const std::string &heading) const;
|
||||
|
||||
const Description &m_description;
|
||||
utils::LogStream &m_outputStream;
|
||||
};
|
||||
|
@ -81,9 +81,9 @@ inline LogStream &operator<<(LogStream &stream, const ResetFormat &)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Keyword
|
||||
struct Token
|
||||
{
|
||||
Keyword(const std::string &name)
|
||||
Token(const std::string &name)
|
||||
: name(name)
|
||||
{
|
||||
}
|
||||
@ -93,6 +93,16 @@ struct Keyword
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Keyword: public Token
|
||||
{
|
||||
Keyword(const std::string &name)
|
||||
: Token(name)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline LogStream &operator<<(LogStream &stream, const Keyword &keyword)
|
||||
{
|
||||
return (stream
|
||||
@ -103,14 +113,12 @@ inline LogStream &operator<<(LogStream &stream, const Keyword &keyword)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Variable
|
||||
struct Variable: public Token
|
||||
{
|
||||
Variable(const std::string &name)
|
||||
: name(name)
|
||||
: Token(name)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string &name;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -123,6 +131,50 @@ inline LogStream &operator<<(LogStream &stream, const Variable &variable)
|
||||
<< utils::ResetFormat());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Heading1: public Token
|
||||
{
|
||||
Heading1(const std::string &name)
|
||||
: Token(name)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline LogStream &operator<<(LogStream &stream, const Heading1 &heading1)
|
||||
{
|
||||
return (stream
|
||||
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||
<< "%---------------------------------------" << std::endl
|
||||
<< "% " << heading1.name << std::endl
|
||||
<< "%---------------------------------------"
|
||||
<< utils::ResetFormat()
|
||||
<< std::endl);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct Heading2: public Token
|
||||
{
|
||||
Heading2(const std::string &name)
|
||||
: Token(name)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline LogStream &operator<<(LogStream &stream, const Heading2 &heading2)
|
||||
{
|
||||
return (stream
|
||||
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||
<< "% " << heading2.name
|
||||
<< utils::ResetFormat());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void TranslatorASP::translate() const
|
||||
|
||||
void TranslatorASP::translateDomain() const
|
||||
{
|
||||
printHeading1("domain");
|
||||
m_outputStream << utils::Heading1("domain");
|
||||
|
||||
const auto &domain = m_description.domain();
|
||||
|
||||
@ -77,7 +77,7 @@ void TranslatorASP::translateDomain() const
|
||||
|
||||
void TranslatorASP::translateTypes() const
|
||||
{
|
||||
printHeading2("types");
|
||||
m_outputStream << utils::Heading2("types");
|
||||
|
||||
m_outputStream << std::endl;
|
||||
|
||||
@ -120,7 +120,7 @@ void TranslatorASP::translateTypes() const
|
||||
|
||||
void TranslatorASP::translatePredicates() const
|
||||
{
|
||||
printHeading2("predicates");
|
||||
m_outputStream << utils::Heading2("predicates");
|
||||
|
||||
const auto &predicates = m_description.domain().predicates();
|
||||
|
||||
@ -147,7 +147,7 @@ void TranslatorASP::translatePredicates() const
|
||||
|
||||
void TranslatorASP::translateActions() const
|
||||
{
|
||||
printHeading2("actions");
|
||||
m_outputStream << utils::Heading2("actions");
|
||||
|
||||
const auto &actions = m_description.domain().actions();
|
||||
|
||||
@ -251,7 +251,7 @@ void TranslatorASP::translateActions() const
|
||||
|
||||
void TranslatorASP::translateConstants(const std::string &heading, const expressions::Constants &constants) const
|
||||
{
|
||||
printHeading2(heading);
|
||||
m_outputStream << utils::Heading2(heading);
|
||||
|
||||
std::for_each(constants.cbegin(), constants.cend(),
|
||||
[&](const auto &constant)
|
||||
@ -405,7 +405,7 @@ void TranslatorASP::translateProblem() const
|
||||
{
|
||||
BOOST_ASSERT(m_description.containsProblem());
|
||||
|
||||
printHeading1("problem");
|
||||
m_outputStream << utils::Heading1("problem");
|
||||
|
||||
const auto &problem = m_description.problem();
|
||||
|
||||
@ -431,7 +431,7 @@ void TranslatorASP::translateInitialState() const
|
||||
{
|
||||
BOOST_ASSERT(m_description.containsProblem());
|
||||
|
||||
printHeading2("initial state");
|
||||
m_outputStream << utils::Heading2("initial state");
|
||||
|
||||
const auto &initialStateFacts = m_description.problem().initialState().facts();
|
||||
|
||||
@ -466,7 +466,7 @@ void TranslatorASP::translateGoal() const
|
||||
{
|
||||
BOOST_ASSERT(m_description.containsProblem());
|
||||
|
||||
printHeading2("goal");
|
||||
m_outputStream << utils::Heading2("goal");
|
||||
|
||||
const auto &goal = m_description.problem().goal();
|
||||
|
||||
@ -501,28 +501,5 @@ void TranslatorASP::translateGoal() const
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TranslatorASP::printHeading1(const std::string &heading) const
|
||||
{
|
||||
m_outputStream
|
||||
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||
<< "%---------------------------------------" << std::endl
|
||||
<< "% " << heading << std::endl
|
||||
<< "%---------------------------------------"
|
||||
<< utils::ResetFormat()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TranslatorASP::printHeading2(const std::string &heading) const
|
||||
{
|
||||
m_outputStream
|
||||
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||
<< "% " << heading
|
||||
<< utils::ResetFormat();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user