diff options
author | Steve Doiel <steved@usnr.com> | 2015-01-06 15:33:56 -0800 |
---|---|---|
committer | Steve Doiel <steved@usnr.com> | 2015-01-06 15:33:56 -0800 |
commit | 32f0a8bd3a5c9f3c454164f4d23289851b0de3e7 (patch) | |
tree | bbd2c9c1e10e264243b2c8295feda2513cb1a15f /src/pugixml.cpp | |
parent | ff16dbdd4c63fa46cc1f38eda4cfb66f38047657 (diff) |
Add xml_text::set for float
Make float/double round-trip
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r-- | src/pugixml.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index dd3f427..6608d8d 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3954,10 +3954,18 @@ PUGI__NS_BEGIN return set_value_buffer(dest, header, header_mask, buf); } + PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, float value) + { + char buf[128]; + sprintf(buf, "%.9g", value); + + return set_value_buffer(dest, header, header_mask, buf); + } + PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& 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); } @@ -5603,6 +5611,13 @@ namespace pugi return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_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->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + PUGI__FN bool xml_text::set(double rhs) { xml_node_struct* dn = _data_new(); |