Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/boost/property_tree/detail/info_parser_read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/detail/info_parser_error.hpp"
#include "boost/property_tree/detail/info_parser_utils.hpp"
#include "boost/core/no_exceptions_support.hpp"
#include <iterator>
#include <string>
#include <stack>
Expand Down Expand Up @@ -210,7 +211,7 @@ namespace boost { namespace property_tree { namespace info_parser
std::stack<Ptree *> stack;
stack.push(&pt); // Push root ptree on stack initially

try {
BOOST_TRY {
// While there are characters in the stream
while (stream.good()) {
// Read one line from stream
Expand Down Expand Up @@ -372,17 +373,19 @@ namespace boost { namespace property_tree { namespace info_parser
BOOST_PROPERTY_TREE_THROW(info_parser_error("unmatched {", "", 0));

}
catch (info_parser_error &e)
BOOST_CATCH (info_parser_error &e)
{
#ifndef BOOST_NO_EXCEPTIONS
// If line undefined rethrow error with correct filename and line
if (e.line() == 0)
{
BOOST_PROPERTY_TREE_THROW(info_parser_error(e.message(), filename, line_no));
}
else
BOOST_PROPERTY_TREE_THROW(e);

#endif
}
BOOST_CATCH_END

}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/property_tree/detail/rapidxml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <exception> // For std::exception

#define BOOST_PROPERTY_TREE_RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)
#define BOOST_PROPERTY_TREE_RAPIDXML_PARSE_ERROR(what, where) boost::throw_exception(parse_error(what, where))

namespace boost { namespace property_tree { namespace detail {namespace rapidxml
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <boost/property_tree/detail/xml_parser_flags.hpp>
#include <boost/property_tree/detail/xml_parser_utils.hpp>
#include <boost/property_tree/detail/rapidxml.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <vector>

namespace boost { namespace property_tree { namespace xml_parser
Expand Down Expand Up @@ -101,7 +102,7 @@ namespace boost { namespace property_tree { namespace xml_parser
xml_parser_error("read error", filename, 0));
v.push_back(0); // zero-terminate

try {
BOOST_TRY {
// Parse using appropriate flags
const int f_tws = parse_normalize_whitespace
| parse_trim_whitespace;
Expand Down Expand Up @@ -131,12 +132,15 @@ namespace boost { namespace property_tree { namespace xml_parser

// Swap local and result ptrees
pt.swap(local);
} catch (parse_error &e) {
} BOOST_CATCH (parse_error &e) {
#ifndef BOOST_NO_EXCEPTIONS
long line = static_cast<long>(
std::count(&v.front(), e.where<Ch>(), Ch('\n')) + 1);
BOOST_PROPERTY_TREE_THROW(
xml_parser_error(e.what(), filename, line));
#endif
}
BOOST_CATCH_END
}

} } }
Expand Down
11 changes: 7 additions & 4 deletions include/boost/property_tree/info_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <boost/property_tree/detail/info_parser_writer_settings.hpp>
#include <boost/property_tree/detail/info_parser_read.hpp>
#include <boost/property_tree/detail/info_parser_write.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <istream>

namespace boost { namespace property_tree { namespace info_parser
Expand Down Expand Up @@ -43,11 +44,12 @@ namespace boost { namespace property_tree { namespace info_parser
void read_info(std::basic_istream<Ch> &stream, Ptree &pt,
const Ptree &default_ptree)
{
try {
BOOST_TRY {
read_info(stream, pt);
} catch(file_parser_error &) {
} BOOST_CATCH(file_parser_error &) {
pt = default_ptree;
}
BOOST_CATCH_END
}

/**
Expand Down Expand Up @@ -87,11 +89,12 @@ namespace boost { namespace property_tree { namespace info_parser
const Ptree &default_ptree,
const std::locale &loc = std::locale())
{
try {
BOOST_TRY {
read_info(filename, pt, loc);
} catch(file_parser_error &) {
} BOOST_CATCH(file_parser_error &) {
pt = default_ptree;
}
BOOST_CATCH_END
}

/**
Expand Down
17 changes: 13 additions & 4 deletions include/boost/property_tree/ini_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/detail/ptree_utils.hpp>
#include <boost/property_tree/detail/file_parser_error.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <fstream>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -165,13 +166,17 @@ namespace boost { namespace property_tree { namespace ini_parser
BOOST_PROPERTY_TREE_THROW(ini_parser_error(
"cannot open file", filename, 0));
stream.imbue(loc);
try {

BOOST_TRY {
read_ini(stream, pt);
}
catch (ini_parser_error &e) {
BOOST_CATCH (ini_parser_error &e) {
#ifndef BOOST_NO_EXCEPTIONS
BOOST_PROPERTY_TREE_THROW(ini_parser_error(
e.message(), filename, e.line()));
#endif
}
BOOST_CATCH_END
}

namespace detail
Expand Down Expand Up @@ -313,13 +318,17 @@ namespace boost { namespace property_tree { namespace ini_parser
BOOST_PROPERTY_TREE_THROW(ini_parser_error(
"cannot open file", filename, 0));
stream.imbue(loc);
try {

BOOST_TRY {
write_ini(stream, pt, flags);
}
catch (ini_parser_error &e) {
BOOST_CATCH (ini_parser_error &e) {
#ifndef BOOST_NO_EXCEPTIONS
BOOST_PROPERTY_TREE_THROW(ini_parser_error(
e.message(), filename, e.line()));
#endif
}
BOOST_CATCH_END
}

} } }
Expand Down