aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/parsing/element-map.txx
blob: a284c39b06227ec06031262b7f4efb71416d9148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// file      : xsd/cxx/tree/parsing/element-map.txx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef XSD_CXX_TREE_PARSING_ELEMENT_MAP_TXX
#define XSD_CXX_TREE_PARSING_ELEMENT_MAP_TXX

#include <xsd/cxx/xml/dom/elements.hxx>

#include <xsd/cxx/tree/exceptions.hxx>

namespace xsd
{
  namespace cxx
  {
    namespace tree
    {
      template <typename C, typename T>
      XSD_AUTO_PTR<element_type<C, T> > element_map<C, T>::
      parse (const xercesc::DOMElement& e, flags f)
      {
        const qualified_name n (xml::dom::name<C> (e));
        typename map::const_iterator i (map_->find (n));

        if (i != map_->end () && i->second.parser_ != 0)
          return (i->second.parser_) (e, f);
        else
          throw no_element_info<C> (n.name (), n.namespace_ ());
      }

      template<typename T, typename C, typename B>
      XSD_AUTO_PTR<element_type<C, B> >
      parser_impl (const xercesc::DOMElement& e, flags f)
      {
        return XSD_AUTO_PTR<element_type<C, B> > (new T (e, f));
      }
    }
  }
}

#endif // XSD_CXX_TREE_PARSING_ELEMENT_MAP_TXX