25 #include <boost/algorithm/string/classification.hpp>
26 #include <boost/algorithm/string/join.hpp>
27 #include <boost/algorithm/string/predicate.hpp>
28 #include <boost/algorithm/string/split.hpp>
29 #include <boost/lexical_cast.hpp>
43 template<
class Target,
class Source>
inline Target
45 {
return boost::lexical_cast<Target>(arg); }
55 template<
class Source>
inline std::string
57 {
return boost::lexical_cast<std::string>(arg); }
70 template<
class Source>
inline std::string
73 std::ostringstream output;
74 output << std::setprecision(precision) << std::scientific << arg;
83 {
return str.find_first_not_of(
" \t\n\v\f\r") == std::string::npos; }
88 std::string str_upper(str.length(), char());
89 std::transform(str.begin(), str.end(), str_upper.begin(),
90 static_cast<int (*)(
int)
>(std::toupper));
97 const std::size_t startpos = str.find_first_not_of(
" \t\n\v\f\r");
98 if (startpos != std::string::npos) str.erase(0, startpos);
105 const std::size_t endpos = str.find_last_not_of(
" \t\n\v\f\r");
106 if (endpos != std::string::npos) str.erase(endpos + 1);
119 inline std::ostream&
operator<<(std::ostream& os,
const Line& line);
120 inline std::ostream&
operator<<(std::ostream& os,
const Block& block);
121 inline std::ostream&
operator<<(std::ostream& os,
const Coll& coll);
122 inline std::ostream&
operator<<(std::ostream& os,
const Key& key);
149 typedef std::vector<std::string> impl_type;
169 Line() : impl_(), columns_() {}
176 Line(
const std::string& line) : impl_(), columns_()
216 template<
class T>
Line&
219 std::string field_str =
to_string(field);
221 if (field_str.empty())
return *
this;
223 if (contains_comment())
224 {
back() += field_str; }
228 impl_.push_back(field_str);
263 str(
const std::string& line)
266 static const std::string whitespace =
" \t\v\f\r";
267 const std::size_t last_non_ws =
268 line.substr(0, line.find(
'\n')).find_last_not_of(whitespace);
269 if (last_non_ws == std::string::npos)
return *
this;
271 const std::string trimmed_line = line.substr(0, last_non_ws + 1);
272 const std::size_t comment_pos = trimmed_line.find(
'#');
273 const std::string data = trimmed_line.substr(0, comment_pos);
275 std::size_t pos1 = data.find_first_not_of(whitespace, 0);
276 std::size_t pos2 = data.find_first_of(whitespace, pos1);
278 while (pos1 != std::string::npos)
280 impl_.push_back(data.substr(pos1, pos2 - pos1));
281 columns_.push_back(pos1);
283 pos1 = data.find_first_not_of(whitespace, pos2);
284 pos2 = data.find_first_of(whitespace, pos1);
287 if (comment_pos != std::string::npos)
289 impl_.push_back(trimmed_line.substr(comment_pos));
290 columns_.push_back(comment_pos);
299 if (
empty())
return "";
301 std::ostringstream output;
302 int length = 0, spaces = 0;
305 std::vector<std::size_t>::const_iterator column = columns_.begin();
306 for (; field !=
end() && column != columns_.end(); ++field, ++column)
308 spaces = std::max(0, static_cast<int>(*column) - length + 1);
309 length += spaces + field->length();
311 output << std::setw(spaces) <<
" " << *field;
313 return output.str().substr(1);
351 {
return impl_.at(n); }
361 {
return impl_.at(n); }
368 {
return impl_.front(); }
376 {
return impl_.front(); }
383 {
return impl_.back(); }
391 {
return impl_.back(); }
400 {
return impl_.begin(); }
409 {
return impl_.begin(); }
418 {
return impl_.begin(); }
427 {
return impl_.end(); }
436 {
return impl_.end(); }
445 {
return impl_.end(); }
453 {
return impl_.rbegin(); }
462 {
return impl_.rbegin(); }
471 {
return impl_.rbegin(); }
480 {
return impl_.rend(); }
489 {
return impl_.rend(); }
498 {
return impl_.rend(); }
508 if (
size() < 2)
return false;
511 return is_block_specifier(*field) && !is_comment(*++field);
525 {
return !
empty() && !is_comment(
front()) && !is_block_specifier(
front()); }
531 {
return impl_.size(); }
538 {
return std::distance(
begin(), std::find_if(
begin(),
end(), is_comment)); }
543 {
return impl_.max_size(); }
548 {
return impl_.empty(); }
558 impl_.swap(line.impl_);
559 columns_.swap(line.columns_);
578 std::size_t pos1 = 0, pos2 = 0;
580 if (is_block_specifier(*field))
583 pos2 = pos1 + field->length();
584 columns_.push_back(pos1);
586 if (++field ==
end())
return;
589 pos2 = pos1 + field->length();
590 columns_.push_back(pos1);
592 else if (is_comment(*field))
595 pos2 = pos1 + field->length();
596 columns_.push_back(pos1);
601 pos2 = pos1 + field->length();
602 columns_.push_back(pos1);
605 while (++field !=
end())
607 pos1 = pos2 + calc_spaces_for_indent(pos2);
608 if (starts_with_sign(*field)) --pos1;
609 pos2 = pos1 + field->length();
610 columns_.push_back(pos1);
639 contains_comment()
const
643 calc_spaces_for_indent(
const std::size_t& pos)
645 std::size_t width = shift_width_ - (pos % shift_width_);
646 if (width < min_width_) width += shift_width_;
653 static const std::size_t specifier_length = 5;
654 if (field.length() != specifier_length)
return false;
657 return (field_upper ==
"BLOCK") || (field_upper ==
"DECAY");
662 {
return !field.empty() && field[0] ==
'#'; }
664 template<
class T>
Line&
665 insert_fundamental_type(
const T& arg)
667 static const int digits = std::numeric_limits<T>::digits10;
673 {
return !field.empty() && (field[0] ==
'-' || field[0] ==
'+'); }
677 std::vector<std::size_t> columns_;
679 static const std::size_t shift_width_ = 4;
680 static const std::size_t min_width_ = 2;
683 template<>
inline Line&
684 Line::operator<< <float>(
const float& number)
686 insert_fundamental_type(number);
690 template<>
inline Line&
691 Line::operator<< <double>(
const double& number)
693 insert_fundamental_type(number);
697 template<>
inline Line&
698 Line::operator<< <long double>(
const long double& number)
700 insert_fundamental_type(number);
727 typedef std::vector<Line> impl_type;
760 Block(std::istream& is) : name_(), impl_()
770 std::istringstream input(block);
782 name(
const std::string& newName)
802 if (block_def !=
end()) (*block_def)[1] = newName;
820 std::string line_str;
823 std::size_t def_count = 0;
824 bool nameless =
name().empty();
826 while (std::getline(is, line_str))
835 is.seekg(-line_str.length()-1, std::ios_base::cur);
862 str(
const std::string& block)
864 std::istringstream input(block);
874 std::ostringstream output;
894 if (line !=
end())
return *line;
913 {
return (*
this)[cont_to_key(key)]; }
926 {
return (*
this)[
key_type(1, key)]; }
956 if (line !=
end())
return *line;
958 throw std::out_of_range(
959 "SLHAea::Block::at(‘" + boost::join(key,
",") +
"’)");
976 if (line !=
end())
return *line;
978 throw std::out_of_range(
979 "SLHAea::Block::at(‘" + boost::join(key,
",") +
"’)");
993 at(
const std::vector<int>& key)
994 {
return at(cont_to_key(key)); }
1007 at(
const std::vector<int>& key)
const
1008 {
return at(cont_to_key(key)); }
1023 at(
const std::string& s0,
const std::string& s1 =
"",
1024 const std::string& s2 =
"",
const std::string& s3 =
"",
1025 const std::string& s4 =
"")
1026 {
return at(strings_to_key(s0, s1, s2, s3, s4)); }
1041 at(
const std::string& s0,
const std::string& s1 =
"",
1042 const std::string& s2 =
"",
const std::string& s3 =
"",
1043 const std::string& s4 =
"")
const
1044 {
return at(strings_to_key(s0, s1, s2, s3, s4)); }
1059 at(
int i0,
int i1 = no_index_,
int i2 = no_index_,
1060 int i3 = no_index_,
int i4 = no_index_)
1061 {
return at(ints_to_key(i0, i1, i2, i3, i4)); }
1075 at(
int i0,
int i1 = no_index_,
int i2 = no_index_,
1076 int i3 = no_index_,
int i4 = no_index_)
const
1077 {
return at(ints_to_key(i0, i1, i2, i3, i4)); }
1085 {
return impl_.front(); }
1093 {
return impl_.front(); }
1100 {
return impl_.back(); }
1108 {
return impl_.back(); }
1117 {
return impl_.begin(); }
1126 {
return impl_.begin(); }
1135 {
return impl_.begin(); }
1144 {
return impl_.end(); }
1153 {
return impl_.end(); }
1162 {
return impl_.end(); }
1171 {
return impl_.rbegin(); }
1180 {
return impl_.rbegin(); }
1189 {
return impl_.rbegin(); }
1198 {
return impl_.rend(); }
1207 {
return impl_.rend(); }
1216 {
return impl_.rend(); }
1264 template<
class InputIterator>
static InputIterator
1266 {
return std::find_if(first, last,
key_matches(key)); }
1276 return std::find_if(
begin(),
end(),
1288 return std::find_if(
begin(),
end(),
1306 {
return impl_.size(); }
1312 return std::count_if(
begin(),
end(),
1319 {
return impl_.max_size(); }
1324 {
return impl_.empty(); }
1336 { impl_.push_back(line); }
1356 { impl_.pop_back(); }
1369 {
return impl_.insert(position, line); }
1381 template<
class InputIterator>
void
1383 { impl_.insert(position, first, last); }
1395 {
return impl_.erase(position); }
1410 {
return impl_.erase(first, last); }
1427 return (line !=
end()) ?
erase(line) : line;
1445 return (line !=
rend()) ?
erase((++line).base()) :
end();
1472 return erased_count;
1482 name_.swap(block.name_);
1483 impl_.swap(block.impl_);
1530 return (key_.empty() || key_.size() > line.
size()) ?
false :
1531 std::equal(key_.begin(), key_.end(), line.
begin(), parts_equal);
1540 parts_equal(
const std::string& key_part,
const std::string& field)
1541 {
return (key_part ==
"(any)") || boost::iequals(key_part, field); }
1548 template<
class Container>
static key_type
1549 cont_to_key(
const Container& cont)
1552 key.reserve(cont.size());
1553 std::string (*
to_string)(
const typename Container::value_type&) =
1554 boost::lexical_cast<std::string, typename Container::value_type>;
1555 std::transform(cont.begin(), cont.end(), std::back_inserter(key),
1561 strings_to_key(
const std::string& s0,
const std::string& s1,
1562 const std::string& s2,
const std::string& s3,
1563 const std::string& s4)
1567 if (s0.empty())
return key; key.push_back(s0);
1568 if (s1.empty())
return key; key.push_back(s1);
1569 if (s2.empty())
return key; key.push_back(s2);
1570 if (s3.empty())
return key; key.push_back(s3);
1571 if (s4.empty())
return key; key.push_back(s4);
1576 ints_to_key(
int i0,
int i1,
int i2,
int i3,
int i4)
1580 if (i0 == no_index_)
return key; key.push_back(
to_string(i0));
1581 if (i1 == no_index_)
return key; key.push_back(
to_string(i1));
1582 if (i2 == no_index_)
return key; key.push_back(
to_string(i2));
1583 if (i3 == no_index_)
return key; key.push_back(
to_string(i3));
1584 if (i4 == no_index_)
return key; key.push_back(
to_string(i4));
1591 static const int no_index_ = -32768;
1610 typedef std::deque<Block> impl_type;
1649 std::istringstream input(coll);
1665 std::string line_str;
1671 while (std::getline(is, line_str))
1676 if (line.
is_block_def()) block = push_back_named_block(line[1]);
1677 block->push_back(line);
1680 erase_if_empty(
"", orig_size);
1692 std::istringstream input(coll);
1702 std::ostringstream output;
1704 return output.str();
1741 throw std::out_of_range(
"SLHAea::Coll::at(‘" + blockName +
"’)");
1757 throw std::out_of_range(
"SLHAea::Coll::at(‘" + blockName +
"’)");
1779 throw std::out_of_range(
1780 "SLHAea::Coll::at(‘" + boost::join(key,
",") +
"’)");
1802 throw std::out_of_range(
1803 "SLHAea::Coll::at(‘" + boost::join(key,
",") +
"’)");
1811 {
return impl_.front(); }
1819 {
return impl_.front(); }
1826 {
return impl_.back(); }
1834 {
return impl_.back(); }
1905 {
return impl_.begin(); }
1914 {
return impl_.begin(); }
1923 {
return impl_.begin(); }
1932 {
return impl_.end(); }
1941 {
return impl_.end(); }
1950 {
return impl_.end(); }
1958 {
return impl_.rbegin(); }
1967 {
return impl_.rbegin(); }
1976 {
return impl_.rbegin(); }
1985 {
return impl_.rend(); }
1994 {
return impl_.rend(); }
2003 {
return impl_.rend(); }
2049 template<
class InputIterator>
static InputIterator
2051 {
return std::find_if(first, last,
key_matches(blockName)); }
2102 template<
class InputIterator>
static InputIterator
2103 find(InputIterator first, InputIterator last,
2121 {
return impl_.size(); }
2126 {
return impl_.max_size(); }
2131 {
return impl_.empty(); }
2143 { impl_.push_back(block); }
2157 block.
str(blockString);
2158 impl_.push_back(block);
2170 { impl_.push_front(block); }
2184 block.
str(blockString);
2185 impl_.push_front(block);
2194 { impl_.pop_back(); }
2207 {
return impl_.insert(position, block); }
2219 template<
class InputIterator>
void
2221 { impl_.insert(position, first, last); }
2233 {
return impl_.erase(position); }
2248 {
return impl_.erase(first, last); }
2281 return (block !=
rend()) ?
erase((++block).base()) :
end();
2304 return erased_count;
2313 { impl_.swap(coll.impl_); }
2355 {
return boost::iequals(name_, block.
name()); }
2359 { name_ = blockName; }
2373 : key_matches_(key) {}
2379 return (block_def == block.
end()) ?
false : key_matches_(*block_def);
2384 { key_matches_.
set_key(key); }
2392 push_back_named_block(
const key_type& blockName)
2402 return (block !=
end() && block->empty()) ?
erase(block) :
block;
2447 : block(_block),
line(_line), field(_field) {}
2454 Key(
const std::string& keyString)
2471 str(
const std::string& keyString)
2473 std::vector<std::string> keys;
2474 boost::split(keys, keyString, boost::is_any_of(
";"));
2476 if (keys.size() != 3)
2477 {
throw std::invalid_argument(
"SLHAea::Key::str(‘" + keyString +
"’)"); }
2481 boost::split(
line, keys[1], boost::is_any_of(
","));
2482 field = to<Line::size_type>(keys[2]);
2494 std::ostringstream output;
2495 output << block <<
";" << boost::join(
line,
",") <<
";" <<
field;
2496 return output.str();
2527 inline std::istream&
2534 inline std::istream&
2541 inline std::ostream&
2543 {
return os << line.
str(); }
2545 inline std::ostream&
2548 std::copy(block.
begin(), block.
end(),
2549 std::ostream_iterator<Block::value_type>(os,
"\n"));
2553 inline std::ostream&
2556 std::copy(coll.
begin(), coll.
end(),
2557 std::ostream_iterator<Coll::value_type>(os));
2561 inline std::ostream&
2563 {
return os << key.
str(); }
2579 return (a_is_block_def != b.
is_block_def()) ? a_is_block_def :
2585 {
return !(a == b); }
2593 {
return !(b < a); }
2597 {
return !(a < b); }
2617 {
return !(a == b); }
2625 {
return !(b < a); }
2629 {
return !(a < b); }
2640 return std::lexicographical_compare(a.
begin(), a.
end(),
2646 {
return !(a == b); }
2654 {
return !(b < a); }
2658 {
return !(a < b); }
size_type max_size() const
Returns the size() of the largest possible Block.
Definition: slhaea.h:1318
const_reference operator[](size_type n) const
Subscript access to the strings contained in the Line.
Definition: slhaea.h:340
key_matches(const key_type &key)
Definition: slhaea.h:1525
const Block & const_reference
Definition: slhaea.h:1616
size_type size() const
Returns the number of elements in the Block.
Definition: slhaea.h:1305
iterator insert(iterator position, const value_type &block)
Inserts a Block before given position.
Definition: slhaea.h:2206
reference at(size_type n)
Provides access to the strings contained in the Line.
Definition: slhaea.h:350
iterator erase(iterator first, iterator last)
Erases a range of elements.
Definition: slhaea.h:2247
void push_front(const std::string &blockString)
Adds a Block to the begin of the Coll.
Definition: slhaea.h:2181
Line & append(const std::string &arg)
Appends a string to the end of the Line.
Definition: slhaea.h:244
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:1619
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Line.
Definition: slhaea.h:408
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Coll.
Definition: slhaea.h:1913
Coll & str(const std::string &coll)
Assigns content from a string to the Coll.
Definition: slhaea.h:1690
Line value_type
Definition: slhaea.h:731
void push_back(const value_type &block)
Adds a Block to the end of the Coll.
Definition: slhaea.h:2142
const_reverse_iterator crend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Co...
Definition: slhaea.h:2002
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.
Definition: slhaea.h:1041
static Block from_str(const std::string &block)
Constructs a Block with content from a string.
Definition: slhaea.h:768
reference operator[](const std::vector< int > &key)
Locates a Line in the Block.
Definition: slhaea.h:912
void push_back(const std::string &blockString)
Adds a Block to the end of the Coll.
Definition: slhaea.h:2154
void swap(Line &line)
Swaps data with another Line.
Definition: slhaea.h:556
const_reference front() const
Returns a read-only (constant) reference to the first element of the Coll.
Definition: slhaea.h:1818
void clear()
Erases all the elements in the Line.
Definition: slhaea.h:564
iterator erase(iterator position)
Erases element at given position.
Definition: slhaea.h:1394
impl_type::difference_type difference_type
Definition: slhaea.h:1623
reference back()
Returns a read/write reference to the last element of the Block.
Definition: slhaea.h:1099
impl_type::iterator iterator
Definition: slhaea.h:1617
bool operator()(const value_type &line) const
Definition: slhaea.h:1528
reference block(const Key &key)
Accesses a Block in the Coll.
Definition: slhaea.h:2502
std::string str() const
Returns a formatted string representation of the Line.
Definition: slhaea.h:297
void rename(const std::string &newName)
Changes the name and definition of the Block.
Definition: slhaea.h:798
bool is_block_def() const
Returns true if the Line begins with "BLOCK" or "DECAY" followed by a block name. ...
Definition: slhaea.h:506
reference operator[](size_type n)
Subscript access to the strings contained in the Line.
Definition: slhaea.h:327
void set_key(const key_type &key)
Definition: slhaea.h:1535
const_reference back() const
Returns a read-only (constant) reference to the last element of the Block.
Definition: slhaea.h:1107
std::string str() const
Returns a string representation of the Block.
Definition: slhaea.h:872
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Coll...
Definition: slhaea.h:1984
iterator begin()
Returns a read/write iterator that points to the first element in the Block.
Definition: slhaea.h:1116
iterator begin()
Returns a read/write iterator that points to the first element in the Coll.
Definition: slhaea.h:1904
reference at(const std::vector< int > &key)
Locates a Line in the Block.
Definition: slhaea.h:993
Block & read(std::istream &is)
Assigns content from an input stream to the Block.
Definition: slhaea.h:818
iterator find_block_def()
Returns a read/write iterator that points to the first Line in the Block which is a block definition...
Definition: slhaea.h:1274
impl_type::iterator iterator
Definition: slhaea.h:155
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:157
bool operator<(const Line &a, const Line &b)
Definition: slhaea.h:2575
std::ostream & operator<<(std::ostream &os, const Line &line)
Definition: slhaea.h:2542
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:1620
const_reference at(const key_type &blockName) const
Locates a Block in the Coll.
Definition: slhaea.h:1752
std::string value_type
Definition: slhaea.h:152
const Line & const_reference
Definition: slhaea.h:733
Line::size_type field
Index of the field in the Line.
Definition: slhaea.h:2436
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Coll.
Definition: slhaea.h:1957
iterator erase(iterator position)
Erases element at given position.
Definition: slhaea.h:2232
reference operator[](int key)
Locates a Line in the Block.
Definition: slhaea.h:939
void swap(Block &block)
Swaps data with another Block.
Definition: slhaea.h:1480
bool operator!=(const Line &a, const Line &b)
Definition: slhaea.h:2584
const_reverse_iterator crbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Block...
Definition: slhaea.h:1188
reference operator[](const key_type &blockName)
Locates a Block in the Coll.
Definition: slhaea.h:1719
const_reverse_iterator rbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Line...
Definition: slhaea.h:461
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 d...
Definition: slhaea.h:1286
const_reference back() const
Returns a read-only (constant) reference to the last element of the Coll.
Definition: slhaea.h:1833
Container of strings that represents a line in a SLHA structure.
Definition: slhaea.h:146
const_iterator find(const key_type &key) const
Tries to locate a Line in the Block.
Definition: slhaea.h:1248
impl_type::pointer pointer
Definition: slhaea.h:1621
impl_type::size_type size_type
Definition: slhaea.h:741
iterator find(const key_type &blockName)
Tries to locate a Block in the Coll.
Definition: slhaea.h:2018
void trim_left(std::string &str)
Definition: slhaea.h:95
bool is_comment_line() const
Returns true if the Line begins with "#".
Definition: slhaea.h:516
static InputIterator find(InputIterator first, InputIterator last, const key_type &blockName)
Tries to locate a Block in a range.
Definition: slhaea.h:2050
Key(const std::string &keyString)
Constructs a Key from a string.
Definition: slhaea.h:2454
const_reference at(const value_type::key_type &key) const
Locates a Block in the Coll.
Definition: slhaea.h:1797
size_type max_size() const
Returns the size() of the largest possible Line.
Definition: slhaea.h:542
void uncomment()
Uncomments all Blocks in the Coll.
Definition: slhaea.h:2341
bool operator>(const Line &a, const Line &b)
Definition: slhaea.h:2588
void clear()
Erases all the elements in the Coll.
Definition: slhaea.h:2317
Line()
Constructs an empty Line.
Definition: slhaea.h:169
size_type erase(const key_type &blockName)
Erases all Blocks with a given name.
Definition: slhaea.h:2290
const_iterator cbegin() const
Returns a read-only (constant) iterator that points to the first element in the Line.
Definition: slhaea.h:417
std::vector< std::string > key_type
Definition: slhaea.h:730
Container of Lines that resembles a block in a SLHA structure.
Definition: slhaea.h:724
Block & str(const std::string &block)
Assigns content from a string to the Block.
Definition: slhaea.h:862
impl_type::size_type size_type
Definition: slhaea.h:1624
size_type max_size() const
Returns the size() of the largest possible Coll.
Definition: slhaea.h:2125
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Line...
Definition: slhaea.h:479
impl_type::difference_type difference_type
Definition: slhaea.h:740
const_reference front() const
Returns a read-only (constant) reference to the first element of the Line.
Definition: slhaea.h:375
Coll(std::istream &is)
Constructs a Coll with content from an input stream.
Definition: slhaea.h:1639
void pop_back()
Removes the last element.
Definition: slhaea.h:2193
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Block.
Definition: slhaea.h:1170
size_type size() const
Returns the number of elements in the Coll.
Definition: slhaea.h:2120
void uncomment()
Uncomments all Lines in the Block.
Definition: slhaea.h:1518
reference front()
Returns a read/write reference to the first element of the Coll.
Definition: slhaea.h:1810
impl_type::const_pointer const_pointer
Definition: slhaea.h:1622
size_type erase(const key_type &key)
Erases all Lines that match the provided key.
Definition: slhaea.h:1458
static InputIterator find(InputIterator first, InputIterator last, const key_type &key)
Tries to locate a Line in a range.
Definition: slhaea.h:1265
size_type count(const key_type &key) const
Counts all Lines that match a given key.
Definition: slhaea.h:1299
Reference to a single field in a SLHA structure.
Definition: slhaea.h:2426
bool empty() const
Returns true if the Block is empty.
Definition: slhaea.h:1323
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:736
bool is_data_line() const
Returns true if the Line is not empty and if it does not begin with "#", "BLOCK" or "DECAY"...
Definition: slhaea.h:524
iterator erase_last(const key_type &blockName)
Erases last Block with a given name.
Definition: slhaea.h:2278
impl_type::difference_type difference_type
Definition: slhaea.h:161
const_iterator cend() const
Returns a read-only (constant) iterator that points one past the last element in the Line...
Definition: slhaea.h:444
const_reverse_iterator rend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Bl...
Definition: slhaea.h:1206
void insert(iterator position, InputIterator first, InputIterator last)
Inserts a range into the Coll.
Definition: slhaea.h:2220
void trim_right(std::string &str)
Definition: slhaea.h:103
const_reverse_iterator rbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Coll...
Definition: slhaea.h:1966
Line & str(const std::string &line)
Assigns content to the Line based on a string.
Definition: slhaea.h:263
iterator erase_last(const key_type &key)
Erases last Line that matches the provided key.
Definition: slhaea.h:1442
Target to(const Source &arg)
Converts an object of type Source to an object of type Target.
Definition: slhaea.h:44
const_iterator cbegin() const
Returns a read-only (constant) iterator that points to the first element in the Block.
Definition: slhaea.h:1134
void push_back(const std::string &line)
Adds a Line to the end of the Block.
Definition: slhaea.h:1347
Key(const char *keyString)
Constructs a Key from a string.
Definition: slhaea.h:2462
const_reverse_iterator crend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Bl...
Definition: slhaea.h:1215
iterator find(const value_type::key_type &key)
Tries to locate a Block in the Coll.
Definition: slhaea.h:2067
impl_type::const_iterator const_iterator
Definition: slhaea.h:156
size_type data_size() const
Returns the number of elements without the comment in the Line.
Definition: slhaea.h:537
std::string to_string(const Source &arg)
Converts an object of type Source to a string.
Definition: slhaea.h:56
bool operator>=(const Line &a, const Line &b)
Definition: slhaea.h:2596
reference operator[](const std::string &key)
Locates a Line in the Block.
Definition: slhaea.h:925
reference at(const value_type::key_type &key)
Locates a Block in the Coll.
Definition: slhaea.h:1774
void set_key(const key_type &blockName)
Definition: slhaea.h:2358
const_reverse_iterator crbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Line...
Definition: slhaea.h:470
const_reference front() const
Returns a read-only (constant) reference to the first element of the Block.
Definition: slhaea.h:1092
reference at(const key_type &key)
Locates a Line in the Block.
Definition: slhaea.h:953
Line & reference
Definition: slhaea.h:732
void uncomment()
Uncomments the Line.
Definition: slhaea.h:628
std::string to_upper_copy(const std::string &str)
Definition: slhaea.h:86
static Coll from_str(const std::string &coll)
Constructs a Coll with content from a string.
Definition: slhaea.h:1647
const_reference at(const key_type &key) const
Locates a Line in the Block.
Definition: slhaea.h:973
impl_type::pointer pointer
Definition: slhaea.h:738
void push_back(const value_type &line)
Adds a Line to the end of the Block.
Definition: slhaea.h:1335
key_matches(const key_type &blockName)
Definition: slhaea.h:2351
size_type count(const key_type &blockName) const
Counts all Blocks with a given name.
Definition: slhaea.h:2114
void pop_back()
Removes the last element.
Definition: slhaea.h:1355
iterator erase(iterator first, iterator last)
Erases a range of elements.
Definition: slhaea.h:1409
const std::string & const_reference
Definition: slhaea.h:154
Coll & read(std::istream &is)
Assigns content from an input stream to the Coll.
Definition: slhaea.h:1663
const_iterator end() const
Returns a read-only (constant) iterator that points one past the last element in the Block...
Definition: slhaea.h:1152
impl_type::const_pointer const_pointer
Definition: slhaea.h:160
std::istream & operator>>(std::istream &is, Block &block)
Definition: slhaea.h:2528
const_reverse_iterator crend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Li...
Definition: slhaea.h:497
Block value_type
Definition: slhaea.h:1614
void reformat()
Reformats all Blocks in the Coll.
Definition: slhaea.h:2325
Block::reference line(const Key &key)
Accesses a single Line in the Coll.
Definition: slhaea.h:2510
const_reference at(size_type n) const
Provides access to the strings contained in the Line.
Definition: slhaea.h:360
impl_type::size_type size_type
Definition: slhaea.h:162
const_reverse_iterator crbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Coll...
Definition: slhaea.h:1975
iterator end()
Returns a read/write iterator that points one past the last element in the Block. ...
Definition: slhaea.h:1143
Unary predicate that checks if a provided key matches a Line.
Definition: slhaea.h:1522
iterator insert(iterator position, const value_type &line)
Inserts a Line before given position.
Definition: slhaea.h:1368
void set_key(const value_type::key_type &key)
Definition: slhaea.h:2383
iterator begin()
Returns a read/write iterator that points to the first element in the Line.
Definition: slhaea.h:399
Coll()
Constructs an empty Coll.
Definition: slhaea.h:1631
bool operator<=(const Line &a, const Line &b)
Definition: slhaea.h:2592
void swap(Coll &coll)
Swaps data with another Coll.
Definition: slhaea.h:2312
const_iterator end() const
Returns a read-only (constant) iterator that points one past the last element in the Coll...
Definition: slhaea.h:1940
iterator end()
Returns a read/write iterator that points one past the last element in the Coll.
Definition: slhaea.h:1931
void comment()
Comments all Lines in the Block.
Definition: slhaea.h:1510
key_matches_block_def(const value_type::key_type &key)
Definition: slhaea.h:2372
const std::string & name() const
Returns the name of the Block.
Definition: slhaea.h:787
reference at(const key_type &blockName)
Locates a Block in the Coll.
Definition: slhaea.h:1736
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:737
iterator end()
Returns a read/write iterator that points one past the last element in the Line.
Definition: slhaea.h:426
Line & operator<<(const T &field)
Inserts an element at the end of the Line.
Definition: slhaea.h:217
Block & reference
Definition: slhaea.h:1615
impl_type::const_iterator const_iterator
Definition: slhaea.h:735
const_reverse_iterator rend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Li...
Definition: slhaea.h:488
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Block.
Definition: slhaea.h:1125
const_iterator cend() const
Returns a read-only (constant) iterator that points one past the last element in the Coll...
Definition: slhaea.h:1949
impl_type::const_iterator const_iterator
Definition: slhaea.h:1618
void name(const std::string &newName)
Sets the name of the Block.
Definition: slhaea.h:782
Key & str(const std::string &keyString)
Converts a string to a Key.
Definition: slhaea.h:2471
reference back()
Returns a read/write reference to the last element of the Coll.
Definition: slhaea.h:1825
bool empty() const
Returns true if the Line is empty.
Definition: slhaea.h:547
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.
Definition: slhaea.h:1075
std::string & reference
Definition: slhaea.h:153
reference front()
Returns a read/write reference to the first element of the Line.
Definition: slhaea.h:367
void clear()
Erases all the elements in the Block and set its name to an empty string.
Definition: slhaea.h:1491
Coll::key_type block
Name of the Block that contains the field.
Definition: slhaea.h:2430
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:158
Unary predicate that checks if a provided name matches the name of a Block.
Definition: slhaea.h:2348
Line(const std::string &line)
Constructs a Line from a string.
Definition: slhaea.h:176
reference back()
Returns a read/write reference to the last element of the Line.
Definition: slhaea.h:382
iterator erase_first(const key_type &key)
Erases first Line that matches the provided key.
Definition: slhaea.h:1424
void comment()
Comments all Blocks in the Coll.
Definition: slhaea.h:2333
static InputIterator find(InputIterator first, InputIterator last, const value_type::key_type &key)
Tries to locate a Block in a range.
Definition: slhaea.h:2103
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Block...
Definition: slhaea.h:1197
bool operator==(const Line &a, const Line &b)
Definition: slhaea.h:2568
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.
Definition: slhaea.h:1059
Block(const std::string &name="")
Constructs an empty Block.
Definition: slhaea.h:752
iterator find(const key_type &key)
Tries to locate a Line in the Block.
Definition: slhaea.h:1232
Block(std::istream &is)
Constructs a Block with content from an input stream.
Definition: slhaea.h:760
void insert(iterator position, InputIterator first, InputIterator last)
Inserts a range into the Block.
Definition: slhaea.h:1382
Line & operator+=(const std::string &arg)
Appends a string to the end of the Line.
Definition: slhaea.h:201
Key(const Coll::key_type &_block, const Block::key_type &_line, const Line::size_type &_field)
Constructs a Key from explicit key values.
Definition: slhaea.h:2444
Block::key_type line
First field(s) of the Line that contains the field.
Definition: slhaea.h:2433
bool operator()(const value_type &block) const
Definition: slhaea.h:2376
bool is_all_whitespace(const std::string &str)
Definition: slhaea.h:82
const_reverse_iterator rend() const
Returns a read-only (constant) reverse iterator that points to one before the first element in the Co...
Definition: slhaea.h:1993
Line::reference field(const Key &key)
Accesses a single field in the Coll.
Definition: slhaea.h:2518
void push_front(const value_type &block)
Adds a Block to the begin of the Coll.
Definition: slhaea.h:2169
const_reference at(const std::vector< int > &key) const
Locates a Line in the Block.
Definition: slhaea.h:1007
void reformat()
Reformats the string representation of the Line.
Definition: slhaea.h:572
const_iterator find(const key_type &blockName) const
Tries to locate a Block in the Coll.
Definition: slhaea.h:2033
std::string key_type
Definition: slhaea.h:1613
size_type size() const
Returns the number of elements in the Line.
Definition: slhaea.h:530
const_iterator cend() const
Returns a read-only (constant) iterator that points one past the last element in the Block...
Definition: slhaea.h:1161
const_iterator cbegin() const
Returns a read-only (constant) iterator that points to the first element in the Coll.
Definition: slhaea.h:1922
void reformat()
Reformats all Lines in the Block.
Definition: slhaea.h:1502
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Line.
Definition: slhaea.h:452
std::string str() const
Returns a string representation of the Coll.
Definition: slhaea.h:1700
size_type data_size() const
Returns the number of data Lines in the Block.
Definition: slhaea.h:1310
const_iterator find(const value_type::key_type &key) const
Tries to locate a Block in the Coll.
Definition: slhaea.h:2084
Unary predicate that checks if a provided key matches the block definition of a Block.
Definition: slhaea.h:2369
bool operator()(const value_type &block) const
Definition: slhaea.h:2354
Container of Blocks that resembles a complete SLHA structure.
Definition: slhaea.h:1607
const_iterator end() const
Returns a read-only (constant) iterator that points one past the last element in the Line...
Definition: slhaea.h:435
impl_type::const_pointer const_pointer
Definition: slhaea.h:739
iterator erase_first(const key_type &blockName)
Erases first Block with a given name.
Definition: slhaea.h:2261
reference operator[](const key_type &key)
Locates a Line in the Block.
Definition: slhaea.h:891
void comment()
Comments the Line.
Definition: slhaea.h:619
Line & operator=(const std::string &line)
Assigns content from a string to the Line.
Definition: slhaea.h:187
bool empty() const
Returns true if the Coll is empty.
Definition: slhaea.h:2130
impl_type::iterator iterator
Definition: slhaea.h:734
impl_type::pointer pointer
Definition: slhaea.h:159
const_reverse_iterator rbegin() const
Returns a read-only (constant) reverse iterator that points to the last element in the Block...
Definition: slhaea.h:1179
reference front()
Returns a read/write reference to the first element of the Block.
Definition: slhaea.h:1084
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.
Definition: slhaea.h:1023
std::string str() const
Converts a Key into its string representation.
Definition: slhaea.h:2492
const_reference back() const
Returns a read-only (constant) reference to the last element of the Line.
Definition: slhaea.h:390