mCRL2
Loading...
Searching...
No Matches
mcrl2::data::detail::data_property_map< Derived > Class Template Reference

Base class for storing properties of mCRL2 types. Properties are (key, value) pairs stored as strings in KEY = VALUE format. The data_property_map has some predefined functions for types in the Data Library. The optional type argument is used by derived classes. The type represents the name of a derived class as per CRTP. More...

#include <data_property_map.h>

Inheritance diagram for mcrl2::data::detail::data_property_map< Derived >:
mcrl2::lps::detail::specification_property_map< Specification >

Public Member Functions

 data_property_map (const std::string &text)
 The strings may appear in a random order, and not all of them need to be present.
 
std::string to_string () const
 Returns a string representation of the properties.
 
const std::map< std::string, std::string > & data () const
 Returns the stored properties.
 
std::string operator[] (const std::string &key) const
 Returns the value corresponding to key. Throws an exception if the key is not found.
 
std::string compare (const data_property_map &other) const
 Compares this property map with another property map. The function compare_property must be defined properly for all available properties.
 

Protected Member Functions

std::string print (std::size_t n) const
 
std::string print (std::string s) const
 
std::string print (const core::identifier_string &s) const
 
std::string print (const data::variable &v) const
 
template<typename Container >
std::string print (const Container &v, typename atermpp::enable_if_container< Container >::type *=nullptr) const
 
template<typename Container >
std::string print (const Container &v, bool print_separators, typename atermpp::enable_if_container< Container >::type *=nullptr) const
 
unsigned int parse_unsigned_int (std::string const &text) const
 
std::set< std::string > parse_set_string (std::string const &text) const
 
std::set< std::multiset< std::string > > parse_set_multiset_string (std::string const &text) const
 
std::string compare (const std::string &property, unsigned int x, unsigned int y) const
 Compares two integers, and returns a message if they are different. If if they are equal the empty string is returned.
 
template<typename T >
std::string compare (const std::string &property, const std::set< T > &x, const std::set< T > &y) const
 Compares two sets and returns a string with the differences encountered. Elements present in the first one but not in the second are printed with a '+' in front of it, elements present in the seconde but not in the first one with a '-' in front of it. A value x of the type T is printed using print(x), so this operation must be defined. If no differences are found the empty string is returned.
 
std::string compare_property (const std::string &property, const std::string &, const std::string &) const
 Compares two values x and y of a given property. This function should be redefined in derived classes.
 
unsigned int max_key_length () const
 Returns the maximum length of the property names.
 
std::string align (const std::string &s, unsigned int n) const
 
template<typename Container >
std::set< core::identifier_stringnames (const Container &v) const
 Collects the names of the elements of the container. The name of element x is retrieved by x.name().
 
 data_property_map ()
 Default constructor for derived types.
 
void parse_text (const std::string &text)
 Initializes the property map with text containing lines in KEY = VALUE format.
 

Static Protected Member Functions

template<typename Container >
static std::string add_separators (std::string const &c, typename std::enable_if< atermpp::is_set< Container >::value >::type *=nullptr)
 Add start/end separators for non-set container types.
 
template<typename Container >
static std::string add_separators (std::string const &c, typename std::enable_if< !atermpp::is_set< Container >::value >::type *=0)
 Add start/end separators for set container types.
 

Protected Attributes

std::map< std::string, std::string > m_data
 Contains a normalized string representation of the properties.
 

Detailed Description

template<typename Derived = void>
class mcrl2::data::detail::data_property_map< Derived >

Base class for storing properties of mCRL2 types. Properties are (key, value) pairs stored as strings in KEY = VALUE format. The data_property_map has some predefined functions for types in the Data Library. The optional type argument is used by derived classes. The type represents the name of a derived class as per CRTP.

Definition at line 33 of file data_property_map.h.

Constructor & Destructor Documentation

◆ data_property_map() [1/2]

template<typename Derived = void>
mcrl2::data::detail::data_property_map< Derived >::data_property_map ( )
inlineprotected

Default constructor for derived types.

Definition at line 225 of file data_property_map.h.

◆ data_property_map() [2/2]

template<typename Derived = void>
mcrl2::data::detail::data_property_map< Derived >::data_property_map ( const std::string &  text)
inline

The strings may appear in a random order, and not all of them need to be present.

Definition at line 247 of file data_property_map.h.

Member Function Documentation

◆ add_separators() [1/2]

template<typename Derived = void>
template<typename Container >
static std::string mcrl2::data::detail::data_property_map< Derived >::add_separators ( std::string const &  c,
typename std::enable_if< !atermpp::is_set< Container >::value >::type *  = 0 
)
inlinestaticprotected

Add start/end separators for set container types.

Definition at line 46 of file data_property_map.h.

◆ add_separators() [2/2]

template<typename Derived = void>
template<typename Container >
static std::string mcrl2::data::detail::data_property_map< Derived >::add_separators ( std::string const &  c,
typename std::enable_if< atermpp::is_set< Container >::value >::type *  = nullptr 
)
inlinestaticprotected

Add start/end separators for non-set container types.

Definition at line 39 of file data_property_map.h.

◆ align()

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::align ( const std::string &  s,
unsigned int  n 
) const
inlineprotected

