smartheim / wakaamaNode

lwM2M library based on Wakaama for PlattformIO/cmake with easy object API
https://openhab-nodes.github.io/wakaamaNode/
MIT License
27 stars 18 forks source link

C++ migration: Return types #11

Open davidgraeff opened 6 years ago

davidgraeff commented 6 years ago

Wakaama is following the C pattern of returning a value that might be a success or failure, depending on the specific value or specific error ranges. The library is not consistent in its returns though. Sometimes COAP error codes are returned, sometimes just a -1 or a 0 means an error.

The C++ std::optional (C++11 backport, using C++17 native if available) should be used for returning a value instead. The alternative would be exceptions, but using these in the embedded domain is controversial and the code might be compiled with -fno-exceptions.

See https://github.com/martinmoene/optional-lite