From 2894cc4eb253859479a13b709faab1e95b7a924c Mon Sep 17 00:00:00 2001
From: "arseny.kapoulkine"
- $$ wording - one may think that child() has a string overload All tree functions - that work with strings work with either C-style null terminated strings or - STL strings of the selected character type. For example, node name accessors - look like this in char mode: + All tree functions that work with strings work with either C-style null terminated + strings or STL strings of the selected character type. For example, node + name accessors look like this in char mode:
const char* xml_node::name() const; bool xml_node::set_name(const char* value); @@ -417,12 +416,7 @@ performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion.str
has to be a valid string; passing null pointer results in undefined behavior. - There are also two overloads with the same semantics which accept a string - as an argument: -std::string as_utf8(const std::wstring& str); -std::wstring as_wide(const std::string& str); -
@@ -499,7 +493,7 @@ guarantees beyond the ones provided by callback. - $$ XPath functions may throw
xpath_exception
+ XPath functions may throwxpath_exception
on parsing error; also, XPath implementation uses STL, and thus may throw i.e.std::bad_alloc
in low memory conditions. Still, XPath functions provide strong exception guarantee. @@ -520,10 +514,10 @@ functions- All memory for tree structure, tree data and XPath objects is allocated - via globally specified functions, which default to malloc/free. You can - set your own allocation functions with set_memory_management functions. - The function interfaces are the same as that of malloc/free: + All memory for tree structure/data is allocated via globally specified + functions, which default to malloc/free. You can set your own allocation + functions with set_memory_management functions. The function interfaces + are the same as that of malloc/free:
typedef void* (*allocation_function)(size_t size); typedef void (*deallocation_function)(void* ptr); @@ -539,15 +533,13 @@Allocation function is called with the size (in bytes) as an argument and should return a pointer to memory block with alignment that is suitable - for storage of primitive types (usually a maximum of pointer and
-double
types alignment is sufficient) and - size that is greater or equal to the requested one. If the allocation fails, - the function has to return null pointer (throwing an exception from allocation - function results in undefined behavior). -- Deallocation function is called with the pointer that was returned by the - previous call; it is never called with a null pointer. If memory management - functions are not thread-safe, library thread safety is not guaranteed. + for pointer storage and size that is greater or equal to the requested + one. If the allocation fails, the function has to return null pointer (throwing + an exception from allocation function results in undefined behavior). Deallocation + function is called with the pointer that was returned by the previous call + or with a null pointer; null pointer deallocation should be handled as + a no-op. If memory management functions are not thread-safe, library thread + safety is not guaranteed.
This is a simple example of custom memory management (samples/custom_memory_management.cpp): @@ -580,6 +572,16 @@ are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.
++
+ ++ Note ++ + Currently memory for XPath objects is allocated using default operators + new/delete; this will change in the next version. +
-- cgit v1.2.3