|
qtty-cpp 0.4.5
Header-only C++ wrapper for qtty
|
One-page reference for common tasks.
Meter, Kilometer, Millimeter, Centimeter, Inch, Foot, Mile, LightYear
Literals: _m, _km, _mm, _cm, _in, _ft, _mi, _ly
Second, Minute, Hour, Day, Millisecond, Microsecond
Literals: _s, _min, _h, _day, _ms, _us
Radian, Degree, Arcminute, Arcsecond
Literals: _rad, _deg, _arcmin, _arcsec
Kilogram, Gram, Milligram, Ton, Pound, Ounce
Literals: _kg, _g, _mg, _ton, _lb, _oz
Watt, Kilowatt, Megawatt, Horsepower
Literals: _W, _kW, _MW, _hp
| Operation | Code | Result Type |
|---|---|---|
| Create | Meter m(10.0) | Meter |
| Literal | auto m = 10.0_m | Meter |
| Convert | m.to<Kilometer>() | Kilometer |
| Add | a + b | Same unit |
| Multiply | m * 2.0 | Same unit |
| Divide | m / 2.0 | Same unit |
| Compare | a > b | bool |
| Get value | m.value() | double |
| Absolute | m.abs() | Same unit |
| Negate | -m | Same unit |
| Exception | When Thrown |
|---|---|
| InvalidUnitError | Unknown unit ID |
| IncompatibleDimensionsError | Converting incompatible dimensions |
| ConversionError | Invalid numeric value |
| QttyException | Base class (catch-all) |
| Problem | Solution |
|---|---|
| Submodule missing | git submodule update --init --recursive |
| Library not found | Check RPATH or set LD_LIBRARY_PATH |
| Generated headers missing | Run cargo run --manifest-path gen_cpp_units/Cargo.toml --release -- qtty/qtty-ffi/units.csv include/qtty |
| Cargo not found | Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh |
See docs/README.md for additional documentation.