| 1 | *** old2/rapidxml.hpp
|
|---|
| 2 | --- new2/rapidxml.hpp
|
|---|
| 3 | ***************
|
|---|
| 4 | *** 145,150 ****
|
|---|
| 5 | --- 145,152 ----
|
|---|
| 6 | node_pi //!< A PI node. Name contains target. Value contains instructions.
|
|---|
| 7 | };
|
|---|
| 8 |
|
|---|
| 9 | + const std::size_t auto_size = ~0;
|
|---|
| 10 | +
|
|---|
| 11 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 12 | // Parsing flags
|
|---|
| 13 |
|
|---|
| 14 | ***************
|
|---|
| 15 | *** 406,425 ****
|
|---|
| 16 | //! \return Pointer to allocated node. This pointer will never be NULL.
|
|---|
| 17 | xml_node<Ch> *allocate_node(node_type type,
|
|---|
| 18 | const Ch *name = 0, const Ch *value = 0,
|
|---|
| 19 | ! std::size_t name_size = 0, std::size_t value_size = 0)
|
|---|
| 20 | {
|
|---|
| 21 | void *memory = allocate_memory(sizeof(xml_node<Ch>));
|
|---|
| 22 | xml_node<Ch> *node = new(memory) xml_node<Ch>(type);
|
|---|
| 23 | if (name)
|
|---|
| 24 | {
|
|---|
| 25 | ! if (name_size > 0)
|
|---|
| 26 | node->name(name, name_size);
|
|---|
| 27 | else
|
|---|
| 28 | node->name(name);
|
|---|
| 29 | }
|
|---|
| 30 | if (value)
|
|---|
| 31 | {
|
|---|
| 32 | ! if (value_size > 0)
|
|---|
| 33 | node->value(value, value_size);
|
|---|
| 34 | else
|
|---|
| 35 | node->value(value);
|
|---|
| 36 | --- 408,427 ----
|
|---|
| 37 | //! \return Pointer to allocated node. This pointer will never be NULL.
|
|---|
| 38 | xml_node<Ch> *allocate_node(node_type type,
|
|---|
| 39 | const Ch *name = 0, const Ch *value = 0,
|
|---|
| 40 | ! std::size_t name_size = auto_size, std::size_t value_size = auto_size)
|
|---|
| 41 | {
|
|---|
| 42 | void *memory = allocate_memory(sizeof(xml_node<Ch>));
|
|---|
| 43 | xml_node<Ch> *node = new(memory) xml_node<Ch>(type);
|
|---|
| 44 | if (name)
|
|---|
| 45 | {
|
|---|
| 46 | ! if (name_size != auto_size)
|
|---|
| 47 | node->name(name, name_size);
|
|---|
| 48 | else
|
|---|
| 49 | node->name(name);
|
|---|
| 50 | }
|
|---|
| 51 | if (value)
|
|---|
| 52 | {
|
|---|
| 53 | ! if (value_size != auto_size)
|
|---|
| 54 | node->value(value, value_size);
|
|---|
| 55 | else
|
|---|
| 56 | node->value(value);
|
|---|
| 57 | ***************
|
|---|
| 58 | *** 437,456 ****
|
|---|
| 59 | //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string.
|
|---|
| 60 | //! \return Pointer to allocated attribute. This pointer will never be NULL.
|
|---|
| 61 | xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0,
|
|---|
| 62 | ! std::size_t name_size = 0, std::size_t value_size = 0)
|
|---|
| 63 | {
|
|---|
| 64 | void *memory = allocate_memory(sizeof(xml_attribute<Ch>));
|
|---|
| 65 | xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;
|
|---|
| 66 | if (name)
|
|---|
| 67 | {
|
|---|
| 68 | ! if (name_size > 0)
|
|---|
| 69 | attribute->name(name, name_size);
|
|---|
| 70 | else
|
|---|
| 71 | attribute->name(name);
|
|---|
| 72 | }
|
|---|
| 73 | if (value)
|
|---|
| 74 | {
|
|---|
| 75 | ! if (value_size > 0)
|
|---|
| 76 | attribute->value(value, value_size);
|
|---|
| 77 | else
|
|---|
| 78 | attribute->value(value);
|
|---|
| 79 | --- 439,458 ----
|
|---|
| 80 | //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string.
|
|---|
| 81 | //! \return Pointer to allocated attribute. This pointer will never be NULL.
|
|---|
| 82 | xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0,
|
|---|
| 83 | ! std::size_t name_size = auto_size, std::size_t value_size = auto_size)
|
|---|
| 84 | {
|
|---|
| 85 | void *memory = allocate_memory(sizeof(xml_attribute<Ch>));
|
|---|
| 86 | xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;
|
|---|
| 87 | if (name)
|
|---|
| 88 | {
|
|---|
| 89 | ! if (name_size != auto_size)
|
|---|
| 90 | attribute->name(name, name_size);
|
|---|
| 91 | else
|
|---|
| 92 | attribute->name(name);
|
|---|
| 93 | }
|
|---|
| 94 | if (value)
|
|---|
| 95 | {
|
|---|
| 96 | ! if (value_size != auto_size)
|
|---|
| 97 | attribute->value(value, value_size);
|
|---|
| 98 | else
|
|---|
| 99 | attribute->value(value);
|
|---|
| 100 | ***************
|
|---|
| 101 | *** 465,474 ****
|
|---|
| 102 | //! \param source String to initialize the allocated memory with, or 0 to not initialize it.
|
|---|
| 103 | //! \param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.
|
|---|
| 104 | //! \return Pointer to allocated char array. This pointer will never be NULL.
|
|---|
| 105 | ! Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)
|
|---|
| 106 | {
|
|---|
| 107 | ! assert(source || size); // Either source or size (or both) must be specified
|
|---|
| 108 | ! if (size == 0)
|
|---|
| 109 | size = internal::measure(source) + 1;
|
|---|
| 110 | Ch *result = static_cast<Ch *>(allocate_memory(size));
|
|---|
| 111 | if (source)
|
|---|
| 112 | --- 467,476 ----
|
|---|
| 113 | //! \param source String to initialize the allocated memory with, or 0 to not initialize it.
|
|---|
| 114 | //! \param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.
|
|---|
| 115 | //! \return Pointer to allocated char array. This pointer will never be NULL.
|
|---|
| 116 | ! Ch *allocate_string(const Ch *source = 0, std::size_t size = auto_size)
|
|---|
| 117 | {
|
|---|
| 118 | ! assert(source || size != auto_size); // Either source or size (or both) must be specified
|
|---|
| 119 | ! if (size == auto_size)
|
|---|
| 120 | size = internal::measure(source) + 1;
|
|---|
| 121 | Ch *result = static_cast<Ch *>(allocate_memory(size));
|
|---|
| 122 | if (source)
|
|---|