LIBXML_DOMDocument.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #if (HAVE_LIBXML > 0 || _MSC_VER == 0)
  21. #ifndef FIX_LIBXMLDOMDOCUMENT_H
  22. #define FIX_LIBXMLDOMDOCUMENT_H
  23. #ifdef _MSC_VER
  24. #pragma comment( lib, "libxml2" )
  25. #endif
  26. #include "DOMDocument.h"
  27. #include "Exceptions.h"
  28. #include <libxml/xmlmemory.h>
  29. #include <libxml/parser.h>
  30. namespace FIX
  31. {
  32. /// XML attribute as represented by libxml.
  33. class LIBXML_DOMAttributes : public DOMAttributes
  34. {
  35. public:
  36. LIBXML_DOMAttributes( xmlNodePtr pNode )
  37. : m_pNode(pNode) {}
  38. bool get( const std::string&, std::string& );
  39. DOMAttributes::map toMap();
  40. private:
  41. xmlNodePtr m_pNode;
  42. };
  43. /// XML node as represented by libxml.
  44. class LIBXML_DOMNode : public DOMNode
  45. {
  46. public:
  47. LIBXML_DOMNode( xmlNodePtr pNode )
  48. : m_pNode(pNode) {}
  49. ~LIBXML_DOMNode() {}
  50. DOMNodePtr getFirstChildNode();
  51. DOMNodePtr getNextSiblingNode();
  52. DOMAttributesPtr getAttributes();
  53. std::string getName();
  54. std::string getText();
  55. private:
  56. xmlNodePtr m_pNode;
  57. };
  58. /// XML document as represented by libxml.
  59. class LIBXML_DOMDocument : public DOMDocument
  60. {
  61. public:
  62. LIBXML_DOMDocument() throw( ConfigError );
  63. ~LIBXML_DOMDocument();
  64. bool load( std::istream& );
  65. bool load( const std::string& );
  66. bool xml( std::ostream& );
  67. DOMNodePtr getNode( const std::string& );
  68. private:
  69. xmlDocPtr m_pDoc;
  70. };
  71. }
  72. #endif
  73. #endif