/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

  1. #include <cstdlib>
  2. #include <string>
  3. #include <iostream>
  4. #include "FWCore/Concurrency/interface/Xerces.h"
  5. #include <xercesc/parsers/SAXParser.hpp>
  6. // ---------------------------------------------------------------------------
  7. // This is a simple class that lets us do easy (though not terribly efficient)
  8. // trancoding of XMLCh data to local code page for display.
  9. // ---------------------------------------------------------------------------
  10. class StrX
  11. {
  12. public :
  13. typedef XERCES_CPP_NAMESPACE::XMLString XMLString;
  14. // -----------------------------------------------------------------------
  15. // Constructors and Destructor
  16. // -----------------------------------------------------------------------
  17. StrX(const XMLCh* const toTranscode)
  18. {
  19. // Call the private transcoding method
  20. fLocalForm = XMLString::transcode(toTranscode);
  21. }
  22. ~StrX()
  23. {
  24. delete [] fLocalForm;
  25. }
  26. // -----------------------------------------------------------------------
  27. // Getter methods
  28. // -----------------------------------------------------------------------
  29. const char* localForm() const
  30. {
  31. return fLocalForm;
  32. }
  33. private :
  34. // -----------------------------------------------------------------------
  35. // Private data members
  36. //
  37. // fLocalForm
  38. // This is the local code page form of the string.
  39. // -----------------------------------------------------------------------
  40. char* fLocalForm;
  41. };
  42. inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
  43. {
  44. target << toDump.localForm();
  45. return target;
  46. }