Definition at line 202 of file data_property_map.h.

◆ compare() [1/3]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::compare ( const data_property_map< Derived > &  other) const
inline

Compares this property map with another property map. The function compare_property must be defined properly for all available properties.

Returns
A string describing the differences found.

Definition at line 286 of file data_property_map.h.

◆ compare() [2/3]

template<typename Derived = void>
template<typename T >
std::string mcrl2::data::detail::data_property_map< Derived >::compare ( const std::string &  property,
const std::set< T > &  x,
const std::set< T > &  y 
) const
inlineprotected

Compares two sets and returns a string with the differences encountered. Elements present in the first one but not in the second are printed with a '+' in front of it, elements present in the seconde but not in the first one with a '-' in front of it. A value x of the type T is printed using print(x), so this operation must be defined. If no differences are found the empty string is returned.

Definition at line 150 of file data_property_map.h.

◆ compare() [3/3]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::compare ( const std::string &  property,
unsigned int  x,
unsigned int  y 
) const
inlineprotected

Compares two integers, and returns a message if they are different. If if they are equal the empty string is returned.

Definition at line 132 of file data_property_map.h.

◆ compare_property()

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::compare_property ( const std::string &  property,
const std::string &  ,
const std::string &   
) const
inlineprotected

Compares two values x and y of a given property. This function should be redefined in derived classes.

Returns
An empty string if the two values are equal, otherwise a string indicating the differences between the two.

Definition at line 183 of file data_property_map.h.

◆ data()

template<typename Derived = void>
const std::map< std::string, std::string > & mcrl2::data::detail::data_property_map< Derived >::data ( ) const
inline

Returns the stored properties.

Definition at line 265 of file data_property_map.h.

◆ max_key_length()

template<typename Derived = void>
unsigned int mcrl2::data::detail::data_property_map< Derived >::max_key_length ( ) const
inlineprotected

Returns the maximum length of the property names.

Definition at line 192 of file data_property_map.h.

◆ names()

template<typename Derived = void>
template<typename Container >
std::set< core::identifier_string > mcrl2::data::detail::data_property_map< Derived >::names ( const Container &  v) const
inlineprotected

Collects the names of the elements of the container. The name of element x is retrieved by x.name().

Definition at line 214 of file data_property_map.h.

◆ operator[]()

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::operator[] ( const std::string &  key) const
inline

Returns the value corresponding to key. Throws an exception if the key is not found.

Definition at line 272 of file data_property_map.h.

◆ parse_set_multiset_string()

template<typename Derived = void>
std::set< std::multiset< std::string > > mcrl2::data::detail::data_property_map< Derived >::parse_set_multiset_string ( std::string const &  text) const
inlineprotected

Definition at line 113 of file data_property_map.h.

◆ parse_set_string()

template<typename Derived = void>
std::set< std::string > mcrl2::data::detail::data_property_map< Derived >::parse_set_string ( std::string const &  text) const
inlineprotected

Definition at line 106 of file data_property_map.h.

◆ parse_text()

template<typename Derived = void>
void mcrl2::data::detail::data_property_map< Derived >::parse_text ( const std::string &  text)
inlineprotected

Initializes the property map with text containing lines in KEY = VALUE format.

Definition at line 231 of file data_property_map.h.

◆ parse_unsigned_int()

template<typename Derived = void>
unsigned int mcrl2::data::detail::data_property_map< Derived >::parse_unsigned_int ( std::string const &  text) const
inlineprotected

Definition at line 101 of file data_property_map.h.

◆ print() [1/6]

template<typename Derived = void>
template<typename Container >
std::string mcrl2::data::detail::data_property_map< Derived >::print ( const Container &  v,
bool  print_separators,
typename atermpp::enable_if_container< Container >::type *  = nullptr 
) const
inlineprotected

Definition at line 93 of file data_property_map.h.

◆ print() [2/6]

template<typename Derived = void>
template<typename Container >
std::string mcrl2::data::detail::data_property_map< Derived >::print ( const Container &  v,
typename atermpp::enable_if_container< Container >::type *  = nullptr 
) const
inlineprotected

Definition at line 80 of file data_property_map.h.

◆ print() [3/6]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::print ( const core::identifier_string s) const
inlineprotected

Definition at line 69 of file data_property_map.h.

◆ print() [4/6]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::print ( const data::variable v) const
inlineprotected

Definition at line 74 of file data_property_map.h.

◆ print() [5/6]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::print ( std::size_t  n) const
inlineprotected

Definition at line 57 of file data_property_map.h.

◆ print() [6/6]

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::print ( std::string  s) const
inlineprotected

Definition at line 64 of file data_property_map.h.

◆ to_string()

template<typename Derived = void>
std::string mcrl2::data::detail::data_property_map< Derived >::to_string ( ) const
inline

Returns a string representation of the properties.

Definition at line 253 of file data_property_map.h.

Member Data Documentation

◆ m_data

template<typename Derived = void>
std::map<std::string, std::string> mcrl2::data::detail::data_property_map< Derived >::m_data
protected

Contains a normalized string representation of the properties.

Definition at line 52 of file data_property_map.h.


The documentation for this class was generated from the following file: