From: Luca Heltai Date: Fri, 27 Oct 2017 11:57:54 +0000 (+0200) Subject: Changed default separator for tuple to ":" X-Git-Tag: v9.0.0-rc1~848^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7aad2e401b2b671980ea2aeb3b48ec3c5cce282;p=dealii.git Changed default separator for tuple to ":" --- diff --git a/include/deal.II/base/patterns.h b/include/deal.II/base/patterns.h index d694d4e1b4..cbadcfdb18 100644 --- a/include/deal.II/base/patterns.h +++ b/include/deal.II/base/patterns.h @@ -664,7 +664,7 @@ namespace Patterns /** - * This pattern matches comma-separated values of arbitrary types. Each type + * This pattern matches column-separated values of arbitrary types. Each type * has to match a pattern given to the constructor. * * An example usage is the following: @@ -676,14 +676,17 @@ namespace Patterns * ps.push_back(std::unique_ptr()); * ps.push_back(std::unique_ptr()); * - * Patterns::Tuple pattern(ps, ";"); + * Patterns::Tuple pattern(ps, ":"); * - * bool check = ps.match("5; 3.14; Ciao"); // check = true + * bool check = ps.match("5: 3.14: Ciao"); // check = true * @endcode * * The constructor expects a vector of Patterns, and optionally a string * specifying the separator to use when parsing the Tuple from a string. * + * The default separator is the semicolumn, owing to the fact that a pair + * is in fact a tuple with two elements. + * * @author Luca Heltai, 2017. */ class Tuple : public PatternBase @@ -698,7 +701,7 @@ namespace Patterns * Constructor. */ Tuple (const std::vector > &patterns, - const std::string &separator = ","); + const std::string &separator = ":"); /** * Constructor. Same as above, specialized for const char *. This is @@ -1256,7 +1259,7 @@ namespace Patterns Tuple::Tuple(const char *separator, const PatternTypes &... ps) : - // simply forward to the std::string version + // forward to the version with std::string argument Tuple (std::string(separator), ps...) {} @@ -1282,7 +1285,7 @@ namespace Patterns Tuple::Tuple(const PatternTypes &... ps) : // forward to the version with the separator argument - Tuple (std::string(","), ps...) + Tuple (std::string(":"), ps...) {} diff --git a/source/base/patterns.cc b/source/base/patterns.cc index 7c529584cc..502ef9c35d 100644 --- a/source/base/patterns.cc +++ b/source/base/patterns.cc @@ -1020,7 +1020,7 @@ namespace Patterns << patterns[i]->description(style) << ">"; - if (separator != ",") + if (separator != ":") description << " separated by <" << separator << ">"; description << "]"; @@ -1034,7 +1034,7 @@ namespace Patterns description << "A Tuple of " << patterns.size() << " elements "; - if (separator != ",") + if (separator != ":") description << " separated by <" << separator << "> "; description << " where each element is [" << patterns[0]->description(style) @@ -1108,7 +1108,7 @@ namespace Patterns if (is) std::getline(is, separator, '>'); else - separator = ","; + separator = ":"; return std::unique_ptr(new Tuple(patterns,separator)); } diff --git a/tests/base/patterns_11.cc b/tests/base/patterns_11.cc index 9a99dbde0d..8a76f93a09 100644 --- a/tests/base/patterns_11.cc +++ b/tests/base/patterns_11.cc @@ -29,7 +29,7 @@ int main() deallog << desc << std::endl; - std::string test = "3.14, Ciao"; + std::string test = "3.14: Ciao"; if (pattern.match(test)) deallog << "OK" << std::endl;