get_param_result.hpp
Go to the documentation of this file.
1 #pragma once
2 
11 #include <string>
12 #include <type_traits>
13 
14 #include <ros/console_backend.h>
15 
16 namespace cras
17 {
18 
23 {
25  bool defaultUsed {false};
26 
28  bool convertFailed {false};
29 
31  bool requiredMissing {false};
32 
34  ::std::string message{};
35 
37  ::ros::console::Level messageLevel {::ros::console::Level::Count};
38 };
39 
44 template <typename T>
46 {
52  GetParamResult(const T& value, const ::cras::GetParamResultInfo& info) : value(value), info(info) {}
53 
58  operator T() const // NOLINT(google-explicit-constructor)
59  {
60  return this->value;
61  }
62 
67  template <typename = ::std::enable_if<::std::is_same<T, char*>::value>>
68  operator ::std::string() const // NOLINT(google-explicit-constructor)
69  {
70  return {this->value};
71  }
72 
78  template <int I, typename = ::std::enable_if<::std::is_same<T, char[I]>::value>>
79  operator ::std::string() const // NOLINT(google-explicit-constructor)
80  {
81  return {this->value};
82  }
83 
85  T value;
86 
89 };
90 
91 }
bool defaultUsed
Whether the default value has been used.
bool convertFailed
Whether a value conversion failed.
T value
The returned value.
::std::string message
The log message (returned even if option printMessages is false).
::ros::console::Level messageLevel
Severity of the log message.
GetParamResult(const T &value, const ::cras::GetParamResultInfo &info)
Construct the result from a value and info.
bool requiredMissing
Whether a required parameter was found missing or could not be read.
Detailed information about the executed getParam() call.
Definition: any.hpp:15
Wrapper for the result of a getParam() call. It is designed to autoconvert to the result type sometim...


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sat Jun 17 2023 02:32:53