Majoranapp
A C++ library for studying MZM in non-interacting systems
Basics.hpp
Go to the documentation of this file.
1 #ifndef INFO_BASICS_HPP
2 #define INFO_BASICS_HPP
3 
4 #include <string>
5 #include <iostream>
6 #include <iomanip>
7 
8 #include "Colors.hpp"
9 #include "Time.hpp"
10 
15 {
16 protected:
20  static const std::string comment;
21 
22 public:
23  /*
24  * @brief increase verbosity of the output (flag)
25  */
26  static bool verbose;
27 
33  static void Comment(std::string text)
34  {
35  std::cout << comment << text << "\n";
36  }
37 
46  template <class T1, class T2>
47  static void Comment(T1 key, T2 value)
48  {
49  std::cout << comment << "-" << key << " " << value << "\n";
50  }
51 
58  static void LogComment(std::string text, std::string color)
59  {
61  {
62  std::clog << std::fixed
63  << std::setprecision(6)
64  << std::setfill('0');
65  std::clog << comment
66  << ColorsInfo::StartColor(color)
67  << "["
68  << std::setw(12) << TimeInfo::Time()
69  << "] "
70  << text
72  << "\n";
73  }
74  }
75 
81  static void LogBegining(std::string text)
82  {
84  }
85 
91  static void LogAccomplished(std::string text = "... done")
92  {
94  }
95 
102  static void Warning(std::string text, std::string note = "")
103  {
104  std::cout << ColorsInfo::Colorize("[!] " + text, Color::red)
105  << ColorsInfo::Colorize(note, Color::bwhite) << "\n";
106  }
107 
113  static void Title(std::string title)
114  {
115  Comment(title);
116  Line();
117  }
118 
124  static void Line(int n = 40)
125  {
126  std::cout << comment << std::string(n, '=') << "\n";
127  }
128 };
129 
130 const std::string BasicsInfo::comment{"# "};
131 bool BasicsInfo::verbose{false};
132 #endif
static void Title(std::string title)
Display title and Line.
Definition: Basics.hpp:113
static const std::string green
Definition: Colors.hpp:13
static void Comment(std::string text)
Display commented line.
Definition: Basics.hpp:33
static const std::string bwhite
Definition: Colors.hpp:16
static const std::string comment
standard comment string (default: #)
Definition: Basics.hpp:20
static void LogComment(std::string text, std::string color)
Colored comment to std::clog with current program time.
Definition: Basics.hpp:58
static std::string Colorize(std::string text, std::string color)
Add prefix and suffix for color display in Linux terminal.
Definition: Colors.hpp:33
static std::string StartColor(std::string color)
returns selected color
Definition: Colors.hpp:44
static std::string StopColor()
resets color to default normal
Definition: Colors.hpp:53
static const std::string red
Definition: Colors.hpp:14
static void LogAccomplished(std::string text="... done")
LogComment with green color.
Definition: Basics.hpp:91
static bool verbose
Definition: Basics.hpp:26
Basic info functions.
Definition: Basics.hpp:14
static void Comment(T1 key, T2 value)
Comment for displaying map item.
Definition: Basics.hpp:47
static void Line(int n=40)
Display line of n char (default char &#39;=&#39;)
Definition: Basics.hpp:124
static void LogBegining(std::string text)
LogComment with red color.
Definition: Basics.hpp:81
static double Time()
returns current clock time (in seconds)
Definition: Time.hpp:32
static void Warning(std::string text, std::string note="")
Warning sent to std::cout.
Definition: Basics.hpp:102