*/
std::unique_ptr<PatternBase> pattern_factory (const std::string &description);
- /**
- * Escape the string @p input for the specified @p style so that characters
- * will appear as intended. For example, characters like _ can not be
- * written as is in LateX and have to be escaped as \_.
- */
- std::string escape(const std::string &input, const PatternBase::OutputStyle style);
+ namespace internal
+ {
+ /**
+ * Escape the string @p input for the specified @p style so that characters
+ * will appear as intended. For example, characters like _ can not be
+ * written as is in LateX and have to be escaped as \_.
+ */
+ std::string escape(const std::string &input, const PatternBase::OutputStyle style);
+ }
/**
* Test for the string being an integer. If bounds are given to the
{
auto escape = [] (const std::string &input)
{
- return Patterns::escape(input, Patterns::PatternBase::LaTeX);
+ return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX);
};
// if there are any parameters in this section then print them
{
auto escape = [] (const std::string &input)
{
- return Patterns::escape(input, Patterns::PatternBase::LaTeX);
+ return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX);
};
out << '\n'
{
auto escape = [] (const std::string &input)
{
- return Patterns::escape(input, Patterns::PatternBase::LaTeX);
+ return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX);
};
// if there are any parameters in this section then print them
{
auto escape = [] (const std::string &input)
{
- return Patterns::escape(input, Patterns::PatternBase::LaTeX);
+ return Patterns::internal::escape(input, Patterns::PatternBase::LaTeX);
};
out << std::endl
namespace Patterns
{
+
+ namespace internal
+ {
+
+
+ std::string escape(const std::string &input, const PatternBase::OutputStyle style)
+ {
+ switch (style)
+ {
+ case PatternBase::Machine:
+ case PatternBase::Text:
+ return input;
+ case PatternBase::LaTeX:
+ {
+ std::string u;
+ u.reserve (input.size());
+ for (auto c : input)
+ {
+ switch (c)
+ {
+ case '#':
+ case '$':
+ case '%':
+ case '&':
+ case '_':
+ case '{':
+ case '}':
+ // simple escaping:
+ u.push_back('\\');
+ u.push_back(c);
+ break;
+
+ case '\\':
+ u.append("\\textbackslash{}");
+ break;
+
+ case '^':
+ u.append("\\^{}");
+ break;
+
+ case '~':
+ u.append("\\~{}");
+ break;
+
+ default:
+ // all other chars are just copied:
+ u.push_back(c);
+ }
+ }
+ return u;
+ }
+ default:
+ Assert(false, ExcNotImplemented());
+ }
+ return "";
+ }
+
+ }
+
+
namespace
{
/**
- std::string escape(const std::string &input, const PatternBase::OutputStyle style)
- {
- switch (style)
- {
- case PatternBase::Machine:
- case PatternBase::Text:
- return input;
- case PatternBase::LaTeX:
- {
- std::string u;
- u.reserve (input.size());
- for (auto c : input)
- {
- switch (c)
- {
- case '#':
- case '$':
- case '%':
- case '&':
- case '_':
- case '{':
- case '}':
- // simple escaping:
- u.push_back('\\');
- u.push_back(c);
- break;
-
- case '\\':
- u.append("\\textbackslash{}");
- break;
-
- case '^':
- u.append("\\^{}");
- break;
-
- case '~':
- u.append("\\~{}");
- break;
-
- default:
- // all other chars are just copied:
- u.push_back(c);
- }
- }
- return u;
- }
- default:
- Assert(false, ExcNotImplemented());
- }
- return "";
- }
-
-
-
std::unique_ptr<PatternBase> pattern_factory(const std::string &description)
{
std::unique_ptr<PatternBase> p;
std::ostringstream description;
description << "Any one of "
- << escape(Utilities::replace_in_string(sequence,"|",", "), style);
+ << internal::escape(Utilities::replace_in_string(sequence,"|",", "), style);
return description.str();
}
<< " elements ";
if (separator != ",")
description << "separated by <"
- << escape(separator, style)
+ << internal::escape(separator, style)
<< "> ";
description << "where each element is ["
<< pattern->description(style)
std::ostringstream description;
description << "A key"
- << escape(key_value_separator, style)
+ << internal::escape(key_value_separator, style)
<< "value map of "
<< min_elements << " to " << max_elements
<< " elements ";
if (separator != ",")
- description << " separated by <" << escape(separator, style) << "> ";
+ description << " separated by <" << internal::escape(separator, style) << "> ";
description << " where each key is ["
<< key_pattern->description(style)
<< "]"
<< patterns.size()
<< " elements ";
if (separator != ":")
- description << " separated by <" << escape(separator, style) << "> ";
+ description << " separated by <" << internal::escape(separator, style) << "> ";
description << " where each element is ["
<< patterns[0]->description(style)
<< "]";
for (unsigned int i=1; i<patterns.size(); ++i)
{
- description << escape(separator, style)
+ description << internal::escape(separator, style)
<< "[" << patterns[i]->description(style) << "]";
}
std::ostringstream description;
description << "A comma-separated list of any of "
- << escape(Utilities::replace_in_string(sequence,"|",", "), style);
+ << internal::escape(Utilities::replace_in_string(sequence,"|",", "), style);
return description.str();
}