From c6375e2ed92ac54fdc3a12e5947bfcdb00994d98 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Sun, 17 Mar 2013 15:44:07 +0100 Subject: [PATCH] Add success/failure to plist::parse_ascii API --- Frameworks/plist/src/ascii.h | 2 +- Frameworks/plist/src/ascii.rl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Frameworks/plist/src/ascii.h b/Frameworks/plist/src/ascii.h index 5a7bee84..ecd7d464 100644 --- a/Frameworks/plist/src/ascii.h +++ b/Frameworks/plist/src/ascii.h @@ -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 */ diff --git a/Frameworks/plist/src/ascii.rl b/Frameworks/plist/src/ascii.rl index ee11fa88..3d6fe447 100644 --- a/Frameworks/plist/src/ascii.rl +++ b/Frameworks/plist/src/ascii.rl @@ -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 */