41 {
"*D", { 9.869233E-13,
UnitSI().
m(2) } },
42 {
"*l", { 1e-3,
UnitSI().
m(3) } },
47 {
"min", { 60,
UnitSI().
s() } },
48 {
"h", { 3600,
UnitSI().
s() } },
49 {
"d", { 24*3600,
UnitSI().
s() } },
50 {
"y", { 365.2425*24*3600,
UnitSI().
s() } },
79 for (it=base_units_map.begin(); it!=base_units_map.end(); ++it) {
80 if (it->first.at(0)==
'*') {
81 std::string shortcut = it->first.substr(1);
82 double coef = it->second.coef_;
85 std::string key = prefix_it->first + shortcut;
86 units_map_.insert(std::pair<std::string, DerivedUnit>( key, { coef*prefix_it->second, it->second.unit_ } ));
89 units_map_.insert( std::pair<std::string, DerivedUnit>( it->first, it->second ) );
108 typedef spirit_namespace::position_iterator< std::string::iterator > PosnIterT;
110 std::string::iterator begin = s.begin();
111 std::string::iterator end = s.end();
113 const PosnIterT posn_begin( begin, end );
114 const PosnIterT posn_end( end, end );
119 spirit_namespace::parse( begin, end,
121 spirit_namespace::space_p );
123 }
catch (ExcInvalidUnit &e) {
124 e << EI_UnitDefinition(s);
137 Formula &formula = unit_data.find(
"")->second;
149 ASSERT_DBG(it != UnitConverter::basic_factors.units_map_.end())(factor.
factor_).error(
"Undefined unit.");
150 coef *= pow(it->second.coef_, factor.
exponent_);
155 coef *= pow(it->second.coef_, factor.
exponent_);
Helper class. Defines basic factors of SI, non-SI and derived units.
UnitsMap units_map_
Define all base and derived units given by their symbol.
UnitData read_unit(std::string s)
Parse and check unit defined in string format.
bool basic_
unit is basic (strict defined in application) / derived (defined by user as formula) ...
UnitSI unit_si() const
Return unit_si_.
void check_unit_data()
Check unit_data_ object.
Definition of unit grammar.
UnitConverter()
Constructor.
void add_converted_unit(Factor factor, UnitData &unit_data, UnitSI &unit_si, double &coef)
Calculates UnitSi and coeficient of Factor, recursively calls this method for user defined formula...
Class manages parsing of user defined field unit.
double convert(std::string actual_unit)
Convert string to coeficient and UnitSI representation, return coeficient.
void multiply(const UnitSI &other, int exp=1)
Multiply with power of given unit.
std::string factor_
string represantation of unit or user defined constant
UnitData unit_data() const
Store structure given by parser.
void reset()
Reset UnitSI object (set vector of exponents to zeros and set undef flag)
BasicFactors()
Constructor.
UnitSI & m(int exp=1)
Methods set values of exponents for SI units with similar name.
Class for representation SI units of Fields.
static const BasicFactors basic_factors
Define all base and derived units given by their symbol.