File indexing completed on 2024-04-06 11:57:01
0001 #include <iostream>
0002 #include <map>
0003 #include "TROOT.h"
0004 #include "TColor.h"
0005
0006 using namespace std;
0007
0008 static const map<TString, Color_t> colormap{{"kWhite", kWhite},
0009 {"kBlack", kBlack},
0010 {"kGray", kGray},
0011 {"kRed", kRed},
0012 {"kGreen", kGreen},
0013 {"kBlue", kBlue},
0014 {"kYellow", kYellow},
0015 {"kMagenta", kMagenta},
0016 {"kCyan", kCyan},
0017 {"kOrange", kOrange},
0018 {"kSpring", kSpring},
0019 {"kTeal", kTeal},
0020 {"kAzure", kAzure},
0021 {"kViolet", kViolet},
0022 {"kPink", kPink}};
0023
0024 Color_t parser(TString input) {
0025
0026 input.ReplaceAll(" ", "");
0027
0028
0029 if (input.IsDec())
0030 return input.Atoi();
0031
0032
0033 if (input(0) != 'k')
0034 exit(EXIT_FAILURE);
0035
0036
0037 Ssiz_t Plus = input.First('+'), Minus = input.First('-');
0038
0039
0040 if (Plus != TString::kNPOS && Minus != TString::kNPOS)
0041 exit(EXIT_FAILURE);
0042
0043
0044 if (Plus != TString::kNPOS) {
0045 TString Left = input(0, Plus), Right = input(Plus + 1);
0046 cout << Left << ' ' << Right << endl;
0047 return colormap.at(Left) + Right.Atoi();
0048 } else if (Minus != TString::kNPOS) {
0049 TString Left = input(0, Minus), Right = input(Minus + 1);
0050 return colormap.at(Left) - Right.Atoi();
0051 } else {
0052 return colormap.at(input);
0053 }
0054 }
0055
0056 Color_t ColorParser(TString input) { return parser(input); }