mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-02-26 08:22:31 +00:00
Moved the 'parse_bool()' function from mkvmerge.cpp to the common string parsing file.
This commit is contained in:
parent
3b003df714
commit
fef593a468
@ -296,3 +296,19 @@ parse_timecode(const std::string &src,
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief Parse a string for a boolean value
|
||||
|
||||
Interpretes the string \c orig as a boolean value. Accepted
|
||||
is "true", "yes", "1" as boolean true and "false", "no", "0"
|
||||
as boolean false.
|
||||
*/
|
||||
bool
|
||||
parse_bool(const std::string &orig) {
|
||||
std::string s(downcase(orig));
|
||||
|
||||
if ((s == "yes") || (s == "true") || (s == "1"))
|
||||
return true;
|
||||
if ((s == "no") || (s == "false") || (s == "0"))
|
||||
return false;
|
||||
throw false;
|
||||
}
|
||||
|
@ -59,4 +59,6 @@ parse_double(const std::string &s,
|
||||
return parse_double(s.c_str(), value);
|
||||
}
|
||||
|
||||
bool MTX_DLL_API parse_bool(const std::string &orig);
|
||||
|
||||
#endif // __MTX_COMMON_STRING_PARSING_H
|
||||
|
@ -509,23 +509,6 @@ parse_number_with_unit(const std::string &s,
|
||||
return (int64_t)(multiplier * d_value);
|
||||
}
|
||||
|
||||
/** \brief Parse a string for a boolean value
|
||||
|
||||
Interpretes the string \c orig as a boolean value. Accepted
|
||||
is "true", "yes", "1" as boolean true and "false", "no", "0"
|
||||
as boolean false.
|
||||
*/
|
||||
bool
|
||||
parse_bool(const std::string &orig) {
|
||||
std::string s(downcase(orig));
|
||||
|
||||
if ((s == "yes") || (s == "true") || (s == "1"))
|
||||
return true;
|
||||
if ((s == "no") || (s == "false") || (s == "0"))
|
||||
return false;
|
||||
throw false;
|
||||
}
|
||||
|
||||
/** \brief Parse tags and add them to the list of all tags
|
||||
|
||||
Also tests the tags for missing mandatory elements.
|
||||
|
Loading…
Reference in New Issue
Block a user