Logo ROOT  
Reference Guide
ValueChecking.h
Go to the documentation of this file.
1/*
2 * ValueChecking.h
3 *
4 * Created on: 03.08.2020
5 * Author: shageboeck
6 */
7
8#ifndef ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
9#define ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
10
11#include <TSystem.h>
12
13#include <exception>
14#include <vector>
15#include <string>
16#include <sstream>
17
18class CachingError : public std::exception {
19 public:
20 CachingError(const std::string& newMessage) :
21 std::exception(),
22 _messages()
23 {
24 _messages.push_back(newMessage);
25 }
26
27 CachingError(CachingError&& previous, const std::string& newMessage) :
28 std::exception(),
29 _messages{std::move(previous._messages)}
30 {
31 _messages.push_back(newMessage);
32 }
33
34 const char* what() const noexcept override {
35 std::stringstream out;
36 out << "**Computation/caching error** in\n";
37
38 std::string indent;
39 for (auto it = _messages.rbegin(); it != _messages.rend(); ++it) {
40 std::string message = *it;
41 auto pos = message.find('\n', 0);
42 while (pos != std::string::npos) {
43 message.insert(pos+1, indent);
44 pos = (message.find('\n', pos+1));
45 }
46
47 out << indent << message << "\n";
48 indent += " ";
49 }
50
51 out << std::endl;
52
53 std::string* ret = new std::string(out.str()); //Make it survive this method
54
55 return ret->c_str();
56 }
57
58
59 private:
60 std::vector<std::string> _messages;
61};
62
63
65 public:
66 template <class T,
68 FormatPdfTree& operator<<(const T& arg) {
69 _stream << arg.ClassName() << "::" << arg.GetName() << " " << &arg << " ";
70 arg.printArgs(_stream);
71 return *this;
72 }
73
74 template <class T,
76 FormatPdfTree& operator<<(const T& arg) {
77 _stream << arg;
78 return *this;
79 }
80
81 operator std::string() const {
82 return _stream.str();
83 }
84
85 std::ostream& stream() {
86 return _stream;
87 }
88
89 private:
90 std::ostringstream _stream;
91};
92
93
94
95#endif /* ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_ */
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const char * what() const noexcept override
Definition: ValueChecking.h:34
CachingError(CachingError &&previous, const std::string &newMessage)
Definition: ValueChecking.h:27
CachingError(const std::string &newMessage)
Definition: ValueChecking.h:20
std::vector< std::string > _messages
Definition: ValueChecking.h:60
std::ostringstream _stream
Definition: ValueChecking.h:90
std::ostream & stream()
Definition: ValueChecking.h:85
FormatPdfTree & operator<<(const T &arg)
Definition: ValueChecking.h:68
double T(double x)
Definition: ChebyshevPol.h:34