flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
slhaea.h
Go to the documentation of this file.
1// SLHAea - containers for SUSY Les Houches Accord input/output
2// Copyright © 2009-2011 Frank S. Thomas <frank@timepit.eu>
3//
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7
8#ifndef SLHAEA_H
9#define SLHAEA_H
10
11#include <algorithm>
12#include <cctype>
13#include <cstddef>
14#include <deque>
15#include <functional>
16#include <iomanip>
17#include <iostream>
18#include <iterator>
19#include <limits>
20#include <sstream>
21#include <stdexcept>
22#include <string>
23#include <utility>
24#include <vector>
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>
30
31#if __cplusplus <= 199711L
32#define MEM_FN std::mem_fun_ref
33#else
34#define MEM_FN std::mem_fn
35#endif
36
37namespace SLHAea {
38
39// auxiliary functions
49template<class Target, class Source> inline Target
50to(const Source& arg)
51{ return boost::lexical_cast<Target>(arg); }
52
61template<class Source> inline std::string
62to_string(const Source& arg)
63{ return boost::lexical_cast<std::string>(arg); }
64
76template<class Source> inline std::string
77to_string(const Source& arg, int precision)
78{
79 std::ostringstream output;
80 output << std::setprecision(precision) << std::scientific << arg;
81 return output.str();
82}
83
84
85namespace detail {
86
87inline bool
88is_all_whitespace(const std::string& str)
89{ return str.find_first_not_of(" \t\n\v\f\r") == std::string::npos; }
90
91inline std::string
92to_upper_copy(const std::string& str)
93{
94 std::string str_upper(str.length(), char());
95 std::transform(str.begin(), str.end(), str_upper.begin(),
96 static_cast<int (*)(int)>(std::toupper));
97 return str_upper;
98}
99
100inline void
101trim_left(std::string& str)
102{
103 const std::size_t startpos = str.find_first_not_of(" \t\n\v\f\r");
104 if (startpos != std::string::npos) str.erase(0, startpos);
105 else str.clear();
106}
107
108inline void
109trim_right(std::string& str)
110{
111 const std::size_t endpos = str.find_last_not_of(" \t\n\v\f\r");
112 if (endpos != std::string::npos) str.erase(endpos + 1);
113 else str.clear();
114}
115
116} // namespace detail
117
118
119// forward declarations
120class Line;
121class Block;
122class Coll;
123struct Key;
124
125inline std::ostream& operator<<(std::ostream& os, const Line& line);
126inline std::ostream& operator<<(std::ostream& os, const Block& block);
127inline std::ostream& operator<<(std::ostream& os, const Coll& coll);
128inline std::ostream& operator<<(std::ostream& os, const Key& key);
129
130
152class Line
153{
154private:
155 typedef std::vector<std::string> impl_type;
156
157public:
158 typedef std::string value_type;
159 typedef std::string& reference;
160 typedef const std::string& const_reference;
161 typedef impl_type::iterator iterator;
162 typedef impl_type::const_iterator const_iterator;
163 typedef impl_type::reverse_iterator reverse_iterator;
164 typedef impl_type::const_reverse_iterator const_reverse_iterator;
165 typedef impl_type::pointer pointer;
166 typedef impl_type::const_pointer const_pointer;
167 typedef impl_type::difference_type difference_type;
168 typedef impl_type::size_type size_type;
169
170 // NOTE: The compiler-generated copy constructor and assignment
171 // operator for this class are just fine, so we don't need to
172 // write our own.
173
175 Line() : impl_(), columns_() {}
176
182 Line(const std::string& line) : impl_(), columns_()
183 { str(line); }
184
192 Line&
193 operator=(const std::string& line)
194 {
195 str(line);
196 return *this;
197 }
198
206 Line&
207 operator+=(const std::string& arg)
208 {
209 append(arg);
210 return *this;
211 }
212
222 template<class T> Line&
223 operator<<(const T& field)
224 {
225 std::string field_str = to_string(field);
226 detail::trim_right(field_str);
227 if (field_str.empty()) return *this;
228
229 if (contains_comment())
230 { back() += field_str; }
231 else
232 {
233 detail::trim_left(field_str);
234 impl_.push_back(field_str);
235 reformat();
236 }
237 return *this;
238 }
239
249 Line&
250 append(const std::string& arg)
251 {
252 str(str() + arg);
253 return *this;
254 }
255
268 Line&
269 str(const std::string& line)
270 {
271 clear();
272 static const std::string whitespace = " \t\v\f\r";
273 const std::size_t last_non_ws =
274 line.substr(0, line.find('\n')).find_last_not_of(whitespace);
275 if (last_non_ws == std::string::npos) return *this;
276
277 const std::string trimmed_line = line.substr(0, last_non_ws + 1);
278 const std::size_t comment_pos = trimmed_line.find('#');
279 const std::string data = trimmed_line.substr(0, comment_pos);
280
281 std::size_t pos1 = data.find_first_not_of(whitespace, 0);
282 std::size_t pos2 = data.find_first_of(whitespace, pos1);
283
284 while (pos1 != std::string::npos)
285 {
286 impl_.push_back(data.substr(pos1, pos2 - pos1));
287 columns_.push_back(pos1);
288
289 pos1 = data.find_first_not_of(whitespace, pos2);
290 pos2 = data.find_first_of(whitespace, pos1);
291 }
292
293 if (comment_pos != std::string::npos)
294 {
295 impl_.push_back(trimmed_line.substr(comment_pos));
296 columns_.push_back(comment_pos);
297 }
298 return *this;
299 }
300
302 std::string
303 str() const
304 {
305 if (empty()) return "";
306
307 std::ostringstream output;
308 int length = 0, spaces = 0;
309
310 const_iterator field = begin();
311 std::vector<std::size_t>::const_iterator column = columns_.begin();
312 for (; field != end() && column != columns_.end(); ++field, ++column)
313 {
314 spaces = std::max(0, static_cast<int>(*column) - length + 1);
315 length += spaces + field->length();
316
317 output << std::setw(spaces) << " " << *field;
318 }
319 return output.str().substr(1);
320 }
321
322 // element access
334 { return impl_[n]; }
335
347 { return impl_[n]; }
348
357 { return impl_.at(n); }
358
366 at(size_type n) const
367 { return impl_.at(n); }
368
374 { return impl_.front(); }
375
381 front() const
382 { return impl_.front(); }
383
389 { return impl_.back(); }
390
396 back() const
397 { return impl_.back(); }
398
399 // iterators
406 { return impl_.begin(); }
407
414 begin() const
415 { return impl_.begin(); }
416
423 cbegin() const
424 { return impl_.begin(); }
425
433 { return impl_.end(); }
434
441 end() const
442 { return impl_.end(); }
443
450 cend() const
451 { return impl_.end(); }
452
459 { return impl_.rbegin(); }
460
467 rbegin() const
468 { return impl_.rbegin(); }
469
476 crbegin() const
477 { return impl_.rbegin(); }
478
486 { return impl_.rend(); }
487
494 rend() const
495 { return impl_.rend(); }
496
503 crend() const
504 { return impl_.rend(); }
505
506 // introspection
511 bool
513 {
514 if (size() < 2) return false;
515
516 const_iterator field = begin();
517 return is_block_specifier(*field) && !is_comment(*++field);
518 }
519
521 bool
523 { return !empty() && is_comment(front()); }
524
529 bool
531 { return !empty() && !is_comment(front()) && !is_block_specifier(front()); }
532
533 // capacity
536 size() const
537 { return impl_.size(); }
538
543 data_size() const
544 { return std::distance(begin(), std::find_if(begin(), end(), is_comment)); }
545
548 max_size() const
549 { return impl_.max_size(); }
550
552 bool
553 empty() const
554 { return impl_.empty(); }
555
556 // modifiers
561 void
562 swap(Line& line)
563 {
564 impl_.swap(line.impl_);
565 columns_.swap(line.columns_);
566 }
567
569 void
571 {
572 impl_.clear();
573 columns_.clear();
574 }
575
577 void
579 {
580 if (empty()) return;
581
582 columns_.clear();
583 const_iterator field = begin();
584 std::size_t pos1 = 0, pos2 = 0;
585
586 if (is_block_specifier(*field))
587 {
588 pos1 = 0;
589 pos2 = pos1 + field->length();
590 columns_.push_back(pos1);
591
592 if (++field == end()) return;
593
594 pos1 = pos2 + 1;
595 pos2 = pos1 + field->length();
596 columns_.push_back(pos1);
597 }
598 else if (is_comment(*field))
599 {
600 pos1 = 0;
601 pos2 = pos1 + field->length();
602 columns_.push_back(pos1);
603 }
604 else
605 {
606 pos1 = shift_width_;
607 pos2 = pos1 + field->length();
608 columns_.push_back(pos1);
609 }
610
611 while (++field != end())
612 {
613 pos1 = pos2 + calc_spaces_for_indent(pos2);
614 if (starts_with_sign(*field)) --pos1;
615 pos2 = pos1 + field->length();
616 columns_.push_back(pos1);
617 }
618 }
619
624 void
626 { if (!empty()) str("#" + str()); }
627
633 void
635 {
636 if (!empty() && is_comment(front()))
637 {
638 front().erase(0, 1);
639 str(str());
640 }
641 }
642
643private:
644 bool
646 { return std::find_if(rbegin(), rend(), is_comment) != rend(); }
647
648 static std::size_t
649 calc_spaces_for_indent(const std::size_t& pos)
650 {
651 std::size_t width = shift_width_ - (pos % shift_width_);
652 if (width < min_width_) width += shift_width_;
653 return width;
654 }
655
656 static bool
658 {
659 static const std::size_t specifier_length = 5;
660 if (field.length() != specifier_length) return false;
661
662 const value_type field_upper = detail::to_upper_copy(field);
663 return (field_upper == "BLOCK") || (field_upper == "DECAY");
664 }
665
666 static bool
667 is_comment(const value_type& field)
668 { return !field.empty() && field[0] == '#'; }
669
670 template<class T> Line&
672 {
673 static const int digits = std::numeric_limits<T>::digits10;
674 return *this << to_string(arg, digits);
675 }
676
677 static bool
679 { return !field.empty() && (field[0] == '-' || field[0] == '+'); }
680
681private:
683 std::vector<std::size_t> columns_;
684
685 static const std::size_t shift_width_ = 4;
686 static const std::size_t min_width_ = 2;
687};
688
689template<> inline Line&
690Line::operator<< <float>(const float& number)
691{
693 return *this;
694}
695
696template<> inline Line&
697Line::operator<< <double>(const double& number)
698{
700 return *this;
701}
702
703template<> inline Line&
704Line::operator<< <long double>(const long double& number)
705{
707 return *this;
708}
709
710
730class Block
731{
732private:
733 typedef std::vector<Line> impl_type;
734
735public:
736 typedef std::vector<std::string> key_type;
738 typedef Line& reference;
739 typedef const Line& const_reference;
740 typedef impl_type::iterator iterator;
741 typedef impl_type::const_iterator const_iterator;
742 typedef impl_type::reverse_iterator reverse_iterator;
743 typedef impl_type::const_reverse_iterator const_reverse_iterator;
744 typedef impl_type::pointer pointer;
745 typedef impl_type::const_pointer const_pointer;
746 typedef impl_type::difference_type difference_type;
747 typedef impl_type::size_type size_type;
748
749 // NOTE: The compiler-generated copy constructor and assignment
750 // operator for this class are just fine, so we don't need to
751 // write our own.
752
757 explicit
758 Block(const std::string& name = "") : name_(name), impl_() {}
759
765 explicit
766 Block(std::istream& is) : name_(), impl_()
767 { read(is); }
768
773 static Block
774 from_str(const std::string& block)
775 {
776 std::istringstream input(block);
777 return Block(input);
778 }
779
787 void
788 name(const std::string& newName)
789 { name_ = newName; }
790
792 const std::string&
793 name() const
794 { return name_; }
795
803 void
804 rename(const std::string& newName)
805 {
806 name(newName);
807 iterator block_def = find_block_def();
808 if (block_def != end()) (*block_def)[1] = newName;
809 }
810
823 Block&
824 read(std::istream& is)
825 {
826 std::string line_str;
827 value_type line;
828
829 std::size_t def_count = 0;
830 bool nameless = name().empty();
831
832 while (std::getline(is, line_str))
833 {
834 if (detail::is_all_whitespace(line_str)) continue;
835
836 line.str(line_str);
837 if (line.is_block_def())
838 {
839 if (++def_count > 1)
840 {
841 is.seekg(-static_cast<std::ptrdiff_t>(line_str.length() + 1), std::ios_base::cur);
842 break;
843 }
844 if (nameless)
845 {
846 name(line[1]);
847 nameless = false;
848 }
849 }
850 push_back(line);
851 }
852 return *this;
853 }
854
867 Block&
868 str(const std::string& block)
869 {
870 std::istringstream input(block);
871 clear();
872 read(input);
873 return *this;
874 }
875
877 std::string
878 str() const
879 {
880 std::ostringstream output;
881 output << *this;
882 return output.str();
883 }
884
885 // element access
898 {
899 iterator line = find(key);
900 if (line != end()) return *line;
901
903 return back();
904 }
905
918 operator[](const std::vector<int>& key)
919 { return (*this)[cont_to_key(key)]; }
920
931 operator[](const std::string& key)
932 { return (*this)[key_type(1, key)]; }
933
945 operator[](int key)
946 { return (*this)[key_type(1, to_string(key))]; }
947
959 at(const key_type& key)
960 {
961 iterator line = find(key);
962 if (line != end()) return *line;
963
964 throw std::out_of_range(
965 "SLHAea::Block::at(‘" + boost::join(key, ",") + "’)");
966 }
967
979 at(const key_type& key) const
980 {
981 const_iterator line = find(key);
982 if (line != end()) return *line;
983
984 throw std::out_of_range(
985 "SLHAea::Block::at(‘" + boost::join(key, ",") + "’)");
986 }
987
999 at(const std::vector<int>& key)
1000 { return at(cont_to_key(key)); }
1001
1013 at(const std::vector<int>& key) const
1014 { return at(cont_to_key(key)); }
1015
1028 reference
1029 at(const std::string& s0, const std::string& s1 = "",
1030 const std::string& s2 = "", const std::string& s3 = "",
1031 const std::string& s4 = "")
1032 { return at(strings_to_key(s0, s1, s2, s3, s4)); }
1033
1047 at(const std::string& s0, const std::string& s1 = "",
1048 const std::string& s2 = "", const std::string& s3 = "",
1049 const std::string& s4 = "") const
1050 { return at(strings_to_key(s0, s1, s2, s3, s4)); }
1051
1064 reference
1065 at(int i0, int i1 = no_index_, int i2 = no_index_,
1066 int i3 = no_index_, int i4 = no_index_)
1067 { return at(ints_to_key(i0, i1, i2, i3, i4)); }
1068
1081 at(int i0, int i1 = no_index_, int i2 = no_index_,
1082 int i3 = no_index_, int i4 = no_index_) const
1083 { return at(ints_to_key(i0, i1, i2, i3, i4)); }
1084
1089 reference
1091 { return impl_.front(); }
1092
1098 front() const
1099 { return impl_.front(); }
1100
1104 reference
1106 { return impl_.back(); }
1107
1113 back() const
1114 { return impl_.back(); }
1115
1116 // iterators
1121 iterator
1123 { return impl_.begin(); }
1124
1131 begin() const
1132 { return impl_.begin(); }
1133
1140 cbegin() const
1141 { return impl_.begin(); }
1142
1148 iterator
1150 { return impl_.end(); }
1151
1158 end() const
1159 { return impl_.end(); }
1160
1167 cend() const
1168 { return impl_.end(); }
1169
1177 { return impl_.rbegin(); }
1178
1185 rbegin() const
1186 { return impl_.rbegin(); }
1187
1194 crbegin() const
1195 { return impl_.rbegin(); }
1196
1204 { return impl_.rend(); }
1205
1212 rend() const
1213 { return impl_.rend(); }
1214
1221 crend() const
1222 { return impl_.rend(); }
1223
1224 // lookup
1237 iterator
1238 find(const key_type& key)
1239 { return std::find_if(begin(), end(), key_matches(key)); }
1240
1254 find(const key_type& key) const
1255 { return std::find_if(begin(), end(), key_matches(key)); }
1256
1270 template<class InputIterator> static InputIterator
1271 find(InputIterator first, InputIterator last, const key_type& key)
1272 { return std::find_if(first, last, key_matches(key)); }
1273
1279 iterator
1281 {
1282 return std::find_if(begin(), end(),
1284 }
1285
1293 {
1294 return std::find_if(begin(), end(),
1296 }
1297
1298 // introspection
1304 size_type
1305 count(const key_type& key) const
1306 { return std::count_if(begin(), end(), key_matches(key)); }
1307
1308 // capacity
1310 size_type
1311 size() const
1312 { return impl_.size(); }
1313
1315 size_type
1317 {
1318 return std::count_if(begin(), end(),
1320 }
1321
1323 size_type
1324 max_size() const
1325 { return impl_.max_size(); }
1326
1328 bool
1329 empty() const
1330 { return impl_.empty(); }
1331
1332 // modifiers
1340 void
1342 { impl_.push_back(line); }
1343
1352 void
1353 push_back(const std::string& line)
1354 { impl_.push_back(value_type(line)); }
1355
1360 void
1362 { impl_.pop_back(); }
1363
1373 iterator
1374 insert(iterator position, const value_type& line)
1375 { return impl_.insert(position, line); }
1376
1387 template<class InputIterator> void
1388 insert(iterator position, InputIterator first, InputIterator last)
1389 { impl_.insert(position, first, last); }
1390
1399 iterator
1400 erase(iterator position)
1401 { return impl_.erase(position); }
1402
1414 iterator
1416 { return impl_.erase(first, last); }
1417
1429 iterator
1431 {
1432 iterator line = find(key);
1433 return (line != end()) ? erase(line) : line;
1434 }
1435
1447 iterator
1449 {
1450 reverse_iterator line = find(rbegin(), rend(), key);
1451 return (line != rend()) ? erase((++line).base()) : end();
1452 }
1453
1463 size_type
1464 erase(const key_type& key)
1465 {
1466 const key_matches pred(key);
1467 size_type erased_count = 0;
1468
1469 for (iterator line = begin(); line != end();)
1470 {
1471 if (pred(*line))
1472 {
1473 line = erase(line);
1474 ++erased_count;
1475 }
1476 else ++line;
1477 }
1478 return erased_count;
1479 }
1480
1485 void
1486 swap(Block& block)
1487 {
1488 name_.swap(block.name_);
1489 impl_.swap(block.impl_);
1490 }
1491
1496 void
1498 {
1499 name_.clear();
1500 impl_.clear();
1501 }
1502
1507 void
1510
1515 void
1518
1523 void
1526
1529 {
1530 explicit
1531 key_matches(const key_type& key) : key_(key) {}
1532
1533 bool
1534 operator()(const value_type& line) const
1535 {
1536 return (key_.empty() || key_.size() > line.size()) ? false :
1537 std::equal(key_.begin(), key_.end(), line.begin(), parts_equal);
1538 }
1539
1540 void
1541 set_key(const key_type& key)
1542 { key_ = key; }
1543
1544 private:
1545 static bool
1546 parts_equal(const std::string& key_part, const std::string& field)
1547 { return (key_part == "(any)") || boost::iequals(key_part, field); }
1548
1549 private:
1551 };
1552
1553private:
1554 template<class Container> static key_type
1555 cont_to_key(const Container& cont)
1556 {
1557 key_type key;
1558 key.reserve(cont.size());
1559 std::string (*to_string)(const typename Container::value_type&) =
1560 boost::lexical_cast<std::string, typename Container::value_type>;
1561 std::transform(cont.begin(), cont.end(), std::back_inserter(key),
1562 to_string);
1563 return key;
1564 }
1565
1566 static key_type
1567 strings_to_key(const std::string& s0, const std::string& s1,
1568 const std::string& s2, const std::string& s3,
1569 const std::string& s4)
1570 {
1571 key_type key;
1572 key.reserve(5);
1573 if (s0.empty()) { return key; } key.push_back(s0);
1574 if (s1.empty()) { return key; } key.push_back(s1);
1575 if (s2.empty()) { return key; } key.push_back(s2);
1576 if (s3.empty()) { return key; } key.push_back(s3);
1577 if (s4.empty()) { return key; } key.push_back(s4);
1578 return key;
1579 }
1580
1581 static key_type
1582 ints_to_key(int i0, int i1, int i2, int i3, int i4)
1583 {
1584 key_type key;
1585 key.reserve(5);
1586 if (i0 == no_index_) { return key; } key.push_back(to_string(i0));
1587 if (i1 == no_index_) { return key; } key.push_back(to_string(i1));
1588 if (i2 == no_index_) { return key; } key.push_back(to_string(i2));
1589 if (i3 == no_index_) { return key; } key.push_back(to_string(i3));
1590 if (i4 == no_index_) { return key; } key.push_back(to_string(i4));
1591 return key;
1592 }
1593
1594private:
1595 std::string name_;
1597 static const int no_index_ = -32768;
1598};
1599
1600
1613class Coll
1614{
1615private:
1616 typedef std::deque<Block> impl_type;
1617
1618public:
1619 typedef std::string key_type;
1622 typedef const Block& const_reference;
1623 typedef impl_type::iterator iterator;
1624 typedef impl_type::const_iterator const_iterator;
1625 typedef impl_type::reverse_iterator reverse_iterator;
1626 typedef impl_type::const_reverse_iterator const_reverse_iterator;
1627 typedef impl_type::pointer pointer;
1628 typedef impl_type::const_pointer const_pointer;
1629 typedef impl_type::difference_type difference_type;
1630 typedef impl_type::size_type size_type;
1631
1632 // NOTE: The compiler-generated copy constructor and assignment
1633 // operator for this class are just fine, so we don't need to
1634 // write our own.
1635
1637 Coll() : impl_() {}
1638
1644 explicit
1645 Coll(std::istream& is) : impl_()
1646 { read(is); }
1647
1652 static Coll
1653 from_str(const std::string& coll)
1654 {
1655 std::istringstream input(coll);
1656 return Coll(input);
1657 }
1658
1668 Coll&
1669 read(std::istream& is)
1670 {
1671 std::string line_str;
1672 Line line;
1673
1674 const size_type orig_size = size();
1676
1677 while (std::getline(is, line_str))
1678 {
1679 if (detail::is_all_whitespace(line_str)) continue;
1680
1681 line.str(line_str);
1684 }
1685
1686 erase_if_empty("", orig_size);
1687 return *this;
1688 }
1689
1695 Coll&
1696 str(const std::string& coll)
1697 {
1698 std::istringstream input(coll);
1699 clear();
1700 read(input);
1701 return *this;
1702 }
1703
1705 std::string
1706 str() const
1707 {
1708 std::ostringstream output;
1709 output << *this;
1710 return output.str();
1711 }
1712
1713 // element access
1724 reference
1725 operator[](const key_type& blockName)
1726 {
1727 iterator block = find(blockName);
1728 if (block != end()) return *block;
1729
1730 push_back(value_type(blockName));
1731 return back();
1732 }
1733
1741 reference
1742 at(const key_type& blockName)
1743 {
1744 iterator block = find(blockName);
1745 if (block != end()) return *block;
1746
1747 throw std::out_of_range("SLHAea::Coll::at(‘" + blockName + "’)");
1748 }
1749
1758 at(const key_type& blockName) const
1759 {
1760 const_iterator block = find(blockName);
1761 if (block != end()) return *block;
1762
1763 throw std::out_of_range("SLHAea::Coll::at(‘" + blockName + "’)");
1764 }
1765
1779 reference
1781 {
1782 iterator block = find(key);
1783 if (block != end()) return *block;
1784
1785 throw std::out_of_range(
1786 "SLHAea::Coll::at(‘" + boost::join(key, ",") + "’)");
1787 }
1788
1803 at(const value_type::key_type& key) const
1804 {
1805 const_iterator block = find(key);
1806 if (block != end()) return *block;
1807
1808 throw std::out_of_range(
1809 "SLHAea::Coll::at(‘" + boost::join(key, ",") + "’)");
1810 }
1811
1815 reference
1817 { return impl_.front(); }
1818
1824 front() const
1825 { return impl_.front(); }
1826
1830 reference
1832 { return impl_.back(); }
1833
1839 back() const
1840 { return impl_.back(); }
1841
1842 // (nested) element access via Key
1850 reference
1851 block(const Key& key);
1852
1862 block(const Key& key) const;
1863
1871 line(const Key& key);
1872
1881 line(const Key& key) const;
1882
1891 field(const Key& key);
1892
1902 field(const Key& key) const;
1903
1904 // iterators
1909 iterator
1911 { return impl_.begin(); }
1912
1919 begin() const
1920 { return impl_.begin(); }
1921
1928 cbegin() const
1929 { return impl_.begin(); }
1930
1936 iterator
1938 { return impl_.end(); }
1939
1946 end() const
1947 { return impl_.end(); }
1948
1955 cend() const
1956 { return impl_.end(); }
1957
1964 { return impl_.rbegin(); }
1965
1972 rbegin() const
1973 { return impl_.rbegin(); }
1974
1981 crbegin() const
1982 { return impl_.rbegin(); }
1983
1991 { return impl_.rend(); }
1992
1999 rend() const
2000 { return impl_.rend(); }
2001
2008 crend() const
2009 { return impl_.rend(); }
2010
2011 // lookup
2023 iterator
2024 find(const key_type& blockName)
2025 { return std::find_if(begin(), end(), key_matches(blockName)); }
2026
2039 find(const key_type& blockName) const
2040 { return std::find_if(begin(), end(), key_matches(blockName)); }
2041
2055 template<class InputIterator> static InputIterator
2056 find(InputIterator first, InputIterator last, const key_type& blockName)
2057 { return std::find_if(first, last, key_matches(blockName)); }
2058
2072 iterator
2074 { return std::find_if(begin(), end(), key_matches_block_def(key)); }
2075
2090 find(const value_type::key_type& key) const
2091 { return std::find_if(begin(), end(), key_matches_block_def(key)); }
2092
2108 template<class InputIterator> static InputIterator
2109 find(InputIterator first, InputIterator last,
2110 const value_type::key_type& key)
2111 { return std::find_if(first, last, key_matches_block_def(key)); }
2112
2113 // introspection
2119 size_type
2120 count(const key_type& blockName) const
2121 { return std::count_if(begin(), end(), key_matches(blockName)); }
2122
2123 // capacity
2125 size_type
2126 size() const
2127 { return impl_.size(); }
2128
2130 size_type
2131 max_size() const
2132 { return impl_.max_size(); }
2133
2135 bool
2136 empty() const
2137 { return impl_.empty(); }
2138
2139 // modifiers
2147 void
2149 { impl_.push_back(block); }
2150
2159 void
2160 push_back(const std::string& blockString)
2161 {
2163 block.str(blockString);
2164 impl_.push_back(block);
2165 }
2166
2174 void
2176 { impl_.push_front(block); }
2177
2186 void
2187 push_front(const std::string& blockString)
2188 {
2190 block.str(blockString);
2191 impl_.push_front(block);
2192 }
2193
2198 void
2200 { impl_.pop_back(); }
2201
2211 iterator
2213 { return impl_.insert(position, block); }
2214
2225 template<class InputIterator> void
2226 insert(iterator position, InputIterator first, InputIterator last)
2227 { impl_.insert(position, first, last); }
2228
2237 iterator
2238 erase(iterator position)
2239 { return impl_.erase(position); }
2240
2252 iterator
2254 { return impl_.erase(first, last); }
2255
2266 iterator
2267 erase_first(const key_type& blockName)
2268 {
2269 iterator block = find(blockName);
2270 return (block != end()) ? erase(block) : block;
2271 }
2272
2283 iterator
2284 erase_last(const key_type& blockName)
2285 {
2286 reverse_iterator block = find(rbegin(), rend(), blockName);
2287 return (block != rend()) ? erase((++block).base()) : end();
2288 }
2289
2295 size_type
2296 erase(const key_type& blockName)
2297 {
2298 const key_matches pred(blockName);
2299 size_type erased_count = 0;
2300
2301 for (iterator block = begin(); block != end();)
2302 {
2303 if (pred(*block))
2304 {
2305 block = erase(block);
2306 ++erased_count;
2307 }
2308 else ++block;
2309 }
2310 return erased_count;
2311 }
2312
2317 void
2318 swap(Coll& coll)
2319 { impl_.swap(coll.impl_); }
2320
2322 void
2324 { impl_.clear(); }
2325
2330 void
2333
2338 void
2341
2346 void
2349
2355 {
2356 explicit
2357 key_matches(const key_type& blockName) : name_(blockName) {}
2358
2359 bool
2361 { return boost::iequals(name_, block.name()); }
2362
2363 void
2364 set_key(const key_type& blockName)
2365 { name_ = blockName; }
2366
2367 private:
2369 };
2370
2376 {
2377 explicit
2379 : key_matches_(key) {}
2380
2381 bool
2383 {
2385 return (block_def == block.end()) ? false : key_matches_(*block_def);
2386 }
2387
2388 void
2390 { key_matches_.set_key(key); }
2391
2392 private:
2394 };
2395
2396private:
2397 pointer
2399 {
2400 push_back(value_type(blockName));
2401 return &back();
2402 }
2403
2404 iterator
2405 erase_if_empty(const key_type& blockName, const size_type& offset = 0)
2406 {
2407 iterator block = find(begin() + offset, end(), blockName);
2408 return (block != end() && block->empty()) ? erase(block) : block;
2409 }
2410
2411private:
2413};
2414
2415
2432struct Key
2433{
2434public:
2437
2440
2443
2450 Key(const Coll::key_type& _block,
2451 const Block::key_type& _line,
2452 const Line::size_type& _field)
2453 : block(_block), line(_line), field(_field) {}
2454
2460 Key(const std::string& keyString)
2461 { str(keyString); }
2462
2468 Key(const char* keyString)
2469 { str(keyString); }
2470
2476 Key&
2477 str(const std::string& keyString)
2478 {
2479 std::vector<std::string> keys;
2480 boost::split(keys, keyString, boost::is_any_of(";"));
2481
2482 if (keys.size() != 3)
2483 { throw std::invalid_argument("SLHAea::Key::str(‘" + keyString + "’)"); }
2484
2485 block = keys[0];
2486 line.clear();
2487 boost::split(line, keys[1], boost::is_any_of(","));
2488 field = to<Line::size_type>(keys[2]);
2489
2490 return *this;
2491 }
2492
2497 std::string
2498 str() const
2499 {
2500 std::ostringstream output;
2501 output << block << ";" << boost::join(line, ",") << ";" << field;
2502 return output.str();
2503 }
2504};
2505
2506
2507inline Coll::reference
2508Coll::block(const Key& key)
2509{ return at(key.block); }
2510
2512Coll::block(const Key& key) const
2513{ return at(key.block); }
2514
2515inline Block::reference
2516Coll::line(const Key& key)
2517{ return block(key).at(key.line); }
2518
2520Coll::line(const Key& key) const
2521{ return block(key).at(key.line); }
2522
2523inline Line::reference
2524Coll::field(const Key& key)
2525{ return line(key).at(key.field); }
2526
2528Coll::field(const Key& key) const
2529{ return line(key).at(key.field); }
2530
2531
2532// stream operators
2533inline std::istream&
2534operator>>(std::istream& is, Block& block)
2535{
2536 block.read(is);
2537 return is;
2538}
2539
2540inline std::istream&
2541operator>>(std::istream& is, Coll& coll)
2542{
2543 coll.read(is);
2544 return is;
2545}
2546
2547inline std::ostream&
2548operator<<(std::ostream& os, const Line& line)
2549{ return os << line.str(); }
2550
2551inline std::ostream&
2552operator<<(std::ostream& os, const Block& block)
2553{
2554 std::copy(block.begin(), block.end(),
2555 std::ostream_iterator<Block::value_type>(os, "\n"));
2556 return os;
2557}
2558
2559inline std::ostream&
2560operator<<(std::ostream& os, const Coll& coll)
2561{
2562 std::copy(coll.begin(), coll.end(),
2563 std::ostream_iterator<Coll::value_type>(os));
2564 return os;
2565}
2566
2567inline std::ostream&
2568operator<<(std::ostream& os, const Key& key)
2569{ return os << key.str(); }
2570
2571
2572// relational operators for Line
2573inline bool
2574operator==(const Line& a, const Line& b)
2575{
2576 return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin())
2577 && a.str() == b.str();
2578}
2579
2580inline bool
2581operator<(const Line& a, const Line& b)
2582{
2583 const bool a_is_block_def = a.is_block_def();
2584
2585 return (a_is_block_def != b.is_block_def()) ? a_is_block_def :
2586 std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
2587}
2588
2589inline bool
2590operator!=(const Line& a, const Line& b)
2591{ return !(a == b); }
2592
2593inline bool
2594operator>(const Line& a, const Line& b)
2595{ return b < a; }
2596
2597inline bool
2598operator<=(const Line& a, const Line& b)
2599{ return !(b < a); }
2600
2601inline bool
2602operator>=(const Line& a, const Line& b)
2603{ return !(a < b); }
2604
2605
2606// relational operators for Block
2607inline bool
2608operator==(const Block& a, const Block& b)
2609{
2610 return a.size() == b.size() && a.name() == b.name()
2611 && std::equal(a.begin(), a.end(), b.begin());
2612}
2613
2614inline bool
2615operator<(const Block& a, const Block& b)
2616{
2617 return (a.name() != b.name()) ? a.name() < b.name() :
2618 std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
2619}
2620
2621inline bool
2622operator!=(const Block& a, const Block& b)
2623{ return !(a == b); }
2624
2625inline bool
2626operator>(const Block& a, const Block& b)
2627{ return b < a; }
2628
2629inline bool
2630operator<=(const Block& a, const Block& b)
2631{ return !(b < a); }
2632
2633inline bool
2634operator>=(const Block& a, const Block& b)
2635{ return !(a < b); }
2636
2637
2638// relational operators for Coll
2639inline bool
2640operator==(const Coll& a, const Coll& b)
2641{ return a.size() == b.size() && std::equal(a.begin(), a.end(), b.begin()); }
2642
2643inline bool
2644operator<(const Coll& a, const Coll& b)
2645{
2646 return std::lexicographical_compare(a.begin(), a.end(),
2647 b.begin(), b.end());
2648}
2649
2650inline bool
2651operator!=(const Coll& a, const Coll& b)
2652{ return !(a == b); }
2653
2654inline bool
2655operator>(const Coll& a, const Coll& b)
2656{ return b < a; }
2657
2658inline bool
2659operator<=(const Coll& a, const Coll& b)
2660{ return !(b < a); }
2661
2662inline bool
2663operator>=(const Coll& a, const Coll& b)
2664{ return !(a < b); }
2665
2666} // namespace SLHAea
2667
2668#undef MEM_FN
2669
2670#endif // SLHAEA_H
size_type size() const
Definition: slhaea.h:1311
void push_back(const value_type &line)
Adds a Line to the end of the Block.
Definition: slhaea.h:1341
iterator erase_first(const key_type &key)
Erases first Line that matches the provided key.
Definition: slhaea.h:1430
void insert(iterator position, InputIterator first, InputIterator last)
Inserts a range into the Block.
Definition: slhaea.h:1388
size_type erase(const key_type &key)
Erases all Lines that match the provided key.
Definition: slhaea.h:1464
iterator find(const key_type &key)
Tries to locate a Line in the Block.
Definition: slhaea.h:1238
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:1065
reference at(const std::vector< int > &key)
Locates a Line in the Block.
Definition: slhaea.h:999
impl_type::pointer pointer
Definition: slhaea.h:744
void uncomment()
Uncomments all Lines in the Block.
Definition: slhaea.h:1524
const_reference at(const key_type &key) const
Locates a Line in the Block.
Definition: slhaea.h:979
reference front()
Definition: slhaea.h:1090
void push_back(const std::string &line)
Adds a Line to the end of the Block.
Definition: slhaea.h:1353
iterator begin()
Definition: slhaea.h:1122
void rename(const std::string &newName)
Changes the name and definition of the Block.
Definition: slhaea.h:804
static key_type cont_to_key(const Container &cont)
Definition: slhaea.h:1555
void swap(Block &block)
Swaps data with another Block.
Definition: slhaea.h:1486
const_iterator find(const key_type &key) const
Tries to locate a Line in the Block.
Definition: slhaea.h:1254
const_reverse_iterator crend() const
Definition: slhaea.h:1221
const_iterator begin() const
Definition: slhaea.h:1131
const_iterator find_block_def() const
Definition: slhaea.h:1292
const_reference front() const
Definition: slhaea.h:1098
static key_type ints_to_key(int i0, int i1, int i2, int i3, int i4)
Definition: slhaea.h:1582
static Block from_str(const std::string &block)
Constructs a Block with content from a string.
Definition: slhaea.h:774
reverse_iterator rend()
Definition: slhaea.h:1203
const_reference at(const std::vector< int > &key) const
Locates a Line in the Block.
Definition: slhaea.h:1013
iterator erase(iterator position)
Erases element at given position.
Definition: slhaea.h:1400
iterator erase_last(const key_type &key)
Erases last Line that matches the provided key.
Definition: slhaea.h:1448
static const int no_index_
Definition: slhaea.h:1597
size_type max_size() const
Definition: slhaea.h:1324
reference back()
Definition: slhaea.h:1105
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:1081
size_type data_size() const
Definition: slhaea.h:1316
iterator find_block_def()
Definition: slhaea.h:1280
Line value_type
Definition: slhaea.h:737
Block(const std::string &name="")
Constructs an empty Block.
Definition: slhaea.h:758
void comment()
Comments all Lines in the Block.
Definition: slhaea.h:1516
size_type count(const key_type &key) const
Counts all Lines that match a given key.
Definition: slhaea.h:1305
iterator insert(iterator position, const value_type &line)
Inserts a Line before given position.
Definition: slhaea.h:1374
const_reverse_iterator rend() const
Definition: slhaea.h:1212
static InputIterator find(InputIterator first, InputIterator last, const key_type &key)
Tries to locate a Line in a range.
Definition: slhaea.h:1271
iterator end()
Definition: slhaea.h:1149
reference operator[](int key)
Locates a Line in the Block.
Definition: slhaea.h:945
std::vector< std::string > key_type
Definition: slhaea.h:736
impl_type::size_type size_type
Definition: slhaea.h:747
impl_type::const_iterator const_iterator
Definition: slhaea.h:741
impl_type::iterator iterator
Definition: slhaea.h:740
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:743
const_iterator cend() const
Definition: slhaea.h:1167
const_iterator end() const
Definition: slhaea.h:1158
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:1029
void pop_back()
Definition: slhaea.h:1361
iterator erase(iterator first, iterator last)
Erases a range of elements.
Definition: slhaea.h:1415
reference operator[](const std::vector< int > &key)
Locates a Line in the Block.
Definition: slhaea.h:918
const_iterator cbegin() const
Definition: slhaea.h:1140
static key_type strings_to_key(const std::string &s0, const std::string &s1, const std::string &s2, const std::string &s3, const std::string &s4)
Definition: slhaea.h:1567
Line & reference
Definition: slhaea.h:738
const Line & const_reference
Definition: slhaea.h:739
Block & str(const std::string &block)
Assigns content from a string to the Block.
Definition: slhaea.h:868
const_reference back() const
Definition: slhaea.h:1113
impl_type::const_pointer const_pointer
Definition: slhaea.h:745
void name(const std::string &newName)
Sets the name of the Block.
Definition: slhaea.h:788
impl_type::difference_type difference_type
Definition: slhaea.h:746
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:742
const_reverse_iterator rbegin() const
Definition: slhaea.h:1185
std::vector< Line > impl_type
Definition: slhaea.h:733
reverse_iterator rbegin()
Definition: slhaea.h:1176
std::string str() const
Definition: slhaea.h:878
Block & read(std::istream &is)
Assigns content from an input stream to the Block.
Definition: slhaea.h:824
reference operator[](const std::string &key)
Locates a Line in the Block.
Definition: slhaea.h:931
bool empty() const
Definition: slhaea.h:1329
reference at(const key_type &key)
Locates a Line in the Block.
Definition: slhaea.h:959
Block(std::istream &is)
Constructs a Block with content from an input stream.
Definition: slhaea.h:766
const_reverse_iterator crbegin() const
Definition: slhaea.h:1194
const std::string & name() const
Definition: slhaea.h:793
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:1047
std::string name_
Definition: slhaea.h:1595
void reformat()
Reformats all Lines in the Block.
Definition: slhaea.h:1508
void clear()
Definition: slhaea.h:1497
reference operator[](const key_type &key)
Locates a Line in the Block.
Definition: slhaea.h:897
impl_type impl_
Definition: slhaea.h:1596
iterator begin()
Definition: slhaea.h:1910
iterator erase_first(const key_type &blockName)
Erases first Block with a given name.
Definition: slhaea.h:2267
reference back()
Definition: slhaea.h:1831
std::deque< Block > impl_type
Definition: slhaea.h:1616
const_iterator find(const value_type::key_type &key) const
Tries to locate a Block in the Coll.
Definition: slhaea.h:2090
impl_type::size_type size_type
Definition: slhaea.h:1630
const_reference front() const
Definition: slhaea.h:1824
void swap(Coll &coll)
Swaps data with another Coll.
Definition: slhaea.h:2318
void uncomment()
Uncomments all Blocks in the Coll.
Definition: slhaea.h:2347
void push_front(const std::string &blockString)
Adds a Block to the begin of the Coll.
Definition: slhaea.h:2187
impl_type::difference_type difference_type
Definition: slhaea.h:1629
Block & reference
Definition: slhaea.h:1621
std::string key_type
Definition: slhaea.h:1619
iterator end()
Definition: slhaea.h:1937
reference block(const Key &key)
Accesses a Block in the Coll.
Definition: slhaea.h:2508
const_reference back() const
Definition: slhaea.h:1839
void clear()
Definition: slhaea.h:2323
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:1626
const_iterator cbegin() const
Definition: slhaea.h:1928
const_iterator end() const
Definition: slhaea.h:1946
const_reference at(const key_type &blockName) const
Locates a Block in the Coll.
Definition: slhaea.h:1758
impl_type::const_iterator const_iterator
Definition: slhaea.h:1624
void push_front(const value_type &block)
Adds a Block to the begin of the Coll.
Definition: slhaea.h:2175
const_reverse_iterator rbegin() const
Definition: slhaea.h:1972
iterator erase_last(const key_type &blockName)
Erases last Block with a given name.
Definition: slhaea.h:2284
Coll & str(const std::string &coll)
Assigns content from a string to the Coll.
Definition: slhaea.h:1696
impl_type::pointer pointer
Definition: slhaea.h:1627
Block value_type
Definition: slhaea.h:1620
void reformat()
Reformats all Blocks in the Coll.
Definition: slhaea.h:2331
iterator find(const key_type &blockName)
Tries to locate a Block in the Coll.
Definition: slhaea.h:2024
bool empty() const
Definition: slhaea.h:2136
void push_back(const std::string &blockString)
Adds a Block to the end of the Coll.
Definition: slhaea.h:2160
const_reverse_iterator rend() const
Definition: slhaea.h:1999
Coll(std::istream &is)
Constructs a Coll with content from an input stream.
Definition: slhaea.h:1645
void pop_back()
Definition: slhaea.h:2199
iterator find(const value_type::key_type &key)
Tries to locate a Block in the Coll.
Definition: slhaea.h:2073
const_reverse_iterator crbegin() const
Definition: slhaea.h:1981
const_reverse_iterator crend() const
Definition: slhaea.h:2008
size_type erase(const key_type &blockName)
Erases all Blocks with a given name.
Definition: slhaea.h:2296
impl_type::const_pointer const_pointer
Definition: slhaea.h:1628
reference at(const key_type &blockName)
Locates a Block in the Coll.
Definition: slhaea.h:1742
impl_type impl_
Definition: slhaea.h:2412
Coll & read(std::istream &is)
Assigns content from an input stream to the Coll.
Definition: slhaea.h:1669
size_type size() const
Definition: slhaea.h:2126
reverse_iterator rend()
Definition: slhaea.h:1990
void push_back(const value_type &block)
Adds a Block to the end of the Coll.
Definition: slhaea.h:2148
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:1625
impl_type::iterator iterator
Definition: slhaea.h:1623
size_type count(const key_type &blockName) const
Counts all Blocks with a given name.
Definition: slhaea.h:2120
pointer push_back_named_block(const key_type &blockName)
Definition: slhaea.h:2398
void comment()
Comments all Blocks in the Coll.
Definition: slhaea.h:2339
iterator erase(iterator first, iterator last)
Erases a range of elements.
Definition: slhaea.h:2253
reference front()
Definition: slhaea.h:1816
const_iterator find(const key_type &blockName) const
Tries to locate a Block in the Coll.
Definition: slhaea.h:2039
iterator insert(iterator position, const value_type &block)
Inserts a Block before given position.
Definition: slhaea.h:2212
void insert(iterator position, InputIterator first, InputIterator last)
Inserts a range into the Coll.
Definition: slhaea.h:2226
reverse_iterator rbegin()
Definition: slhaea.h:1963
iterator erase_if_empty(const key_type &blockName, const size_type &offset=0)
Definition: slhaea.h:2405
reference operator[](const key_type &blockName)
Locates a Block in the Coll.
Definition: slhaea.h:1725
Block::reference line(const Key &key)
Accesses a single Line in the Coll.
Definition: slhaea.h:2516
const_iterator cend() const
Definition: slhaea.h:1955
static Coll from_str(const std::string &coll)
Constructs a Coll with content from a string.
Definition: slhaea.h:1653
std::string str() const
Definition: slhaea.h:1706
const_reference at(const value_type::key_type &key) const
Locates a Block in the Coll.
Definition: slhaea.h:1803
static InputIterator find(InputIterator first, InputIterator last, const key_type &blockName)
Tries to locate a Block in a range.
Definition: slhaea.h:2056
size_type max_size() const
Definition: slhaea.h:2131
const Block & const_reference
Definition: slhaea.h:1622
reference at(const value_type::key_type &key)
Locates a Block in the Coll.
Definition: slhaea.h:1780
iterator erase(iterator position)
Erases element at given position.
Definition: slhaea.h:2238
static InputIterator find(InputIterator first, InputIterator last, const value_type::key_type &key)
Tries to locate a Block in a range.
Definition: slhaea.h:2109
Line::reference field(const Key &key)
Accesses a single field in the Coll.
Definition: slhaea.h:2524
const_iterator begin() const
Definition: slhaea.h:1919
reverse_iterator rbegin()
Definition: slhaea.h:458
impl_type::const_reverse_iterator const_reverse_iterator
Definition: slhaea.h:164
iterator end()
Definition: slhaea.h:432
void clear()
Definition: slhaea.h:570
size_type data_size() const
Definition: slhaea.h:543
impl_type::pointer pointer
Definition: slhaea.h:165
Line & insert_fundamental_type(const T &arg)
Definition: slhaea.h:671
bool is_data_line() const
Definition: slhaea.h:530
Line & append(const std::string &arg)
Appends a string to the end of the Line.
Definition: slhaea.h:250
static bool is_comment(const value_type &field)
Definition: slhaea.h:667
const_reverse_iterator rend() const
Definition: slhaea.h:494
reference operator[](size_type n)
Subscript access to the strings contained in the Line.
Definition: slhaea.h:333
const_iterator begin() const
Definition: slhaea.h:414
void uncomment()
Definition: slhaea.h:634
void reformat()
Definition: slhaea.h:578
impl_type::difference_type difference_type
Definition: slhaea.h:167
const_iterator cbegin() const
Definition: slhaea.h:423
const_reference front() const
Definition: slhaea.h:381
size_type max_size() const
Definition: slhaea.h:548
const_reverse_iterator crend() const
Definition: slhaea.h:503
std::vector< std::string > impl_type
Definition: slhaea.h:155
impl_type::reverse_iterator reverse_iterator
Definition: slhaea.h:163
Line(const std::string &line)
Constructs a Line from a string.
Definition: slhaea.h:182
std::string str() const
Definition: slhaea.h:303
reference front()
Definition: slhaea.h:373
reference at(size_type n)
Provides access to the strings contained in the Line.
Definition: slhaea.h:356
const_reference at(size_type n) const
Provides access to the strings contained in the Line.
Definition: slhaea.h:366
std::vector< std::size_t > columns_
Definition: slhaea.h:683
static const std::size_t min_width_
Definition: slhaea.h:686
size_type size() const
Definition: slhaea.h:536
static bool is_block_specifier(const value_type &field)
Definition: slhaea.h:657
impl_type::const_pointer const_pointer
Definition: slhaea.h:166
const_iterator end() const
Definition: slhaea.h:441
bool contains_comment() const
Definition: slhaea.h:645
static std::size_t calc_spaces_for_indent(const std::size_t &pos)
Definition: slhaea.h:649
Line & operator+=(const std::string &arg)
Appends a string to the end of the Line.
Definition: slhaea.h:207
Line & operator<<(const T &field)
Inserts an element at the end of the Line.
Definition: slhaea.h:223
static bool starts_with_sign(const value_type &field)
Definition: slhaea.h:678
impl_type::iterator iterator
Definition: slhaea.h:161
void comment()
Definition: slhaea.h:625
bool is_block_def() const
Definition: slhaea.h:512
reference back()
Definition: slhaea.h:388
std::string value_type
Definition: slhaea.h:158
const_iterator cend() const
Definition: slhaea.h:450
Line & operator=(const std::string &line)
Assigns content from a string to the Line.
Definition: slhaea.h:193
const std::string & const_reference
Definition: slhaea.h:160
std::string & reference
Definition: slhaea.h:159
bool empty() const
Definition: slhaea.h:553
Line & str(const std::string &line)
Assigns content to the Line based on a string.
Definition: slhaea.h:269
reverse_iterator rend()
Definition: slhaea.h:485
bool is_comment_line() const
Definition: slhaea.h:522
void swap(Line &line)
Swaps data with another Line.
Definition: slhaea.h:562
impl_type::size_type size_type
Definition: slhaea.h:168
static const std::size_t shift_width_
Definition: slhaea.h:685
const_reference back() const
Definition: slhaea.h:396
iterator begin()
Definition: slhaea.h:405
const_reverse_iterator rbegin() const
Definition: slhaea.h:467
impl_type impl_
Definition: slhaea.h:682
const_reverse_iterator crbegin() const
Definition: slhaea.h:476
const_reference operator[](size_type n) const
Subscript access to the strings contained in the Line.
Definition: slhaea.h:346
impl_type::const_iterator const_iterator
Definition: slhaea.h:162
void trim_right(std::string &str)
Definition: slhaea.h:109
std::string to_upper_copy(const std::string &str)
Definition: slhaea.h:92
void trim_left(std::string &str)
Definition: slhaea.h:101
bool is_all_whitespace(const std::string &str)
Definition: slhaea.h:88
std::istream & operator>>(std::istream &is, Block &block)
Definition: slhaea.h:2534
bool operator==(const Line &a, const Line &b)
Definition: slhaea.h:2574
bool operator!=(const Line &a, const Line &b)
Definition: slhaea.h:2590
bool operator<(const Line &a, const Line &b)
Definition: slhaea.h:2581
bool operator>(const Line &a, const Line &b)
Definition: slhaea.h:2594
std::ostream & operator<<(std::ostream &os, const Line &line)
Definition: slhaea.h:2548
bool operator<=(const Line &a, const Line &b)
Definition: slhaea.h:2598
std::string to_string(const Source &arg)
Converts an object of type Source to a string.
Definition: slhaea.h:62
Target to(const Source &arg)
Converts an object of type Source to an object of type Target.
Definition: slhaea.h:50
bool operator>=(const Line &a, const Line &b)
Definition: slhaea.h:2602
void for_each(T &&t, F f, seq< Is... >)
Definition: for_each.hpp:38
bool find_if(State &&state)
Definition: find_if.hpp:61
constexpr T arg(const Complex< T > &z) noexcept
Definition: complex.hpp:42
data
Definition: scan_HSSUSY.m:46
#define MEM_FN
Definition: slhaea.h:32
bool operator()(const value_type &line) const
Definition: slhaea.h:1534
static bool parts_equal(const std::string &key_part, const std::string &field)
Definition: slhaea.h:1546
key_matches(const key_type &key)
Definition: slhaea.h:1531
void set_key(const key_type &key)
Definition: slhaea.h:1541
key_matches_block_def(const value_type::key_type &key)
Definition: slhaea.h:2378
bool operator()(const value_type &block) const
Definition: slhaea.h:2382
value_type::key_matches key_matches_
Definition: slhaea.h:2393
void set_key(const value_type::key_type &key)
Definition: slhaea.h:2389
void set_key(const key_type &blockName)
Definition: slhaea.h:2364
key_matches(const key_type &blockName)
Definition: slhaea.h:2357
bool operator()(const value_type &block) const
Definition: slhaea.h:2360
Line::size_type field
Definition: slhaea.h:2442
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:2450
std::string str() const
Converts a Key into its string representation.
Definition: slhaea.h:2498
Key(const std::string &keyString)
Constructs a Key from a string.
Definition: slhaea.h:2460
Key & str(const std::string &keyString)
Converts a string to a Key.
Definition: slhaea.h:2477
Key(const char *keyString)
Constructs a Key from a string.
Definition: slhaea.h:2468
Block::key_type line
Definition: slhaea.h:2439
Coll::key_type block
Definition: slhaea.h:2436