Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JScale.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "Jeep/JScale.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 using namespace std;
12 
13 #define PRINT(out, scale) {\
14  out << setw(8) << left << #scale << ' ' \
15  << scientific << setprecision(0) << getValue(scale) << ' ' \
16  << getUnit(scale) \
17  << endl; \
18  }
19 
20 
21 /**
22  * \file
23  * Example program to test JEEP::JScale_t enumeration.
24  * \author mdejong
25  */
26 int main(int argc, char* argv[])
27 {
28  using namespace std;
29 
30  char unit;
31  int debug;
32 
33  try {
34 
35  JParser<> zap;
36 
37  zap['U'] = make_field(unit) = ' ';
38  zap['d'] = make_field(debug) = 1;
39 
40  zap(argc, argv);
41  }
42  catch(const exception &error) {
43  FATAL(error.what() << endl);
44  }
45 
46 
47  using namespace JPP;
48 
49  cout << "unit [" << unit << "] " << scientific << setprecision(0) << getValue(getScale(unit)) << endl;
50 
51  PRINT(cout, femto_t);
52  PRINT(cout, pico_t);
53  PRINT(cout, nano_t);
54  PRINT(cout, micro_t);
55  PRINT(cout, milli_t);
56  PRINT(cout, unit_t);
57  PRINT(cout, kilo_t);
58  PRINT(cout, mega_t);
59  PRINT(cout, tera_t);
60  PRINT(cout, peta_t);
61  PRINT(cout, exa_t);
62 }
63 
Utility class to parse command line options.
Definition: JParser.hh:1711
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
int main(int argc, char *argv[])
Definition: Main.cc:15
exa
Definition: JScale.hh:37
micro
Definition: JScale.hh:29
#define PRINT(out, scale)
Definition: JScale.cc:13
JScale_t getScale(const char unit)
Get scale corresponding to textual unit.
Definition: JScale.hh:111
kilo
Definition: JScale.hh:32
milli
Definition: JScale.hh:30
peta
Definition: JScale.hh:36
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
femto
Definition: JScale.hh:26
Enumeration for scaling of quantity.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
mega
Definition: JScale.hh:33
nano
Definition: JScale.hh:28
Utility class to parse command line options.
pico
Definition: JScale.hh:27
unit
Definition: JScale.hh:31
tera
Definition: JScale.hh:35
int debug
debug level