PageRenderTime 26ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/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// ---------------------------------------------------------------------------
 8//  This is a simple class that lets us do easy (though not terribly efficient)
 9//  trancoding of XMLCh data to local code page for display.
10// ---------------------------------------------------------------------------
11class StrX
12{
13public :
14    typedef XERCES_CPP_NAMESPACE::XMLString XMLString;
15    // -----------------------------------------------------------------------
16    //  Constructors and Destructor
17    // -----------------------------------------------------------------------
18    StrX(const XMLCh* const toTranscode)
19    {
20        // Call the private transcoding method
21        fLocalForm = XMLString::transcode(toTranscode);
22    }
23
24    ~StrX()
25    {
26        delete [] fLocalForm;
27    }
28
29    // -----------------------------------------------------------------------
30    //  Getter methods
31    // -----------------------------------------------------------------------
32    const char* localForm() const
33    {
34        return fLocalForm;
35    }
36
37private :
38    // -----------------------------------------------------------------------
39    //  Private data members
40    //
41    //  fLocalForm
42    //      This is the local code page form of the string.
43    // -----------------------------------------------------------------------
44    char*   fLocalForm;
45};
46
47
48inline std::ostream& operator<<(std::ostream& target, const StrX& toDump)
49{
50    target << toDump.localForm();
51    return target;
52}
53