vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XercesXMLUtils.h
Go to the documentation of this file.
1 #ifndef XERCESXMLUTILS_H
2 #define XERCESXMLUTILS_H
3 
4 #include <xercesc/dom/DOM.hpp>
5 #include <iostream>
6 
7 #ifndef HELPERS_IMP_EXP
8  #ifdef VRECKO_LIBRARY
9  #define HELPERS_IMP_EXP __declspec(dllexport)
10  #else
11  #define HELPERS_IMP_EXP __declspec(dllimport)
12  #endif
13 #endif
14 
15 
16 HELPERS_IMP_EXP XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* findXMLNode (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* rootNode, const char* nodeName, bool bSearchSubTrees = false);
17  // Doesn't search the [rootNode]!
18 HELPERS_IMP_EXP char* getNodeTextTrans (XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* node);
19  // It's the callers responsibility to release the pointer (use XMLString::release()).
20 
21 
22 // ---------------------------------------------------------------------------
23 // Class from XERCES examples:
24 // ----
25 // This is a simple class that lets us do easy (though not terribly efficient)
26 // trancoding of XMLCh data to local code page for display.
27 // ---------------------------------------------------------------------------
29 {
30  public :
31  StrX(const XMLCh* const toTranscode) {
32  // Call the private transcoding method
33  fLocalForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode);
34  }
35 
36  ~StrX() {
37  XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fLocalForm);
38  }
39 
40  // Getter methods
41  const char* localForm() const {
42  return fLocalForm;
43  }
44 
45  private :
46  // -----------------------------------------------------------------------
47  // Private data members
48  //
49  // fLocalForm
50  // This is the local code page form of the string.
51  // -----------------------------------------------------------------------
52  char* fLocalForm;
53 };
54 
55 #define XercesToStr(str) StrX(str).localForm()
56 
57 inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
58 {
59  target << toDump.localForm();
60  return target;
61 }
62 
63 
64 #endif