SLHAea
0.1
containers for SUSY Les Houches Accord input/output
|
Container of Lines that resembles a block in a SLHA structure. More...
#include <slhaea.h>
Classes | |
struct | key_matches |
Unary predicate that checks if a provided key matches a Line. More... | |
Public Types | |
typedef std::vector< std::string > | key_type |
typedef Line | value_type |
typedef Line & | reference |
typedef const Line & | const_reference |
typedef impl_type::iterator | iterator |
typedef impl_type::const_iterator | const_iterator |
typedef impl_type::reverse_iterator | reverse_iterator |
typedef impl_type::const_reverse_iterator | const_reverse_iterator |
typedef impl_type::pointer | pointer |
typedef impl_type::const_pointer | const_pointer |
typedef impl_type::difference_type | difference_type |
typedef impl_type::size_type | size_type |
Public Member Functions | |
Block (const std::string &name="") | |
Constructs an empty Block. More... | |
Block (std::istream &is) | |
Constructs a Block with content from an input stream. More... | |
void | name (const std::string &newName) |
Sets the name of the Block. More... | |
const std::string & | name () const |
Returns the name of the Block. More... | |
void | rename (const std::string &newName) |
Changes the name and definition of the Block. More... | |
Block & | read (std::istream &is) |
Assigns content from an input stream to the Block. More... | |
Block & | str (const std::string &block) |
Assigns content from a string to the Block. More... | |
std::string | str () const |
Returns a string representation of the Block. More... | |
reference | operator[] (const key_type &key) |
Locates a Line in the Block. More... | |
reference | operator[] (const std::vector< int > &key) |
Locates a Line in the Block. More... | |
reference | operator[] (const std::string &key) |
Locates a Line in the Block. More... | |
reference | operator[] (int key) |
Locates a Line in the Block. More... | |
reference | at (const key_type &key) |
Locates a Line in the Block. More... | |
const_reference | at (const key_type &key) const |
Locates a Line in the Block. More... | |
reference | at (const std::vector< int > &key) |
Locates a Line in the Block. More... | |
const_reference | at (const std::vector< int > &key) const |
Locates a Line in the Block. More... | |
reference | at (const std::string &s0, const std::string &s1="", const std::string &s2="", const std::string &s3="", const std::string &s4="") |
Locates a Line in the Block. More... | |
const_reference | at (const std::string &s0, const std::string &s1="", const std::string &s2="", const std::string &s3="", const std::string &s4="") const |
Locates a Line in the Block. More... | |
reference | at (int i0, int i1=no_index_, int i2=no_index_, int i3=no_index_, int i4=no_index_) |
Locates a Line in the Block. More... | |
const_reference | at (int i0, int i1=no_index_, int i2=no_index_, int i3=no_index_, int i4=no_index_) const |
Locates a Line in the Block. More... | |
reference | front () |
Returns a read/write reference to the first element of the Block. More... | |
const_reference | front () const |
Returns a read-only (constant) reference to the first element of the Block. More... | |
reference | back () |
Returns a read/write reference to the last element of the Block. More... | |
const_reference | back () const |
Returns a read-only (constant) reference to the last element of the Block. More... | |
iterator | begin () |
Returns a read/write iterator that points to the first element in the Block. More... | |
const_iterator | begin () const |
Returns a read-only (constant) iterator that points to the first element in the Block. More... | |
const_iterator | cbegin () const |
Returns a read-only (constant) iterator that points to the first element in the Block. More... | |
iterator | end () |
Returns a read/write iterator that points one past the last element in the Block. More... | |
const_iterator | end () const |
Returns a read-only (constant) iterator that points one past the last element in the Block. More... | |
const_iterator | cend () const |
Returns a read-only (constant) iterator that points one past the last element in the Block. More... | |
reverse_iterator | rbegin () |
Returns a read/write reverse iterator that points to the last element in the Block. More... | |
const_reverse_iterator | rbegin () const |
Returns a read-only (constant) reverse iterator that points to the last element in the Block. More... | |
const_reverse_iterator | crbegin () const |
Returns a read-only (constant) reverse iterator that points to the last element in the Block. More... | |
reverse_iterator | rend () |
Returns a read/write reverse iterator that points to one before the first element in the Block. More... | |
const_reverse_iterator | rend () const |
Returns a read-only (constant) reverse iterator that points to one before the first element in the Block. More... | |
const_reverse_iterator | crend () const |
Returns a read-only (constant) reverse iterator that points to one before the first element in the Block. More... | |
iterator | find (const key_type &key) |
Tries to locate a Line in the Block. More... | |
const_iterator | find (const key_type &key) const |
Tries to locate a Line in the Block. More... | |
iterator | find_block_def () |
Returns a read/write iterator that points to the first Line in the Block which is a block definition. More... | |
const_iterator | find_block_def () const |
Returns a read-only (constant) iterator that points to the first Line in the Block which is a block definition. More... | |
size_type | count (const key_type &key) const |
Counts all Lines that match a given key. More... | |
size_type | size () const |
Returns the number of elements in the Block. More... | |
size_type | data_size () const |
Returns the number of data Lines in the Block. More... | |
size_type | max_size () const |
Returns the size() of the largest possible Block. More... | |
bool | empty () const |
Returns true if the Block is empty. More... | |
void | push_back (const value_type &line) |
Adds a Line to the end of the Block. More... | |
void | push_back (const std::string &line) |
Adds a Line to the end of the Block. More... | |
void | pop_back () |
Removes the last element. More... | |
iterator | insert (iterator position, const value_type &line) |
Inserts a Line before given position . More... | |
template<class InputIterator > | |
void | insert (iterator position, InputIterator first, InputIterator last) |
Inserts a range into the Block. More... | |
iterator | erase (iterator position) |
Erases element at given position . More... | |
iterator | erase (iterator first, iterator last) |
Erases a range of elements. More... | |
iterator | erase_first (const key_type &key) |
Erases first Line that matches the provided key. More... | |
iterator | erase_last (const key_type &key) |
Erases last Line that matches the provided key. More... | |
size_type | erase (const key_type &key) |
Erases all Lines that match the provided key. More... | |
void | swap (Block &block) |
Swaps data with another Block. More... | |
void | clear () |
Erases all the elements in the Block and set its name to an empty string. More... | |
void | reformat () |
Reformats all Lines in the Block. More... | |
void | comment () |
Comments all Lines in the Block. More... | |
void | uncomment () |
Uncomments all Lines in the Block. More... | |
Static Public Member Functions | |
static Block | from_str (const std::string &block) |
Constructs a Block with content from a string. More... | |
template<class InputIterator > | |
static InputIterator | find (InputIterator first, InputIterator last, const key_type &key) |
Tries to locate a Line in a range. More... | |
Container of Lines that resembles a block in a SLHA structure.
This class is a named container of Lines that resembles a block in a SLHA structure. Unlike a block in a SLHA structure, a Block can contain any number of block definitions or it can be completely empty.
Access to the elements of the Block is provided by the operator[]() and at() functions. These take one or more strings resp. ints as argument(s) and compare them against the first strings of the contained Lines (the ints are converted to strings before comparison). The first Line that matches the provided arguments is then returned, or if no matching Line is found, an empty Line is appended to the Block (operator[]()) or std::out_of_range
is thrown (at()). The special argument "(any)"
will be considered equal to all strings in the Lines. For example, at("(any)", "2")
returns the first Line whose second element is "2"
.
typedef std::vector<std::string> key_type |
typedef Line value_type |
typedef const Line& const_reference |
typedef impl_type::iterator iterator |
typedef impl_type::const_iterator const_iterator |
typedef impl_type::reverse_iterator reverse_iterator |
typedef impl_type::const_reverse_iterator const_reverse_iterator |
typedef impl_type::pointer pointer |
typedef impl_type::const_pointer const_pointer |
typedef impl_type::difference_type difference_type |
typedef impl_type::size_type size_type |
|
inlineexplicit |
Constructs an empty Block.
name | Name of the Block. |
|
inlineexplicit |
Constructs a Block with content from an input stream.
is | Input stream to read content from. |
|
inlinestatic |
Constructs a Block with content from a string.
block | String to read content from. |
|
inline |
Sets the name of the Block.
newName | New name of the Block. |
Notice that this function only changes a property of the Block. No contained Line (in particular no block definition) is changed.
|
inline |
Returns the name of the Block.
|
inline |
Changes the name and definition of the Block.
newName | New name of the Block. |
In contrast to name() this function changes the name of the Block and its first block definition (if it exists).
|
inline |
Assigns content from an input stream to the Block.
is | Input stream to read content from. |
*this
.This function reads non-empty lines from is
, transforms them into Lines and adds them to the end of the Block. Lines from is
are read until the second block definition is encountered or until the end of the stream, whatever comes first. If is
contains a block definition and the current name of the Block is empty, it is changed accordingly.
|
inline |
Assigns content from a string to the Block.
block | String that is used as content for the Block. |
*this
.This function clears the name and content of the Block and adds every non-empty line found in block
as Line to the end of the Block. If block
contains a block definition, the name of the Block is set accordingly. If block
contains more than two block definitions, only the lines before the second block definition are added to the Block.
|
inline |
Returns a string representation of the Block.
Locates a Line in the Block.
key | First strings of the Line to be located. |
This function takes a key (which is a vector of strings) and locates the Line whose first strings are equal to the strings in key
. If no such Line exists, this function creates an empty Line at the end of the Block and returns a reference to it.
|
inline |
Locates a Line in the Block.
key | Integers that are used to locate the Line. |
This function takes a key (which is a vector of ints) and locates the Line whose first strings are equal to the to strings converted ints in key
. If no such Line exists, this function creates an empty Line at the end of the Block and returns a reference to it.
|
inline |
Locates a Line in the Block.
key | String that is used to locate the Line. |
This function locates the Line whose first string is equal to key
. If no such Line exists, this function creates an empty Line at the end of the Block and returns a reference to it.
|
inline |
Locates a Line in the Block.
key | Integer that is used to locate the Line. |
This function locates the Line whose first string is equal to the to string converted key
. If no such Line exists, this function creates an empty Line at the end of the Block and returns a reference to it.
Locates a Line in the Block.
key | First strings of the Line to be located. |
std::out_of_range | If key does not match any Line. |
This function takes a key (which is a vector of strings) and locates the Line whose first strings are equal to the strings in key
. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
key | First strings of the Line to be located. |
std::out_of_range | If key does not match any Line. |
This function takes a key (which is a vector of strings) and locates the Line whose first strings are equal to the strings in key
. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
key | Integers that are used to locate the Line. |
std::out_of_range | If key does not match any Line. |
This function takes a vector of ints and locates the Line whose first strings are equal to the to strings converted ints in key
. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
key | Integers that are used to locate the Line. |
std::out_of_range | If key does not match any Line. |
This function takes a vector of ints and locates the Line whose first strings are equal to the to strings converted ints in key
. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
s0,s1,s2,s3,s4 | First strings of the Line to be located. |
std::out_of_range | If provided strings do not match any Line. |
This function takes up to five strings and locates the Line whose first strings are equal to all provided non-empty strings. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
s0,s1,s2,s3,s4 | First strings of the Line to be located. |
std::out_of_range | If provided strings do not match any Line. |
This function takes up to five strings and locates the Line whose first strings are equal to all provided non-empty strings. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
i0,i1,i2,i3,i4 | Integers that are used to locate the Line. |
std::out_of_range | If provided ints do not match any Line. |
This function takes up to five ints and locates the Line whose first strings are equal to all provided to string converted ints. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Locates a Line in the Block.
i0,i1,i2,i3,i4 | Integers that are used to locate the Line. |
std::out_of_range | If provided ints do not match any Line. |
This function takes up to five ints and locates the Line whose first strings are equal to all provided to string converted ints. If no such Line exists, std::out_of_range
is thrown.
|
inline |
Returns a read/write reference to the first element of the Block.
|
inline |
Returns a read-only (constant) reference to the first element of the Block.
|
inline |
Returns a read/write reference to the last element of the Block.
|
inline |
Returns a read-only (constant) reference to the last element of the Block.
|
inline |
Returns a read/write iterator that points to the first element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read-only (constant) iterator that points to the first element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read-only (constant) iterator that points to the first element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read/write iterator that points one past the last element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read-only (constant) iterator that points one past the last element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read-only (constant) iterator that points one past the last element in the Block.
Iteration is done in ordinary element order.
|
inline |
Returns a read/write reverse iterator that points to the last element in the Block.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to the last element in the Block.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to the last element in the Block.
Iteration is done in reverse element order.
|
inline |
Returns a read/write reverse iterator that points to one before the first element in the Block.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to one before the first element in the Block.
Iteration is done in reverse element order.
|
inline |
Returns a read-only (constant) reverse iterator that points to one before the first element in the Block.
Iteration is done in reverse element order.
Tries to locate a Line in the Block.
key | First strings of the Line to be located. |
This function takes a key (which is a vector of strings) and tries to locate the Line whose first strings are equal to the strings in key
. If successful the function returns a read/write iterator pointing to the sought after Line. If unsuccessful it returns end().
|
inline |
Tries to locate a Line in the Block.
key | First strings of the Line to be located. |
This function takes a key (which is a vector of strings) and tries to locate the Line whose first strings are equal to the strings in key
. If successful the function returns a read-only (constant) iterator pointing to the sought after Line. If unsuccessful it returns end() const.
|
inlinestatic |
Tries to locate a Line in a range.
first,last | Input iterators to the initial and final positions in a sequence. |
key | First strings of the Line to be located. |
last
if not found.This function tries to locate in the range [first
, last
) the Line whose first strings are equal to the strings in key
. If successful the function returns an iterator pointing to the sought after Line. If unsuccessful it returns last
.
|
inline |
Returns a read/write iterator that points to the first Line in the Block which is a block definition.
If the Block does not contain a block definition, end() is returned.
|
inline |
Returns a read-only (constant) iterator that points to the first Line in the Block which is a block definition.
If the Block does not contain a block definition, end() const is returned.
|
inline |
Returns the number of elements in the Block.
|
inline |
|
inline |
Returns true if the Block is empty.
|
inline |
Adds a Line to the end of the Block.
line | Line to be added. |
This function creates an element at the end of the Block and assigns the given line
to it.
|
inline |
|
inline |
Removes the last element.
This function shrinks the size() of the Block by one.
|
inline |
|
inline |
Inserts a range into the Block.
position | Iterator into the Block. |
first,last | Input iterators to the initial and final positions in a sequence. |
This function inserts copies of the Lines in the range [first
, last
) into the Block before the specified position
and thus enlarges the Block accordingly.
Erases element at given position
.
position | Iterator pointing to the element to be erased. |
This function erases the element at the given position
and thus shortens the Block by one.
Erases a range of elements.
first | Iterator pointing to the first element to be erased. |
last | Iterator pointing to one past the last element to be erased. |
last
prior to erasing (or end()).This function erases the elements in the range [first
, last
) and shortens the Block accordingly.
Erases first Line that matches the provided key.
key | First strings of the Line to be erased. |
This function takes a key (which is a vector of strings) and erases the first Line whose first strings are equal to the strings in key
. If the Block contains such Line, the function returns an iterator pointing to the next element (or end()). If no such Line exists, end() is returned.
Erases last Line that matches the provided key.
key | First strings of the Line to be erased. |
This function takes a key (which is a vector of strings) and erases the last Line whose first strings are equal to the strings in key
. If the Block contains such Line, the function returns an iterator pointing to the next element (or end()). If no such Line exists, end() is returned.
Erases all Lines that match the provided key.
key | First strings of the Lines to be erased. |
This function takes a key (which is a vector of strings) and erases all Lines whose first strings are equal to the strings in key
.
|
inline |
Swaps data with another Block.
block | Block to be swapped with. |
|
inline |
Erases all the elements in the Block and set its name to an empty string.
|
inline |
Reformats all Lines in the Block.
|
inline |
Comments all Lines in the Block.
|
inline |
Uncomments all Lines in the Block.