| 1 | // file : xsd/cxx/tree/parsing/long.hxx |
|---|
| 2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
|---|
| 3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
|---|
| 4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
|---|
| 5 | |
|---|
| 6 | #ifndef XSD_CXX_TREE_PARSING_LONG_HXX |
|---|
| 7 | #define XSD_CXX_TREE_PARSING_LONG_HXX |
|---|
| 8 | |
|---|
| 9 | #include <xsd/cxx/ro-string.hxx> |
|---|
| 10 | #include <xsd/cxx/zc-istream.hxx> |
|---|
| 11 | |
|---|
| 12 | #include <xsd/cxx/xml/string.hxx> // xml::transcode |
|---|
| 13 | |
|---|
| 14 | #include <xsd/cxx/tree/text.hxx> // text_content |
|---|
| 15 | |
|---|
| 16 | namespace xsd |
|---|
| 17 | { |
|---|
| 18 | namespace cxx |
|---|
| 19 | { |
|---|
| 20 | namespace tree |
|---|
| 21 | { |
|---|
| 22 | template <typename C> |
|---|
| 23 | struct traits<long long, C> |
|---|
| 24 | { |
|---|
| 25 | typedef long long type; |
|---|
| 26 | |
|---|
| 27 | static type |
|---|
| 28 | create (const xercesc::DOMElement& e, flags f, container* c); |
|---|
| 29 | |
|---|
| 30 | static type |
|---|
| 31 | create (const xercesc::DOMAttr& a, flags f, container* c); |
|---|
| 32 | |
|---|
| 33 | static type |
|---|
| 34 | create (const std::basic_string<C>& s, |
|---|
| 35 | const xercesc::DOMElement*, |
|---|
| 36 | flags, |
|---|
| 37 | container*); |
|---|
| 38 | }; |
|---|
| 39 | |
|---|
| 40 | template <typename C> |
|---|
| 41 | long long traits<long long, C>:: |
|---|
| 42 | create (const xercesc::DOMElement& e, flags f, container* c) |
|---|
| 43 | { |
|---|
| 44 | return create (text_content<C> (e), 0, f, c); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | template <typename C> |
|---|
| 48 | long long traits<long long, C>:: |
|---|
| 49 | create (const xercesc::DOMAttr& a, flags f, container* c) |
|---|
| 50 | { |
|---|
| 51 | return create (xml::transcode<C> (a.getValue ()), 0, f, c); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | template <typename C> |
|---|
| 55 | long long traits<long long, C>:: |
|---|
| 56 | create (const std::basic_string<C>& s, |
|---|
| 57 | const xercesc::DOMElement*, |
|---|
| 58 | flags, |
|---|
| 59 | container*) |
|---|
| 60 | { |
|---|
| 61 | // This type cannot have whitespaces in its values. As result we |
|---|
| 62 | // don't need to waste time collapsing whitespaces. All we need to |
|---|
| 63 | // do is trim the string representation which can be done without |
|---|
| 64 | // copying. |
|---|
| 65 | // |
|---|
| 66 | ro_string<C> tmp (s); |
|---|
| 67 | trim (tmp); |
|---|
| 68 | |
|---|
| 69 | zc_istream<C> is (tmp); |
|---|
| 70 | |
|---|
| 71 | type t; |
|---|
| 72 | is >> t; |
|---|
| 73 | |
|---|
| 74 | return t; |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | #endif // XSD_CXX_TREE_PARSING_LONG_HXX |
|---|