flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY

#include <slhaea.h>

Collaboration diagram for SLHAea::Line:
Collaboration graph

Public Types

typedef impl_type::const_iterator const_iterator
 
typedef impl_type::const_pointer const_pointer
 
typedef const std::string & const_reference
 
typedef impl_type::const_reverse_iterator const_reverse_iterator
 
typedef impl_type::difference_type difference_type
 
typedef impl_type::iterator iterator
 
typedef impl_type::pointer pointer
 
typedef std::string & reference
 
typedef impl_type::reverse_iterator reverse_iterator
 
typedef impl_type::size_type size_type
 
typedef std::string value_type
 

Public Member Functions

Lineappend (const std::string &arg)
 Appends a string to the end of the Line. More...
 
reference at (size_type n)
 Provides access to the strings contained in the Line. More...
 
const_reference at (size_type n) const
 Provides access to the strings contained in the Line. More...
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void clear ()
 
void comment ()
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
size_type data_size () const
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
reference front ()
 
const_reference front () const
 
bool is_block_def () const
 
bool is_comment_line () const
 
bool is_data_line () const
 
 Line ()
 
 Line (const std::string &line)
 Constructs a Line from a string. More...
 
size_type max_size () const
 
Lineoperator+= (const std::string &arg)
 Appends a string to the end of the Line. More...
 
template<class T >
Lineoperator<< (const T &field)
 Inserts an element at the end of the Line. More...
 
Lineoperator= (const std::string &line)
 Assigns content from a string to the Line. More...
 
reference operator[] (size_type n)
 Subscript access to the strings contained in the Line. More...
 
const_reference operator[] (size_type n) const
 Subscript access to the strings contained in the Line. More...
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
void reformat ()
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
size_type size () const
 
std::string str () const
 
Linestr (const std::string &line)
 Assigns content to the Line based on a string. More...
 
void swap (Line &line)
 Swaps data with another Line. More...
 
void uncomment ()
 

Private Types

typedef std::vector< std::string > impl_type
 

Private Member Functions

bool contains_comment () const
 
template<class T >
Lineinsert_fundamental_type (const T &arg)
 

Static Private Member Functions

static std::size_t calc_spaces_for_indent (const std::size_t &pos)
 
static bool is_block_specifier (const value_type &field)
 
static bool is_comment (const value_type &field)
 
static bool starts_with_sign (const value_type &field)
 

Private Attributes

std::vector< std::size_t > columns_
 
impl_type impl_
 

Static Private Attributes

static const std::size_t min_width_ = 2
 
static const std::size_t shift_width_ = 4
 

Detailed Description

Container of strings that represents a line in a SLHA structure. This class is a container of strings that represents a line in a SLHA structure. The elements of a Line are the so called fields of an ordinary SLHA line, which are its whitespace-separated substrings and the comment. For example, if a Line is constructed from the string " 1 2 0.123 # a comment" its elements would be "1", "2", "0.123", and "# a comment". Array-style access to the elements with integer indices is provided by the operator[]() and at() functions. Line also provides introspective functions to find out whether it is a comment or data line for example. Introspective functions that check if an element is a block specifier ("BLOCK" or "DECAY") always perform case-insensitive comparisons.

In addition to storing the fields of a SLHA line, a Line also stores its formatting (the exact position of the fields in the line). A formatted representation of a Line can be produced with str() const. The reformat() function clears the previous formatting and indents all elements with an appropriate number of spaces.

Definition at line 152 of file slhaea.h.

Member Typedef Documentation

◆ const_iterator

typedef impl_type::const_iterator SLHAea::Line::const_iterator

Definition at line 162 of file slhaea.h.

◆ const_pointer

typedef impl_type::const_pointer SLHAea::Line::const_pointer

Definition at line 166 of file slhaea.h.

◆ const_reference

typedef const std::string& SLHAea::Line::const_reference

Definition at line 160 of file slhaea.h.

◆ const_reverse_iterator

typedef impl_type::const_reverse_iterator SLHAea::Line::const_reverse_iterator

Definition at line 164 of file slhaea.h.

◆ difference_type

typedef impl_type::difference_type SLHAea::Line::difference_type

Definition at line 167 of file slhaea.h.

◆ impl_type

typedef std::vector<std::string> SLHAea::Line::impl_type
private

Definition at line 155 of file slhaea.h.

◆ iterator

typedef impl_type::iterator SLHAea::Line::iterator

Definition at line 161 of file slhaea.h.

◆ pointer

typedef impl_type::pointer SLHAea::Line::pointer

Definition at line 165 of file slhaea.h.

◆ reference

typedef std::string& SLHAea::Line::reference

Definition at line 159 of file slhaea.h.

◆ reverse_iterator

