SLHAea  0.1
containers for SUSY Les Houches Accord input/output
 All Classes Namespaces Files Functions Variables Typedefs
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
Block Class Reference

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 Linereference
 
typedef const Lineconst_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...
 
Blockread (std::istream &is)
 Assigns content from an input stream to the Block. More...
 
Blockstr (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...
 

Detailed Description

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".

Examples:
09_decay_input.cpp, 10_blocks_of_the_same_name.cpp, and 11_multiple_columns.cpp.

Member Typedef Documentation

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

Constructor & Destructor Documentation

Block ( const std::string &  name = "")
inlineexplicit

Constructs an empty Block.

Parameters
nameName of the Block.

+ Here is the caller graph for this function:

Block ( std::istream &  is)
inlineexplicit

Constructs a Block with content from an input stream.

Parameters
isInput stream to read content from.
See Also
read()

+ Here is the call graph for this function:

Member Function Documentation

static Block from_str ( const std::string &  block)
inlinestatic

Constructs a Block with content from a string.

Parameters
blockString to read content from.

+ Here is the call graph for this function:

void name ( const std::string &  newName)
inline

Sets the name of the Block.

Parameters
newNameNew 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.

+ Here is the caller graph for this function:

const std::string& name ( ) const
inline

Returns the name of the Block.

+ Here is the caller graph for this function:

void rename ( const std::string &  newName)
inline

Changes the name and definition of the Block.

Parameters
newNameNew name of the Block.

In contrast to name() this function changes the name of the Block and its first block definition (if it exists).

+ Here is the call graph for this function:

Block& read ( std::istream &  is)
inline

Assigns content from an input stream to the Block.

Parameters
isInput stream to read content from.
Returns
Reference to *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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Block& str ( const std::string &  block)
inline

Assigns content from a string to the Block.

Parameters
blockString that is used as content for the Block.
Returns
Reference to *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.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string str ( ) const
inline

Returns a string representation of the Block.

reference operator[] ( const key_type key)
inline

Locates a Line in the Block.

Parameters
keyFirst strings of the Line to be located.
Returns
Read/write reference to sought-after 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, this function creates an empty Line at the end of the Block and returns a reference to it.

+ Here is the call graph for this function:

reference operator[] ( const std::vector< int > &  key)
inline

Locates a Line in the Block.

Parameters
keyIntegers that are used to locate the Line.
Returns
Read/write reference to sought-after 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.

reference operator[] ( const std::string &  key)
inline

Locates a Line in the Block.

Parameters
keyString that is used to locate the Line.
Returns
Read/write reference to sought-after 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.

reference operator[] ( int  key)
inline

Locates a Line in the Block.

Parameters
keyInteger that is used to locate the Line.
Returns
Read/write reference to sought-after 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.

+ Here is the call graph for this function:

reference at ( const key_type key)
inline

Locates a Line in the Block.

Parameters
keyFirst strings of the Line to be located.
Returns
Read/write reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

Examples:
05_advanced_input.cpp, 08_matrix_input.cpp, 09_decay_input.cpp, 10_blocks_of_the_same_name.cpp, and 11_multiple_columns.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const_reference at ( const key_type key) const
inline

Locates a Line in the Block.

Parameters
keyFirst strings of the Line to be located.
Returns
Read-only (constant) reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

reference at ( const std::vector< int > &  key)
inline

Locates a Line in the Block.

Parameters
keyIntegers that are used to locate the Line.
Returns
Read/write reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

const_reference at ( const std::vector< int > &  key) const
inline

Locates a Line in the Block.

Parameters
keyIntegers that are used to locate the Line.
Returns
Read-only (constant) reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

reference at ( const std::string &  s0,
const std::string &  s1 = "",
const std::string &  s2 = "",
const std::string &  s3 = "",
const std::string &  s4 = "" 
)
inline

Locates a Line in the Block.

Parameters
s0,s1,s2,s3,s4First strings of the Line to be located.
Returns
Read/write reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

const_reference at ( const std::string &  s0,
const std::string &  s1 = "",
const std::string &  s2 = "",
const std::string &  s3 = "",
const std::string &  s4 = "" 
) const
inline

Locates a Line in the Block.

Parameters
s0,s1,s2,s3,s4First strings of the Line to be located.
Returns
Read-only (constant) reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

reference at ( int  i0,
int  i1 = no_index_,
int  i2 = no_index_,
int  i3 = no_index_,
int  i4 = no_index_ 
)
inline

Locates a Line in the Block.

Parameters
i0,i1,i2,i3,i4Integers that are used to locate the Line.
Returns
Read/write reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

const_reference at ( int  i0,
int  i1 = no_index_,
int  i2 = no_index_,
int  i3 = no_index_,
int  i4 = no_index_ 
) const
inline

Locates a Line in the Block.

Parameters
i0,i1,i2,i3,i4Integers that are used to locate the Line.
Returns
Read-only (constant) reference to sought-after Line.
Exceptions
std::out_of_rangeIf 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.

+ Here is the call graph for this function:

reference front ( )
inline

Returns a read/write reference to the first element of the Block.

const_reference front ( ) const
inline

Returns a read-only (constant) reference to the first element of the Block.

reference back ( )
inline

Returns a read/write reference to the last element of the Block.

+ Here is the caller graph for this function:

const_reference back ( ) const
inline

Returns a read-only (constant) reference to the last element of the Block.

iterator begin ( )
inline

Returns a read/write iterator that points to the first element in the Block.

Iteration is done in ordinary element order.

Examples:
03_basic_manip.cpp, and 09_decay_input.cpp.

+ Here is the caller graph for this function:

const_iterator begin ( ) const
inline

Returns a read-only (constant) iterator that points to the first element in the Block.

Iteration is done in ordinary element order.

const_iterator cbegin ( ) const
inline

Returns a read-only (constant) iterator that points to the first element in the Block.

Iteration is done in ordinary element order.

iterator end ( )
inline

Returns a read/write iterator that points one past the last element in the Block.

Iteration is done in ordinary element order.

Examples:
03_basic_manip.cpp, and 09_decay_input.cpp.

+ Here is the caller graph for this function:

const_iterator end ( ) const
inline

Returns a read-only (constant) iterator that points one past the last element in the Block.

Iteration is done in ordinary element order.

const_iterator cend ( ) const
inline

Returns a read-only (constant) iterator that points one past the last element in the Block.

Iteration is done in ordinary element order.

reverse_iterator rbegin ( )
inline

Returns a read/write reverse iterator that points to the last element in the Block.

Iteration is done in reverse element order.

+ Here is the caller graph for this function:

const_reverse_iterator rbegin ( ) const
inline

Returns a read-only (constant) reverse iterator that points to the last element in the Block.

Iteration is done in reverse element order.

const_reverse_iterator crbegin ( ) const
inline

Returns a read-only (constant) reverse iterator that points to the last element in the Block.

Iteration is done in reverse element order.

reverse_iterator rend ( )
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.

+ Here is the caller graph for this function:

const_reverse_iterator rend ( ) const
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.

const_reverse_iterator crend ( ) const
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.

iterator find ( const key_type key)
inline

Tries to locate a Line in the Block.

Parameters
keyFirst strings of the Line to be located.
Returns
Read/write iterator pointing to sought-after element, or end() if not found.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const_iterator find ( const key_type key) const
inline

Tries to locate a Line in the Block.

Parameters
keyFirst strings of the Line to be located.
Returns
Read-only (constant) iterator pointing to sought-after element, or end() const if not found.

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.

+ Here is the call graph for this function:

static InputIterator find ( InputIterator  first,
InputIterator  last,
const key_type key 
)
inlinestatic

Tries to locate a Line in a range.

Parameters
first,lastInput iterators to the initial and final positions in a sequence.
keyFirst strings of the Line to be located.
Returns
Iterator pointing to sought-after element, or 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.

iterator find_block_def ( )
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.

Examples:
10_blocks_of_the_same_name.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const_iterator find_block_def ( ) const
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.

+ Here is the call graph for this function:

size_type count ( const key_type key) const
inline

Counts all Lines that match a given key.

Parameters
keyFirst strings of the Lines that will be counted.
Returns
Number of lines whose first strings equal key.

+ Here is the call graph for this function:

size_type size ( ) const
inline

Returns the number of elements in the Block.

+ Here is the caller graph for this function:

size_type data_size ( ) const
inline

Returns the number of data Lines in the Block.

+ Here is the call graph for this function:

size_type max_size ( ) const
inline

Returns the size() of the largest possible Block.

bool empty ( ) const
inline

Returns true if the Block is empty.

void push_back ( const value_type line)
inline

Adds a Line to the end of the Block.

Parameters
lineLine to be added.

This function creates an element at the end of the Block and assigns the given line to it.

Examples:
10_blocks_of_the_same_name.cpp.

+ Here is the caller graph for this function:

void push_back ( const std::string &  line)
inline

Adds a Line to the end of the Block.

Parameters
lineString that is used to construct the Line that will be added.

This function creates an element at the end of the Block and assigns the Line that is constructed from line to it.

void pop_back ( )
inline

Removes the last element.

This function shrinks the size() of the Block by one.

iterator insert ( iterator  position,
const value_type line 
)
inline

Inserts a Line before given position.

Parameters
positionIterator into the Block.
lineLine to be inserted.
Returns
Iterator pointing to the inserted element.

This function inserts a copy of line before the specified position and thus enlarges the Block by one.

void insert ( iterator  position,
InputIterator  first,
InputIterator  last 
)
inline

Inserts a range into the Block.

Parameters
positionIterator into the Block.
first,lastInput 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.

iterator erase ( iterator  position)
inline

Erases element at given position.

Parameters
positionIterator pointing to the element to be erased.
Returns
Iterator pointing to the next element (or end()).

This function erases the element at the given position and thus shortens the Block by one.

+ Here is the caller graph for this function:

iterator erase ( iterator  first,
iterator  last 
)
inline

Erases a range of elements.

Parameters
firstIterator pointing to the first element to be erased.
lastIterator pointing to one past the last element to be erased.
Returns
Iterator pointing to the element pointed to by last prior to erasing (or end()).

This function erases the elements in the range [first, last) and shortens the Block accordingly.

iterator erase_first ( const key_type key)
inline

Erases first Line that matches the provided key.

Parameters
keyFirst strings of the Line to be erased.
Returns
Iterator pointing to the next element (or end()).

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.

+ Here is the call graph for this function:

iterator erase_last ( const key_type key)
inline

Erases last Line that matches the provided key.

Parameters
keyFirst strings of the Line to be erased.
Returns
Iterator pointing to the next element (or end()).

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.

+ Here is the call graph for this function:

size_type erase ( const key_type key)
inline

Erases all Lines that match the provided key.

Parameters
keyFirst strings of the Lines to be erased.
Returns
The number of Lines 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.

+ Here is the call graph for this function:

void swap ( Block block)
inline

Swaps data with another Block.

Parameters
blockBlock to be swapped with.
void clear ( )
inline

Erases all the elements in the Block and set its name to an empty string.

+ Here is the caller graph for this function:

void reformat ( )
inline

Reformats all Lines in the Block.

See Also
Line::reformat()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void comment ( )
inline

Comments all Lines in the Block.

See Also
Line::comment()
Examples:
03_basic_manip.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void uncomment ( )
inline

Uncomments all Lines in the Block.

See Also
Line::uncomment()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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