Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Patterns::Tuple Class Reference

#include <deal.II/base/patterns.h>

Inheritance diagram for Patterns::Tuple:
[legend]

Public Member Functions

 Tuple (const std::vector< std::unique_ptr< PatternBase >> &patterns, const std::string &separator=":")
 
 Tuple (const std::vector< std::unique_ptr< PatternBase >> &patterns, const char *separator)
 
template<class... PatternTypes>
 Tuple (const std::string &separator, const PatternTypes &... patterns)
 
template<class... PatternTypes>
 Tuple (const char *separator, const PatternTypes &... patterns)
 
template<typename... Patterns>
 Tuple (const Patterns &... patterns)
 
 Tuple (const Tuple &other)
 
virtual bool match (const std::string &test_string) const override
 
virtual std::string description (const OutputStyle style=Machine) const override
 
virtual std::unique_ptr< PatternBaseclone () const override
 
std::size_t memory_consumption () const override
 
const PatternBaseget_pattern (const unsigned int i) const
 
const std::string & get_separator () const
 
template<class... PatternTypes>
 Tuple (const PatternTypes &... ps)
 
- Public Member Functions inherited from Patterns::PatternBase
virtual ~PatternBase ()=default
 
virtual std::string description (const OutputStyle style=Machine) const =0
 

Static Public Member Functions

static std::unique_ptr< Tuplecreate (const std::string &description)
 

Private Attributes

std::vector< std::unique_ptr< PatternBase > > patterns
 
const std::string separator
 

Static Private Attributes

static const char * description_init = "[Tuple"
 

Additional Inherited Members

- Public Types inherited from Patterns::PatternBase
enum  OutputStyle { Machine, Text, LaTeX }
 

Detailed Description

This pattern matches colon-separated values of arbitrary types. Each type has to match a pattern given to the constructor.

An example usage is the following:

std::vector< std::unique_ptr<Patterns::PatternBase> > ps;
ps.push_back(std::unique_ptr<Patterns::Integer>());
ps.push_back(std::unique_ptr<Patterns::Double>());
ps.push_back(std::unique_ptr<Patterns::Anything>());
Patterns::Tuple pattern(ps, ":");
bool check = ps.match("5 : 3.14 : Ciao"); // check = true

or, if you want to exploit ParameterHandler::add_parameter():

using T = std::tuple<std::string, Point<3>, unsigned int>;
T a = Patterns::Tools::Convert<T>::to_value("Ciao : 1.0, 2.0, 3.0 : 33");
prm.add_parameter("A tuple", a);
// DEAL:parameters::A tuple: Ciao : 1.000000, 2.000000, 3.000000 : 33
prm.set("A tuple", "Mondo : 2.0, 3.0, 4.0 : 34");
// DEAL:parameters::A tuple: Mondo : 2.0, 3.0, 4.0 : 34
// DEAL::Mondo : 2.000000, 3.000000, 4.000000 : 34

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 a colon, owing to the fact that a pair is in fact a tuple with two elements.

Author
Luca Heltai, 2017.

Definition at line 774 of file patterns.h.


The documentation for this class was generated from the following files:
Patterns::Tuple
Definition: patterns.h:774
Patterns::Tools::to_string
std::string to_string(const T &t)
Definition: patterns.h:2360
deallog
LogStream deallog
Definition: logstream.cc:37
LAPACKSupport::T
static const char T
Definition: lapack_support.h:163
ParameterHandler::log_parameters
void log_parameters(LogStream &out, const OutputStyle style=DefaultStyle)
Definition: parameter_handler.cc:1745
Patterns::Tools::Convert::to_value
static T to_value(const std::string &s, const std::unique_ptr< Patterns::PatternBase > &p=Convert< T >::to_pattern())=delete
ParameterHandler::add_parameter
void add_parameter(const std::string &entry, ParameterType &parameter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
Definition: parameter_handler.h:2328
ParameterHandler
Definition: parameter_handler.h:845
ParameterHandler::set
void set(const std::string &entry_name, const std::string &new_value)
Definition: parameter_handler.cc:1140