/DetectorDescription/RegressionTest/src/StrX.h
https://github.com/aivanov-cern/cmssw · C Header · 53 lines · 29 code · 7 blank · 17 comment · 0 complexity · 3aa7341faf475594eb6f3c47b720a6e6 MD5 · raw file
- #include <cstdlib>
- #include <string>
- #include <iostream>
- #include "FWCore/Concurrency/interface/Xerces.h"
- #include <xercesc/parsers/SAXParser.hpp>
- // ---------------------------------------------------------------------------
- // This is a simple class that lets us do easy (though not terribly efficient)
- // trancoding of XMLCh data to local code page for display.
- // ---------------------------------------------------------------------------
- class StrX
- {
- public :
- typedef XERCES_CPP_NAMESPACE::XMLString XMLString;
- // -----------------------------------------------------------------------
- // Constructors and Destructor
- // -----------------------------------------------------------------------
- StrX(const XMLCh* const toTranscode)
- {
- // Call the private transcoding method
- fLocalForm = XMLString::transcode(toTranscode);
- }
- ~StrX()
- {
- delete [] fLocalForm;
- }
- // -----------------------------------------------------------------------
- // Getter methods
- // -----------------------------------------------------------------------
- const char* localForm() const
- {
- return fLocalForm;
- }
- private :
- // -----------------------------------------------------------------------
- // Private data members
- //
- // fLocalForm
- // This is the local code page form of the string.
- // -----------------------------------------------------------------------
- char* fLocalForm;
- };
- inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
- {
- target << toDump.localForm();
- return target;
- }