1//
2// ValueTraits.cpp
3//
4// Library: XML
5// Package: XML
6// Module: ValueTraits
7//
8// Definition of the ValueTraits templates.
9//
10// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// Based on libstudxml (http://www.codesynthesis.com/projects/libstudxml/).
14// Copyright (c) 2009-2013 Code Synthesis Tools CC.
15//
16// SPDX-License-Identifier: BSL-1.0
17//
18
19
20#include "Poco/XML/XMLStreamParser.h"
21#include "Poco/XML/XMLStreamParserException.h"
22
23
24namespace Poco {
25namespace XML {
26
27
28bool DefaultValueTraits<bool>::parse(std::string s, const XMLStreamParser& p)
29{
30 if (s == "true" || s == "1" || s == "True" || s == "TRUE")
31 return true;
32 else if (s == "false" || s == "0" || s == "False" || s == "FALSE")
33 return false;
34 else
35 throw XMLStreamParserException(p, "invalid bool value '" + s + "'");
36}
37
38
39} } // namespace Poco::XML
40