13 #ifndef DATATOOLS_UNITS_H 14 #define DATATOOLS_UNITS_H 26 #include <boost/cstdint.hpp> 120 static const double bit = 1.0;
121 static const double octet = 8.0 * bit;
122 static const double byte = octet;
158 const std::string& unit_dimension_label_);
170 const std::string& unit_dimension_label_);
264 const std::string& unit_str_);
274 double get_unit(
const std::string& unit_str_,
bool throw_ =
false);
317 bool find_unit(
const std::string & unit_str_,
318 double & unit_value_,
319 std::string & unit_label_);
343 std::string & unit_label_,
344 double default_unit_ = std::numeric_limits<double>::quiet_NaN());
363 std::string& unit_symbol,
364 std::string& unit_label,
378 unit(
const std::string & name_,
379 const std::string & dimension_desc_,
381 bool SI_main_ =
false);
384 unit(
const std::string & name_,
385 const std::string & symbol_,
386 const std::string & dimension_desc_,
388 bool SI_main_ =
false);
391 unit(
const std::string & name_,
392 const std::string & main_symbol_,
393 const std::string & alt_symbols_,
394 const std::string & dimension_desc_,
396 bool SI_main_ =
false);
411 const std::string &
get_name()
const;
417 unit &
add_symbol(
const std::string & symbol_,
bool main_ =
false);
420 bool has_symbol(
const std::string & symbol_)
const;
423 bool match(
const std::string & id_)
const;
474 operator double()
const;
477 const std::string &
str()
const;
483 virtual void tree_dump(std::ostream & out_ = std::clog,
484 const std::string & title_ =
"",
485 const std::string & indent_ =
"",
486 bool inherit_ =
false)
const;
496 std::set<std::string> _symbols_;
497 std::string _main_symbol_;
498 std::string _dimension_label_;
499 std::string _dimension_meta_;
544 const std::string & default_unit_symbol_);
565 bool has_unit(
const std::string & unit_name_)
const;
569 bool default_unit_ =
false);
605 virtual void tree_dump(std::ostream & out_ = std::clog,
606 const std::string & title_ =
"",
607 const std::string & indent_ =
"",
608 bool inherit_ =
false)
const;
618 std::set<std::string> _unit_names_;
619 std::string _default_unit_name_;
620 int _dimensional_powers_[9];
657 bool has_unit(
const std::string & unit_name_)
const;
660 const unit &
get_unit(
const std::string & unit_name_)
const;
663 bool has_symbol(
const std::string & unit_symbol_)
const;
675 bool has_dimension(
const std::string & dimension_label_)
const;
694 std::list<std::string> & symbols_)
const;
700 virtual void tree_dump(std::ostream & out_ = std::clog,
701 const std::string & title_ =
"",
702 const std::string & indent_ =
"",
703 bool inherit_ =
false)
const;
730 static registry & _access_system_registry_();
745 #define DT_THROW_BAD_UNIT(UnitType,UnitSymbol) \ 746 DT_THROW_IF(true,std::logic_error, \ 747 "Invalid '" << UnitType << "' unit for symbol '" << UnitSymbol << "' !") 750 #endif // DATATOOLS_UNITS_H
Utility macros for exception handling.
#define DR_TYPE_INIT(Introspectable)
Definition: reflection_interface.h:165