SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
typecast.h
Go to the documentation of this file.
1#ifndef _typecast_H_
2#define _typecast_H_
3
4#include <functional>
5
6#include "lambda_transform.h"
7
8namespace sensesp {
9
33template <typename IN, typename OUT>
34class Typecast : public LambdaTransform<IN, OUT> {
35 public:
36 Typecast(std::function<OUT(IN)> cast = [](IN input) -> OUT {
37 return (OUT)input;
38 })
40};
41
44
47
54class RoundToInt : public Typecast<float, int> {
55 public:
56 RoundToInt();
57};
58
59} // namespace sensesp
60#endif
Construct a new transform based on a single function.
Takes as its input a float, rounds it to the nearest whole number, then outputs it as an int.
Definition typecast.h:54
Converts input from one data type to another, then outputs the new type.
Definition typecast.h:34
Typecast(std::function< OUT(IN)> cast=[](IN input) -> OUT { return(OUT) input;})
Definition typecast.h:36
Typecast< int, float > IntToFloat
Definition typecast.h:45
Typecast< float, int > FloatToInt
Definition typecast.h:46
Typecast< bool, int > BoolToInt
Definition typecast.h:43
Typecast< int, bool > IntToBool
Definition typecast.h:42