typedef impl_type::reverse_iterator SLHAea::Line::reverse_iterator

Definition at line 163 of file slhaea.h.

◆ size_type

typedef impl_type::size_type SLHAea::Line::size_type

Definition at line 168 of file slhaea.h.

◆ value_type

typedef std::string SLHAea::Line::value_type

Definition at line 158 of file slhaea.h.

Constructor & Destructor Documentation

◆ Line() [1/2]

SLHAea::Line::Line ( )
inline

Constructs an empty Line.

Definition at line 175 of file slhaea.h.

◆ Line() [2/2]

SLHAea::Line::Line ( const std::string &  line)
inline

Constructs a Line from a string.

Parameters
lineString whose fields are used as content of the Line.
See also
str()

Definition at line 182 of file slhaea.h.

References str().

Member Function Documentation

◆ append()

Line & SLHAea::Line::append ( const std::string &  arg)
inline

Appends a string to the end of the Line.

Parameters
argString that is appended to the Line.
Returns
Reference to *this.

This function appends arg to the output of str() const and uses this temporary string as input for str(). Based on the temporary string, size() is increased or remains unchanged.

Definition at line 250 of file slhaea.h.

References flexiblesusy::arg(), and str().

Referenced by operator+=().

◆ at() [1/2]

reference SLHAea::Line::at ( size_type  n)
inline

Provides access to the strings contained in the Line.

Parameters
nIndex of the string which should be accessed.
Returns
Read/write reference to the accessed string.
Exceptions
std::out_of_rangeIf n is an invalid index.

Definition at line 356 of file slhaea.h.

References impl_.

Referenced by SLHAea::Coll::field().

◆ at() [2/2]

const_reference SLHAea::Line::at ( size_type  n) const
inline

Provides access to the strings contained in the Line.

Parameters
nIndex of the string which should be accessed.
Returns
Read-only (constant) reference to the accessed string.
Exceptions
std::out_of_rangeIf n is an invalid index.

Definition at line 366 of file slhaea.h.

References impl_.

◆ back() [1/2]

reference SLHAea::Line::back ( )
inline

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

Definition at line 388 of file slhaea.h.

References impl_.

Referenced by operator<<().

◆ back() [2/2]

const_reference SLHAea::Line::back ( ) const
inline

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

Definition at line 396 of file slhaea.h.

References impl_.

◆ begin() [1/2]

iterator SLHAea::Line::begin ( )
inline

Returns a read/write iterator that points to the first element in the Line. Iteration is done in ordinary element order.

Definition at line 405 of file slhaea.h.

References impl_.

Referenced by data_size(), is_block_def(), SLHAea::Block::key_matches::operator()(), SLHAea::operator<(), SLHAea::operator==(), reformat(), and str().

◆ begin() [2/2]

const_iterator SLHAea::Line::begin ( ) const
inline

Returns a read-only (constant) iterator that points to the first element in the Line. Iteration is done in ordinary element order.

Definition at line 414 of file slhaea.h.

References impl_.

◆ calc_spaces_for_indent()

static std::size_t SLHAea::Line::calc_spaces_for_indent ( const std::size_t &  pos)
inlinestaticprivate

Definition at line 649 of file slhaea.h.

References min_width_, and shift_width_.

Referenced by reformat().

◆ cbegin()

const_iterator SLHAea::Line::cbegin ( ) const
inline

Returns a read-only (constant) iterator that points to the first element in the Line. Iteration is done in ordinary element order.

Definition at line 423 of file slhaea.h.

References impl_.

◆ cend()

const_iterator SLHAea::Line::cend ( ) const
inline

Returns a read-only (constant) iterator that points one past the last element in the Line. Iteration is done in ordinary element order.

Definition at line 450 of file slhaea.h.

References impl_.

◆ clear()

void SLHAea::Line::clear ( )
inline

Erases all the elements in the Line.

Definition at line 570 of file slhaea.h.

References columns_, and impl_.

Referenced by str().

◆ comment()

void SLHAea::Line::comment ( )
inline

Comments the Line. This function prefixes the Line with a "#" and packetizes all its elements into one.

Definition at line 625 of file slhaea.h.

References empty(), and str().

Referenced by SLHAea::Block::comment().

◆ contains_comment()

bool SLHAea::Line::contains_comment ( ) const
inlineprivate

Definition at line 645 of file slhaea.h.

References flexiblesusy::meta::find_if(), is_comment(), rbegin(), and rend().

Referenced by operator<<().

◆ crbegin()

const_reverse_iterator SLHAea::Line::crbegin ( ) const
inline

Returns a read-only (constant) reverse iterator that points to the last element in the Line. Iteration is done in reverse element order.

Definition at line 476 of file slhaea.h.

References impl_.

◆ crend()

