#include #include struct WeatherStation { double temperature; double pressure; double precipitation; }; void print_value(const flecs::cursor& cur) { // Get unit entity and component flecs::entity u = cur.get_unit(); const flecs::Unit *u_data = u.get(); // Print value with unit symbol std::cout << cur.get_member() << ": " << cur.get_float() << " " << u_data->symbol << "\n"; } int main(int, char *[]) { flecs::world ecs; // Import units module. ecs.import(); // Register reflection data with units. This can improve the way information // is visualized in tools, such as the explorer. ecs.component() .member("temperature") .member("pressure") .member("precipitation"); flecs::entity e = ecs.entity().set({24, 1.2, 0.5}); // Use cursor API to print values with units WeatherStation *ptr = e.get_mut(); flecs::cursor cur = ecs.cursor(ptr); cur.push(); print_value(cur); cur.next(); print_value(cur); cur.next(); print_value(cur); cur.pop(); // Output: // temperature: 24 °C // pressure: 1.2 bar // precipitation: 0.5 mm }