mirror of
https://github.com/zeux/pugixml.git
synced 2025-01-17 04:50:23 +08:00
Add xml_text::set for float
Make float/double round-trip
This commit is contained in:
parent
ff16dbdd4c
commit
32f0a8bd3a
@ -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();
|
||||
|
@ -693,6 +693,7 @@ namespace pugi
|
||||
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
|
||||
bool set(int rhs);
|
||||
bool set(unsigned int rhs);
|
||||
bool set(float rhs);
|
||||
bool set(double rhs);
|
||||
bool set(bool rhs);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user