WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
UnitParser.h
1 
11 #ifndef WRENCH_UNITPARSER_H
12 #define WRENCH_UNITPARSER_H
13 
14 #include <unordered_map>
15 
16 namespace wrench {
17 
18  /***********************/
20  /***********************/
21 
22  class unit_scale;
23 
28  class UnitParser {
29 
34  class unit_scale : public std::unordered_map<std::string, double> {
35  public:
36  using std::unordered_map<std::string, double>::unordered_map;
37  // tuples are : <unit, value for unit, base (2 or 10), true if abbreviated>
38  explicit unit_scale(std::initializer_list<std::tuple<const std::string, double, int, bool>> generators);
39  };
40 
41  private:
42  static double parseValueWithUnit(std::string string, const unit_scale &units, const char *default_unit);
43 
44  public:
45  static double parse_size(std::string string);
46  static double parse_compute_speed(std::string string);
47 
48 
49  };
50 
51  /***********************/
53  /***********************/
54 };
55 
56 
57 #endif //WRENCH_UNITPARSER_H
wrench::UnitParser::parse_compute_speed
static double parse_compute_speed(std::string string)
Given a string compute speed specification with units (e.g., "3f", "10Gf") return the size in bytes.
Definition: UnitParser.cpp:121
wrench
Definition: Alarm.cpp:20
wrench::UnitParser
A class used to part string specification of values with units into a single value (e....
Definition: UnitParser.h:28
wrench::UnitParser::parse_size
static double parse_size(std::string string)
Given a string size specification with units (e.g., "13Mb") return the size in bytes.
Definition: UnitParser.cpp:99