const_reverse_iterator SLHAea::Line::crend ( ) const
inline

Returns a read-only (constant) reverse iterator that points to one before the first element in the Line. Iteration is done in reverse element order.

Definition at line 503 of file slhaea.h.

References impl_.

◆ data_size()

size_type SLHAea::Line::data_size ( ) const
inline

Returns the number of elements without the comment in the Line.

Definition at line 543 of file slhaea.h.

References begin(), end(), flexiblesusy::meta::find_if(), and is_comment().

◆ empty()

bool SLHAea::Line::empty ( ) const
inline

Returns true if the Line is empty.

Definition at line 553 of file slhaea.h.

References impl_.

Referenced by comment(), is_comment_line(), is_data_line(), reformat(), str(), and uncomment().

◆ end() [1/2]

iterator SLHAea::Line::end ( )
inline

Returns a read/write iterator that points one past the last element in the Line. Iteration is done in ordinary element order.

Definition at line 432 of file slhaea.h.

References impl_.

Referenced by data_size(), SLHAea::operator<(), SLHAea::operator==(), reformat(), and str().

◆ end() [2/2]

const_iterator SLHAea::Line::end ( ) const
inline

Returns a read-only (constant) iterator that points one past the last element in the Line. Iteration is done in ordinary element order.

Definition at line 441 of file slhaea.h.

References impl_.

◆ front() [1/2]

reference SLHAea::Line::front ( )
inline

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

Definition at line 373 of file slhaea.h.

References impl_.

Referenced by is_comment_line(), is_data_line(), and uncomment().

◆ front() [2/2]

const_reference SLHAea::Line::front ( ) const
inline

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

Definition at line 381 of file slhaea.h.

References impl_.

◆ insert_fundamental_type()

template<class T >
Line & SLHAea::Line::insert_fundamental_type ( const T &  arg)
inlineprivate

Definition at line 671 of file slhaea.h.

References flexiblesusy::arg(), and SLHAea::to_string().

◆ is_block_def()

bool SLHAea::Line::is_block_def ( ) const
inline

Returns true if the Line begins with "BLOCK" or "DECAY" followed by a block name.

Definition at line 512 of file slhaea.h.

References begin(), is_block_specifier(), is_comment(), and size().

Referenced by SLHAea::Block::find_block_def(), SLHAea::operator<(), SLHAea::Block::read(), SLHAea::Coll::read(), and flexiblesusy::detail::read_scale().

◆ is_block_specifier()

static bool SLHAea::Line::is_block_specifier ( const value_type field)
inlinestaticprivate

Definition at line 657 of file slhaea.h.

References SLHAea::detail::to_upper_copy().

Referenced by is_block_def(), is_data_line(), and reformat().

◆ is_comment()

static bool SLHAea::Line::is_comment ( const value_type field)
inlinestaticprivate

◆ is_comment_line()

bool SLHAea::Line::is_comment_line ( ) const
inline

Returns true if the Line begins with "#".

Definition at line 522 of file slhaea.h.

References empty(), front(), and is_comment().

◆ is_data_line()

bool SLHAea::Line::is_data_line ( ) const
inline

Returns true if the Line is not empty and if it does not begin with "#", "BLOCK" or "DECAY".

Definition at line 530 of file slhaea.h.

References empty(), front(), is_block_specifier(), and is_comment().

Referenced by SLHAea::Block::data_size().

◆ max_size()

size_type SLHAea::Line::max_size ( ) const
inline

Returns the size() of the largest possible Line.

Definition at line 548 of file slhaea.h.

References impl_.

◆ operator+=()

Line & SLHAea::Line::operator+= ( const std::string &  arg)
inline

Appends a string to the end of the Line.

Parameters
argString that is appended to the Line.
Returns
Reference to *this.

This function is an alias for append().

Definition at line 207 of file slhaea.h.

References append(), and flexiblesusy::arg().

◆ operator<<()

template<class T >
Line & SLHAea::Line::operator<< ( const T &  field)
inline

Inserts an element at the end of the Line.

Parameters
fieldElement that is inserted at the end of the Line.
Returns
Reference to *this.

This function inserts an element at the end of the Line. If the the Line contains a comment, field is only appended to the last element and thus size() remains unchanged.

Definition at line 222 of file slhaea.h.

References back(), contains_comment(), impl_, reformat(), SLHAea::to_string(), SLHAea::detail::trim_left(), and SLHAea::detail::trim_right().

◆ operator=()

Line & SLHAea::Line::operator= ( const std::string &  line)
inline

Assigns content from a string to the Line.

Parameters
lineString whose fields are used as content of the Line.
Returns
Reference to *this.

This function is an alias for str().

Definition at line 193 of file slhaea.h.

References str().

