parser.txx 888 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // file : xml/parser.txx
  2. // copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC
  3. // license : MIT; see accompanying LICENSE file
  4. #include <xml/value-traits>
  5. namespace xml
  6. {
  7. template <typename T>
  8. T parser::
  9. attribute (const qname_type& qn, const T& dv) const
  10. {
  11. if (const element_entry* e = get_element ())
  12. {
  13. attribute_map_type::const_iterator i (e->attr_map_.find (qn));
  14. if (i != e->attr_map_.end ())
  15. {
  16. if (!i->second.handled)
  17. {
  18. i->second.handled = true;
  19. e->attr_unhandled_--;
  20. }
  21. return value_traits<T>::parse (i->second.value, *this);
  22. }
  23. }
  24. return dv;
  25. }
  26. template <typename T>
  27. T parser::
  28. element (const qname_type& qn, const T& dv)
  29. {
  30. if (peek () == start_element && qname () == qn)
  31. {
  32. next ();
  33. return element<T> ();
  34. }
  35. return dv;
  36. }
  37. }