CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StrX.h
Go to the documentation of this file.
1 /***************************************************************************
2  StrX.h - description
3  -------------------
4  begin : Tue Oct 23 2001
5  copyright : See Xerces C++ documentation
6  email : case@ucdhep.ucdavis.edu
7  ***************************************************************************/
8 
9 #ifndef STRX_H
10 #define STRX_H
11 
12 #include <xercesc/util/XercesDefs.hpp>
14 #include <xercesc/sax2/XMLReaderFactory.hpp>
15 #include <xercesc/sax2/SAX2XMLReader.hpp>
16 #include <xercesc/util/XMLString.hpp>
17 #include <string>
18 #include <iostream>
19 
28 // ---------------------------------------------------------------------------
29 // This is a simple class that lets us do easy (though not terribly efficient)
30 // trancoding of XMLCh data to local code page for display.
31 // ---------------------------------------------------------------------------
32 class StrX
33 {
34 public:
35  typedef XERCES_CPP_NAMESPACE::XMLString XMLString;
36  // -----------------------------------------------------------------------
37  // Constructors and Destructor
38  // -----------------------------------------------------------------------
39  StrX(const XMLCh* const toTranscode)// : fXMLChForm(toTranscode)
40  {
41  fLocalForm = XMLString::transcode(toTranscode);
42  fXMLChForm = XMLString::transcode(fLocalForm);
43  }
44 
45  StrX( const char* const toTranscode )
46  {
47  fXMLChForm = XMLString::transcode(toTranscode);
48  fLocalForm = XMLString::transcode(fXMLChForm);
49  }
50 
51  StrX( const std::string& toTranscode )
52  {
53  fXMLChForm = XMLString::transcode(toTranscode.c_str());
54  fLocalForm = XMLString::transcode(fXMLChForm);
55  }
56 
58  {
61  }
62 
63  // -----------------------------------------------------------------------
64  // Getter methods
65  // -----------------------------------------------------------------------
66  const char* localForm() const
67  {
68  return fLocalForm;
69  }
70 
71  const XMLCh* xmlChForm() const
72  {
73  return fXMLChForm;
74  }
75 
76 private:
77  XMLCh * fXMLChForm;
78  char * fLocalForm;
79 
80 };
81 
82 inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
83 {
84  target << toDump.localForm();
85  return target;
86 }
87 #endif
XERCES_CPP_NAMESPACE::XMLString XMLString
Definition: StrX.h:35
StrX(const char *const toTranscode)
Definition: StrX.h:45
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const XMLCh * xmlChForm() const
Definition: StrX.h:71
StrX(const XMLCh *const toTranscode)
Definition: StrX.h:39
~StrX()
Definition: StrX.h:57
char * fLocalForm
Definition: StrX.h:78
StrX(const std::string &toTranscode)
Definition: StrX.h:51
XMLCh * fXMLChForm
Definition: StrX.h:77
const char * localForm() const
Definition: StrX.h:66
Definition: StrX.h:32