Blame src/units.hpp

Packit Service 7770af
#ifndef SASS_UNITS_H
Packit Service 7770af
#define SASS_UNITS_H
Packit Service 7770af
Packit Service 7770af
#include <cmath>
Packit Service 7770af
#include <string>
Packit Service 7770af
#include <sstream>
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
Packit Service 7770af
  const double PI = std::acos(-1);
Packit Service 7770af
Packit Service 7770af
  enum UnitClass {
Packit Service 7770af
    LENGTH = 0x000,
Packit Service 7770af
    ANGLE = 0x100,
Packit Service 7770af
    TIME = 0x200,
Packit Service 7770af
    FREQUENCY = 0x300,
Packit Service 7770af
    RESOLUTION = 0x400,
Packit Service 7770af
    INCOMMENSURABLE = 0x500
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
  enum UnitType {
Packit Service 7770af
Packit Service 7770af
    // size units
Packit Service 7770af
    IN = UnitClass::LENGTH,
Packit Service 7770af
    CM,
Packit Service 7770af
    PC,
Packit Service 7770af
    MM,
Packit Service 7770af
    PT,
Packit Service 7770af
    PX,
Packit Service 7770af
Packit Service 7770af
    // angle units
Packit Service 7770af
    DEG = ANGLE,
Packit Service 7770af
    GRAD,
Packit Service 7770af
    RAD,
Packit Service 7770af
    TURN,
Packit Service 7770af
Packit Service 7770af
    // time units
Packit Service 7770af
    SEC = TIME,
Packit Service 7770af
    MSEC,
Packit Service 7770af
Packit Service 7770af
    // frequency units
Packit Service 7770af
    HERTZ = FREQUENCY,
Packit Service 7770af
    KHERTZ,
Packit Service 7770af
Packit Service 7770af
    // resolutions units
Packit Service 7770af
    DPI = RESOLUTION,
Packit Service 7770af
    DPCM,
Packit Service 7770af
    DPPX,
Packit Service 7770af
Packit Service 7770af
    // for unknown units
Packit Service 7770af
    UNKNOWN = INCOMMENSURABLE
Packit Service 7770af
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
  extern const double size_conversion_factors[6][6];
Packit Service 7770af
  extern const double angle_conversion_factors[4][4];
Packit Service 7770af
  extern const double time_conversion_factors[2][2];
Packit Service 7770af
  extern const double frequency_conversion_factors[2][2];
Packit Service 7770af
  extern const double resolution_conversion_factors[3][3];
Packit Service 7770af
Packit Service 7770af
  enum Sass::UnitType string_to_unit(const std::string&);
Packit Service 7770af
  const char* unit_to_string(Sass::UnitType unit);
Packit Service 7770af
  enum Sass::UnitClass get_unit_type(Sass::UnitType unit);
Packit Service 7770af
  std::string get_unit_class(Sass::UnitType unit);
Packit Service 7770af
  std::string unit_to_class(const std::string&);
Packit Service 7770af
  // throws incompatibleUnits exceptions
Packit Service 7770af
  double conversion_factor(const std::string&, const std::string&, bool = true);
Packit Service 7770af
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif