summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-01-16 21:48:50 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-01-16 21:48:50 -0800
commite5ecbd63ce75de0a8f1473cbe0c1f9eea657dd02 (patch)
tree8ace0fd644cc3c8274c1e74f2b0743d21a957441 /src
parent93c3ab46494f35c390b40220519d83634e4e347f (diff)
parent8e95f0d88947631162f5ed1fc5427b414425604b (diff)
Merge branch 'master' into compact
Diffstat (limited to 'src')
-rw-r--r--src/pugiconfig.hpp1
-rw-r--r--src/pugixml.cpp45
-rw-r--r--src/pugixml.hpp13
3 files changed, 52 insertions, 7 deletions
diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp
index 1c216e3..6219dbe 100644
--- a/src/pugiconfig.hpp
+++ b/src/pugiconfig.hpp
@@ -39,7 +39,6 @@
// Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY
-// #include "pugixml.cpp"
// Uncomment this to enable long long support
// #define PUGIXML_HAS_LONG_LONG
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 52ddf4c..7d53832 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4504,10 +4504,19 @@ PUGI__NS_BEGIN
}
template <typename String, typename Header>
+ PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value)
+ {
+ char buf[128];
+ sprintf(buf, "%.9g", value);
+
+ return set_value_buffer(dest, header, header_mask, buf);
+ }
+
+ template <typename String, typename Header>
PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value)
{
char buf[128];
- sprintf(buf, "%g", value);
+ sprintf(buf, "%.17g", value);
return set_value_buffer(dest, header, header_mask, buf);
}
@@ -4548,7 +4557,7 @@ PUGI__NS_BEGIN
_fseeki64(file, 0, SEEK_END);
length_type length = _ftelli64(file);
_fseeki64(file, 0, SEEK_SET);
- #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405)
+ #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))
// there are 64-bit versions of fseek/ftell, let's use them
typedef off64_t length_type;
@@ -4793,7 +4802,7 @@ PUGI__NS_BEGIN
}
#endif
-#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405))
+#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)))
PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode)
{
return _wfopen(path, mode);
@@ -5112,6 +5121,12 @@ namespace pugi
return *this;
}
+ PUGI__FN xml_attribute& xml_attribute::operator=(float rhs)
+ {
+ set_value(rhs);
+ return *this;
+ }
+
PUGI__FN xml_attribute& xml_attribute::operator=(bool rhs)
{
set_value(rhs);
@@ -5167,6 +5182,13 @@ namespace pugi
return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs);
}
+ PUGI__FN bool xml_attribute::set_value(float rhs)
+ {
+ if (!_attr) return false;
+
+ return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs);
+ }
+
PUGI__FN bool xml_attribute::set_value(bool rhs)
{
if (!_attr) return false;
@@ -6224,6 +6246,13 @@ namespace pugi
return dn ? impl::set_value_convert(dn->contents, dn->header, impl::xml_memory_page_contents_allocated_mask, rhs) : false;
}
+ PUGI__FN bool xml_text::set(float rhs)
+ {
+ xml_node_struct* dn = _data_new();
+
+ return dn ? impl::set_value_convert(dn->contents, dn->header, impl::xml_memory_page_contents_allocated_mask, rhs) : false;
+ }
+
PUGI__FN bool xml_text::set(double rhs)
{
xml_node_struct* dn = _data_new();
@@ -6278,6 +6307,12 @@ namespace pugi
return *this;
}
+ PUGI__FN xml_text& xml_text::operator=(float rhs)
+ {
+ set(rhs);
+ return *this;
+ }
+
PUGI__FN xml_text& xml_text::operator=(bool rhs)
{
set(rhs);
@@ -9272,7 +9307,7 @@ PUGI__NS_BEGIN
bool step_push(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* parent, xpath_allocator* alloc)
{
- assert(a);
+ assert(a);
const char_t* name = a->name ? a->name + 0 : PUGIXML_TEXT("");
@@ -9312,7 +9347,7 @@ PUGI__NS_BEGIN
bool step_push(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc)
{
- assert(n);
+ assert(n);
xml_node_type type = PUGI__NODETYPE(n);
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 917ef4a..9798b46 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -352,6 +352,7 @@ namespace pugi
bool set_value(int rhs);
bool set_value(unsigned int rhs);
bool set_value(double rhs);
+ bool set_value(float rhs);
bool set_value(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
@@ -364,6 +365,7 @@ namespace pugi
xml_attribute& operator=(int rhs);
xml_attribute& operator=(unsigned int rhs);
xml_attribute& operator=(double rhs);
+ xml_attribute& operator=(float rhs);
xml_attribute& operator=(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
@@ -431,7 +433,7 @@ namespace pugi
const char_t* name() const;
// Get node value, or "" if node is empty or it has no value
- // Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
+ // Note: For <node>text</node> node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes.
const char_t* value() const;
// Get attribute list
@@ -694,6 +696,7 @@ namespace pugi
bool set(int rhs);
bool set(unsigned int rhs);
bool set(double rhs);
+ bool set(float rhs);
bool set(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
@@ -706,6 +709,7 @@ namespace pugi
xml_text& operator=(int rhs);
xml_text& operator=(unsigned int rhs);
xml_text& operator=(double rhs);
+ xml_text& operator=(float rhs);
xml_text& operator=(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG
@@ -1329,6 +1333,13 @@ namespace std
#endif
+// Make sure implementation is included in header-only mode
+// Use macro expansion in #include to work around QMake (QTBUG-11923)
+#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
+# define PUGIXML_SOURCE "pugixml.cpp"
+# include PUGIXML_SOURCE
+#endif
+
/**
* Copyright (c) 2006-2014 Arseny Kapoulkine
*