31 explicit QttyException(
const std::string& msg) : std::runtime_error(msg) {}
73 if (status == QTTY_OK) {
77 std::string msg = std::string(operation) +
" failed: ";
79 case QTTY_ERR_UNKNOWN_UNIT:
81 case QTTY_ERR_INCOMPATIBLE_DIM:
83 case QTTY_ERR_NULL_OUT:
85 case QTTY_ERR_INVALID_VALUE:
97template<
typename UnitTag>
104template<
typename UnitTag>
115template<
typename Tag>
134template<
typename UnitTag>
170 template<
typename TargetType>
173 qtty_quantity_t src_qty;
174 qtty_quantity_t dst_qty;
176 int32_t status = qtty_quantity_make(m_value,
unit_id(), &src_qty);
230 return m_value ==
other.m_value;
234 return m_value !=
other.m_value;
238 return m_value <
other.m_value;
242 return m_value >
other.m_value;
246 return m_value <=
other.m_value;
250 return m_value >=
other.m_value;
260 m_value +=
other.m_value;
265 m_value -=
other.m_value;
Raised when value conversion fails at the FFI boundary.
ConversionError(const std::string &msg)
Raised when mixing incompatible dimensions in conversion/arithmetic.
IncompatibleDimensionsError(const std::string &msg)
Raised when an unknown or invalid unit identifier is used.
InvalidUnitError(const std::string &msg)
Base exception for all qtty wrapper failures.
QttyException(const std::string &msg)
Quantity & operator*=(double scalar)
bool operator<=(const Quantity &other) const
bool operator!=(const Quantity &other) const
bool operator<(const Quantity &other) const
Quantity operator+(const Quantity &other) const
bool operator==(const Quantity &other) const
constexpr double value() const
Quantity operator*(double scalar) const
Quantity operator-(const Quantity &other) const
Quantity operator-() const
Quantity & operator+=(const Quantity &other)
Quantity & operator-=(const Quantity &other)
Quantity & operator/=(double scalar)
bool operator>(const Quantity &other) const
Quantity operator/(double scalar) const
static constexpr UnitId unit_id()
friend Quantity operator*(double scalar, const Quantity &q)
constexpr Quantity(double value)
bool operator>=(const Quantity &other) const
Quantity< typename ExtractTag< TargetType >::type > to() const
void check_status(int32_t status, const char *operation)
Convert qtty FFI status codes into typed C++ exceptions.