fintp_ws
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
XmlStringUtil.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #pragma once
22 
23 #ifdef WIN32
24  #define __MSXML_LIBRARY_DEFINED__
25 #endif
26 
27 #include <xercesc/util/XMLString.hpp>
28 XERCES_CPP_NAMESPACE_USE
29 
30 class XStrWs
31 {
32  public :
33  // Constructors and Destructor
34  XStrWs( const char* toTranscode )
35  {
36  // Call the private transcoding method
37  fUnicodeForm = XMLString::transcode( toTranscode );
38  }
39 
40  XStrWs( const std::string& toTranscode )
41  {
42  // Call the private transcoding method
43  fUnicodeForm = XMLString::transcode( toTranscode.c_str() );
44  }
45 
47  {
48  try
49  {
50  XMLString::release( &fUnicodeForm );
51  }catch(...){};
52  }
53 
54  // Getter methods
55  const XMLCh* uniForm() const
56  {
57  return fUnicodeForm;
58  }
59 
60  private :
61  // Private data members
62  // fUnicodeForm - This is the Unicode XMLCh format of the string.
63  XMLCh* fUnicodeForm;
64  XStrWs() : fUnicodeForm( NULL ) {};
65 };
66 
67 class StrXWs
68 {
69  public :
70  // -----------------------------------------------------------------------
71  // Constructors and Destructor
72  // -----------------------------------------------------------------------
73  StrXWs( const XMLCh* toTranscode )
74  {
75  // Call the private transcoding method
76  fLocalForm = XMLString::transcode( toTranscode );
77  }
78 
80  {
81  try
82  {
83  XMLString::release( &fLocalForm );
84  }catch( ... ){};
85  }
86 
87 
88  // -----------------------------------------------------------------------
89  // Getter methods
90  // -----------------------------------------------------------------------
91  const char* locForm() const
92  {
93  return fLocalForm;
94  }
95 
96  private :
97  // -----------------------------------------------------------------------
98  // Private data members
99  //
100  // fLocalForm
101  // This is the local code page form of the string.
102  // -----------------------------------------------------------------------
103  char* fLocalForm;
104  StrXWs() : fLocalForm( NULL ) {};
105 };
106 
107 #define unicodeFormWs( str ) ( XStrWs( str ).uniForm() )
108 #define localFormWs( str ) ( StrXWs( str ).locForm() )