Moved the 'parse_bool()' function from mkvmerge.cpp to the common string parsing file.

This commit is contained in:
Moritz Bunkus 2009-08-15 13:33:57 +02:00
parent 3b003df714
commit fef593a468
3 changed files with 18 additions and 17 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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.