Vaucanson  1.4.1
strings.hxx
1 // strings.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2004, 2005, 2006, 2007 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_XML_STRINGS_HXX
18 # define VCSN_XML_STRINGS_HXX
19 
21 
22 namespace vcsn
23 {
24  namespace xml
25  {
26 
27  /*----------------.
28  | Converter tools |
29  `----------------*/
30 
31  // Transcode \a cpp to XML.
32  inline
33  XMLCh*
34  transcode (const char* ccp)
35  {
36  return xercesc::XMLString::transcode(ccp);
37  }
38 
39  // Transcode \a s to XML.
40  inline
41  XMLCh*
42  transcode (const std::string& s)
43  {
44  return transcode (s.c_str());
45  }
46 
47  inline
48  std::string
49  xmlstr(const XMLCh* xmlstr)
50  {
51  assertion(xmlstr != 0);
52 
53  char* cstr = xercesc::XMLString::transcode(xmlstr);
54  assertion(cstr != 0);
55 
56  std::string ret (cstr);
57  xercesc::XMLString::release(&cstr);
58 
59  return ret;
60  }
61 
62  } // End of namespace xml.
63 
64 } // End of namespace vcsn.
65 
66 #endif // ! VCSN_XML_STRINGS_HXX