/**
- * 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:
* ps.push_back(std::unique_ptr<Patterns::Double>());
* ps.push_back(std::unique_ptr<Patterns::Anything>());
*
- * 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
* Constructor.
*/
Tuple (const std::vector<std::unique_ptr<PatternBase> > &patterns,
- const std::string &separator = ",");
+ const std::string &separator = ":");
/**
* Constructor. Same as above, specialized for const char *. This is
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...)
{}
Tuple::Tuple(const PatternTypes &... ps)
:
// forward to the version with the separator argument
- Tuple (std::string(","), ps...)
+ Tuple (std::string(":"), ps...)
{}
<< patterns[i]->description(style)
<< ">";
- if (separator != ",")
+ if (separator != ":")
description << " separated by <" << separator << ">";
description << "]";
description << "A Tuple of "
<< patterns.size()
<< " elements ";
- if (separator != ",")
+ if (separator != ":")
description << " separated by <" << separator << "> ";
description << " where each element is ["
<< patterns[0]->description(style)
if (is)
std::getline(is, separator, '>');
else
- separator = ",";
+ separator = ":";
return std::unique_ptr<Tuple>(new Tuple(patterns,separator));
}