◆ operator[]() [1/2]

reference SLHAea::Line::operator[] ( size_type  n)
inline

Subscript access to the strings contained in the Line.

Parameters
nIndex of the string which should be accessed.
Returns
Read/write reference to the accessed string.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

Definition at line 333 of file slhaea.h.

References impl_.

◆ operator[]() [2/2]

const_reference SLHAea::Line::operator[] ( size_type  n) const
inline

Subscript access to the strings contained in the Line.

Parameters
nIndex of the string which should be accessed.
Returns
Read-only (constant) reference to the accessed string.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

Definition at line 346 of file slhaea.h.

References impl_.

◆ rbegin() [1/2]

reverse_iterator SLHAea::Line::rbegin ( )
inline

Returns a read/write reverse iterator that points to the last element in the Line. Iteration is done in reverse element order.

Definition at line 458 of file slhaea.h.

References impl_.

Referenced by contains_comment().

◆ rbegin() [2/2]

const_reverse_iterator SLHAea::Line::rbegin ( ) const
inline

Returns a read-only (constant) reverse iterator that points to the last element in the Line. Iteration is done in reverse element order.

Definition at line 467 of file slhaea.h.

References impl_.

◆ reformat()

void SLHAea::Line::reformat ( )
inline

Reformats the string representation of the Line.

Definition at line 578 of file slhaea.h.

References begin(), calc_spaces_for_indent(), columns_, empty(), end(), is_block_specifier(), is_comment(), shift_width_, and starts_with_sign().

Referenced by operator<<(), and SLHAea::Block::reformat().

◆ rend() [1/2]

reverse_iterator SLHAea::Line::rend ( )
inline

Returns a read/write reverse iterator that points to one before the first element in the Line. Iteration is done in reverse element order.

Definition at line 485 of file slhaea.h.

References impl_.

Referenced by contains_comment().

◆ rend() [2/2]

const_reverse_iterator SLHAea::Line::rend ( ) const
inline

Returns a read-only (constant) reverse iterator that points to one before the first element in the Line. Iteration is done in reverse element order.

Definition at line 494 of file slhaea.h.

References impl_.

◆ size()

size_type SLHAea::Line::size ( ) const
inline

Returns the number of elements in the Line.

Definition at line 536 of file slhaea.h.

References impl_.

Referenced by is_block_def(), SLHAea::Block::key_matches::operator()(), SLHAea::operator==(), and flexiblesusy::detail::read_scale().

◆ starts_with_sign()

static bool SLHAea::Line::starts_with_sign ( const value_type field)
inlinestaticprivate

Definition at line 678 of file slhaea.h.

Referenced by reformat().

◆ str() [1/2]

std::string SLHAea::Line::str ( ) const
inline

Returns a formatted string representation of the Line.

Definition at line 303 of file slhaea.h.

References begin(), columns_, empty(), and end().

Referenced by append(), comment(), Line(), operator=(), and uncomment().

◆ str() [2/2]

Line & SLHAea::Line::str ( const std::string &  line)
inline

Assigns content to the Line based on a string.

Parameters
lineString whose fields are used as content of the Line.
Returns
Reference to *this.

This function parses line and sets the found fields as content of the Line. If line contains newlines, everything after the first newline is ignored.

The exact formatting of line is stored internally and can be reproduced with str() const.

Definition at line 269 of file slhaea.h.

References clear(), columns_, data, and impl_.

Referenced by SLHAea::operator<<(), SLHAea::operator==(), SLHAea::Block::read(), and SLHAea::Coll::read().

◆ swap()

void SLHAea::Line::swap ( Line line)
inline

Swaps data with another Line.

Parameters
lineLine to be swapped with.

Definition at line 562 of file slhaea.h.

References columns_, and impl_.

◆ uncomment()

void SLHAea::Line::uncomment ( )
inline

Uncomments the Line. This function removes the first character of the Line if it is a "#" and splits the former comment into the corresponding number of fields.

Definition at line 634 of file slhaea.h.

References empty(), front(), is_comment(), and str().

Referenced by SLHAea::Block::uncomment().

Member Data Documentation

◆ columns_

std::vector<std::size_t> SLHAea::Line::columns_
private

Definition at line 683 of file slhaea.h.

Referenced by clear(), reformat(), str(), and swap().

◆ impl_

impl_type SLHAea::Line::impl_
private

◆ min_width_

const std::size_t SLHAea::Line::min_width_ = 2
staticprivate

Definition at line 686 of file slhaea.h.

Referenced by calc_spaces_for_indent().

◆ shift_width_

const std::size_t SLHAea::Line::shift_width_ = 4
staticprivate

Definition at line 685 of file slhaea.h.

Referenced by calc_spaces_for_indent(), and reformat().


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