35 Parameter(
const std::string& value): initialized(true), value(value) {}
42 Parameter(
const T& value): initialized(true), value(std::to_string(value)) {}
49 Parameter(
const std::vector<T>& values): initialized(true) {
50 for (
const auto& val : values) {
53 value += std::to_string(val);
62 operator std::string()
const {
96 std::string val =
asString(std::to_string(def));
98 return std::stof(val);
111 return std::stof(val);
122 std::vector<float>
asFloats(std::vector<float> def)
const {
124 std::vector<float> result;
125 std::istringstream stream(vals);
129 while (getline(stream, str,
',')) {
131 result.push_back(std::stof(str));
145 std::vector<float> result;
146 std::istringstream stream(vals);
148 while (getline(stream, str,
',')) {
150 result.push_back(std::stof(str));
164 std::string val =
asString(std::to_string(def));
166 return std::stoi(val);
179 return std::stoi(val);
191 std::vector<int>
asInts(std::vector<int> def)
const {
193 std::vector<int> result;
194 std::istringstream stream(vals);
198 while (getline(stream, str,
',')) {
200 result.push_back(std::stoi(str));
214 std::vector<int> result;
215 std::istringstream stream(vals);
217 while (getline(stream, str,
',')) {
219 result.push_back(std::stoi(str));
231 unsigned int asUInt(
unsigned int def)
const {
232 std::string val =
asString(std::to_string(def));
233 std::string message =
"Value " + val +
" cannot be casted to unsigned int.";
235 int value = std::stoi(val);
239 return static_cast<unsigned int>(value);
251 std::string message =
"Value " + val +
" cannot be casted to unsigned int.";
253 int value = std::stoi(val);
257 return static_cast<unsigned int>(value);
269 std::vector<unsigned int>
asUInts(std::vector<unsigned int> def)
const {
271 std::vector<unsigned int> result;
272 std::istringstream stream(vals);
274 std::string message =
"Value " + vals +
" cannot be casted to unsigned ints.";
277 while (getline(stream, str,
',')) {
279 int value = std::stoi(str);
283 result.push_back(static_cast<unsigned int>(value));
297 std::vector<unsigned int> result;
298 std::istringstream stream(vals);
300 std::string message =
"Value " + vals +
" cannot be casted to unsigned ints.";
301 while (getline(stream, str,
',')) {
303 int value = std::stoi(str);
307 result.push_back(static_cast<unsigned int>(value));
322 std::string val =
asString(std::to_string(def));
323 std::string loweredCaseValue;
324 std::transform(val.begin(), val.end(), std::back_inserter(loweredCaseValue), [](
char value) {
325 return std::tolower(value);
330 if (!(std::istringstream(loweredCaseValue) >> std::boolalpha >> result)) {
332 return static_cast<bool>(
asInt(def));
345 std::string loweredCaseValue;
346 std::transform(val.begin(), val.end(), std::back_inserter(loweredCaseValue), [](
char value) {
347 return std::tolower(value);
352 if (!(std::istringstream(loweredCaseValue) >> std::boolalpha >> result)) {
354 return static_cast<bool>(
asInt());
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:22
Parameter(const std::vector< T > &values)
The constructor creates a Parameter object with a vector of template values.
Definition: ie_parameter.hpp:49
int asInt(int def) const
Returns an integer value for the given parameter or returns the default value.
Definition: ie_parameter.hpp:163
Definition: ie_argmax_layer.hpp:11
std::vector< int > asInts() const
Returns a vector of int values for the given parameter.
Definition: ie_parameter.hpp:212
float asFloat(float def) const
Gets float value for the given parameter.
Definition: ie_parameter.hpp:95
std::vector< unsigned int > asUInts(std::vector< unsigned int > def) const
Returns a vector of unsigned int values for the given parameter or returns the default value...
Definition: ie_parameter.hpp:269
unsigned int asUInt(unsigned int def) const
Returns an unsigned integer value for the given parameter or returns the default value.
Definition: ie_parameter.hpp:231
std::string asString(std::string def) const
Returns a string value for the given parameter or returns the default one.
Definition: ie_parameter.hpp:71
Parameter()=default
Default constructor.
bool asBool() const
Returns an boolean value for the given parameter. The valid values are (true, false, 1, 0).
Definition: ie_parameter.hpp:343
std::vector< float > asFloats() const
Returns a vector of float values for the given parameter.
Definition: ie_parameter.hpp:143
float asFloat() const
Returns a float value for the given layer parameter.
Definition: ie_parameter.hpp:108
int asInt() const
Returns an integer value for the given parameter.
Definition: ie_parameter.hpp:176
Parameter(const std::string &value)
The constructor creates a Parameter object with string value.
Definition: ie_parameter.hpp:35
std::string asString() const
Returns a string value for the given parameter. Throws exception if parameter was not found...
Definition: ie_parameter.hpp:83
This class represents an object to work with different parameters.
Definition: ie_parameter.hpp:24
unsigned int asUInt() const
Returns an unsigned integer value for the given parameter.
Definition: ie_parameter.hpp:249
Parameter(const T &value)
The constructor creates a Parameter object with template value.
Definition: ie_parameter.hpp:42
std::vector< unsigned int > asUInts() const
Returns a vector of unsigned int values for the given parameter.
Definition: ie_parameter.hpp:295
bool asBool(bool def) const
Returns an boolean value for the given parameter. The valid values are (true, false, 1, 0).
Definition: ie_parameter.hpp:321
std::vector< float > asFloats(std::vector< float > def) const
Returns a vector of float values for the given parameter or returns the default value.
Definition: ie_parameter.hpp:122
A header file for the main Inference Engine exception.
std::vector< int > asInts(std::vector< int > def) const
Returns a vector of int values for the given parameter or returns the default value.
Definition: ie_parameter.hpp:191