String.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <deque>
5 #include <vector>
6 
7 namespace boca
8 {
9 
10 namespace latex
11 {
12 
13 enum class Medium
14 {
15  plain,
16  root,
17  latex
18 };
19 
20 std::string Name(Medium medium);
21 
23 {
24 
25 public:
26 
27  StringHelper(std::string const& string = "");
28 
29  StringHelper(std::string const& string, bool formula);
30 
31  bool Formula() const;
32 
33  std::string str() const;
34 
35  std::string& str();
36 
37 private:
38 
39  std::string string_;
40 
41  bool formula_ = false;
42 
43 };
44 
45 class String
46 {
47 
48 public:
49 
50  String() {}
51 
52  String(char const* string);
53 
54  String(std::string const& string);
55 
56  String(std::string const& string, bool formula);
57 
58  std::string str(Medium medium) const;
59 
60  bool empty() const;
61 
62  String& operator+=(String const& latex);
63 
64  String operator+(String const& latex);
65 
66  friend String operator+(char const* string, String const& latex);
67 
68 private:
69 
70  std::deque<StringHelper> latex_strings_;
71 
72 };
73 
74 String operator "" _TeX(char const*, size_t);
75 
76 class Formula
77 {
78 
79 public:
80 
81  template<typename... Arguments_>
82  Formula(Arguments_ ...arguments) {
83  Set(arguments...);
84  }
85 
86  std::string str();
87 
88  operator std::string();
89 
90 private:
91 
92  template<typename... Arguments_>
93  void Set(std::string const& string, Arguments_ ... arguments) {
94  strings_.emplace_back(string);
95  Set(arguments...);
96  }
97 
98  void Set() {};
99 
100  std::vector<std::string> strings_;
101 
102 };
103 
104 }
105 
107 
109 
110 }
Definition: String.hh:76
String()
Definition: String.hh:50
String operator+(char const *string, const String &latex)
Definition: String.cpp:129
Medium
Definition: String.hh:13
Formula(Arguments_...arguments)
Definition: String.hh:82
Definition: String.hh:45
Boosted Collider Analysis.
Definition: Analysis.hh:15
Definition: String.hh:22
std::string Name(Medium medium)
Definition: String.cpp:68