MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / parse_generic

Function parse_generic

common/src/parse.cpp:86–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84namespace console
85{
86template <class T, class V = T(*)(const char*, const char**)> int
87parse_generic (V convert_func, int argc, const char* const* argv, const char* str, T& val)
88{
89 char *endptr = nullptr;
90 int index = find_argument (argc, argv, str) + 1;
91 errno = 0;
92
93 if (index > 0 && index < argc )
94 {
95 val = convert_func (argv[index], &endptr); // similar to strtol, strtod, strtof
96 // handle out-of-range, junk at the end and no conversion
97 if (errno == ERANGE || *endptr != '\0' || str == endptr)
98 {
99 return -1;
100 }
101 }
102
103 return (index - 1);
104}
105
106int
107parse_argument (int argc, const char * const * argv, const char * str, long int &val) noexcept

Callers 2

parse_argumentFunction · 0.85
parse_argumentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected