mirror of
https://github.com/textmate/textmate.git
synced 2026-01-20 20:27:59 -05:00
Add success/failure to plist::parse_ascii API
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace plist
|
||||
{
|
||||
PUBLIC plist::any_t parse_ascii (std::string const& str);
|
||||
PUBLIC plist::any_t parse_ascii (std::string const& str, bool* success = NULL);
|
||||
}
|
||||
|
||||
#endif /* end of include guard: ASCII_PARSER_H_D3YVICTX */
|
||||
|
||||
@@ -154,12 +154,15 @@ static bool parse_element (char const*& p, char const* pe, plist::any_t& res)
|
||||
|
||||
namespace plist
|
||||
{
|
||||
plist::any_t parse_ascii (std::string const& str)
|
||||
plist::any_t parse_ascii (std::string const& str, bool* success)
|
||||
{
|
||||
plist::any_t res;
|
||||
char const* p = str.data();
|
||||
char const* pe = p + str.size();
|
||||
return parse_element(p, pe, res) && parse_ws(p, pe) && p == pe ? res : plist::any_t();
|
||||
bool didParse = parse_element(p, pe, res) && parse_ws(p, pe) && p == pe;
|
||||
if(success)
|
||||
*success = didParse;
|
||||
return didParse ? res : plist::any_t();
|
||||
}
|
||||
|
||||
} /* plist */
|
||||
|
||||
Reference in New Issue
Block a user