MCPcopy Create free account
hub / github.com/cinder/Cinder / parse_node_attributes

Method parse_node_attributes

include/rapidxml/rapidxml.hpp:2237–2298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2235 // Parse XML attributes of the node
2236 template<int Flags>
2237 void parse_node_attributes(Ch *&text, xml_node<Ch> *node)
2238 {
2239 // For all attributes
2240 while (attribute_name_pred::test(*text))
2241 {
2242 // Extract attribute name
2243 Ch *name = text;
2244 ++text; // Skip first character of attribute name
2245 skip<attribute_name_pred, Flags>(text);
2246 if (text == name)
2247 RAPIDXML_PARSE_ERROR("expected attribute name", name);
2248
2249 // Create new attribute
2250 xml_attribute<Ch> *attribute = this->allocate_attribute();
2251 attribute->name(name, text - name);
2252 node->append_attribute(attribute);
2253
2254 // Skip whitespace after attribute name
2255 skip<whitespace_pred, Flags>(text);
2256
2257 // Skip =
2258 if (*text != Ch('='))
2259 RAPIDXML_PARSE_ERROR("expected =", text);
2260 ++text;
2261
2262 // Add terminating zero after name
2263 if (!(Flags & parse_no_string_terminators))
2264 attribute->name()[attribute->name_size()] = 0;
2265
2266 // Skip whitespace after =
2267 skip<whitespace_pred, Flags>(text);
2268
2269 // Skip quote and remember if it was ' or "
2270 Ch quote = *text;
2271 if (quote != Ch('\'') && quote != Ch('"'))
2272 RAPIDXML_PARSE_ERROR("expected ' or \"", text);
2273 ++text;
2274
2275 // Extract attribute value and expand char refs in it
2276 Ch *value = text, *end;
2277 const int AttFlags = Flags & ~parse_normalize_whitespace; // No whitespace normalization in attributes
2278 if (quote == Ch('\''))
2279 end = skip_and_expand_character_refs<attribute_value_pred<Ch('\'')>, attribute_value_pure_pred<Ch('\'')>, AttFlags>(text);
2280 else
2281 end = skip_and_expand_character_refs<attribute_value_pred<Ch('"')>, attribute_value_pure_pred<Ch('"')>, AttFlags>(text);
2282
2283 // Set attribute value
2284 attribute->value(value, end - value);
2285
2286 // Make sure that end quote is present
2287 if (*text != quote)
2288 RAPIDXML_PARSE_ERROR("expected ' or \"", text);
2289 ++text; // Skip quote
2290
2291 // Add terminating zero after value
2292 if (!(Flags & parse_no_string_terminators))
2293 attribute->value()[attribute->value_size()] = 0;
2294

Callers

nothing calls this directly

Calls 7

allocate_attributeMethod · 0.80
append_attributeMethod · 0.80
name_sizeMethod · 0.80
value_sizeMethod · 0.80
testEnum · 0.50
nameMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected