casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
xerces.h
Go to the documentation of this file.
1 //# xerces.h: handle differences between Xerces-C++ version 2.0 and 3.0...
2 //# Copyright (C) 2014
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef STDCASA_XERCES_
28 #define STDCASA_XERCES_
29 #include <string>
30 #include <xercesc/dom/DOM.hpp>
31 #include <xercesc/parsers/XercesDOMParser.hpp>
32 #include <xercesc/util/PlatformUtils.hpp>
33 #include <xercesc/dom/DOMImplementation.hpp>
34 #include <xercesc/dom/DOMImplementationLS.hpp>
35 #include <xercesc/framework/LocalFileFormatTarget.hpp>
36 #include <xercesc/framework/Wrapper4InputSource.hpp>
37 #include <xercesc/parsers/XercesDOMParser.hpp>
38 
39 namespace casa {
40  namespace xerces {
41 #if XERCES_VERSION_MAJOR > 2
42  typedef xercesc::DOMLSSerializer Writer;
43  typedef xercesc::DOMLSParser Parser;
44 #if defined(DEFINE_CASA_XERCES_STATICS)
45  static const XMLCh *fgDOMValidate = xercesc::XMLUni::fgDOMValidate;
46 #endif
47  inline Writer *create_writer(void *impl) { return static_cast<xercesc::DOMImplementationLS*>(impl)->createLSSerializer( ); }
48  inline Parser *create_parser(void *impl) { return static_cast<xercesc::DOMImplementationLS*>(impl)->createLSParser(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS,0 ); }
49  inline XMLCh *write_to_string( Writer *writer, xercesc::DOMNode *n ) { return writer->writeToString(n); }
50  inline xercesc::DOMDocument *dom_parse( Parser *parser, const xercesc::Wrapper4InputSource &source ) { return parser->parse(&source); }
51  inline bool write_to_file( Writer *writer, xercesc::DOMNode *n, std::string file, const XMLCh * const encoding ) {
52  xercesc::DOMImplementation* impl=xercesc::DOMImplementationRegistry::getDOMImplementation(xercesc::XMLString::transcode("LS"));
53  xercesc::DOMLSOutput *sink = static_cast<xercesc::DOMImplementationLS*>(impl)->createLSOutput();
54  xercesc::LocalFileFormatTarget fileTarget(file.c_str());
55  sink->setEncoding(encoding);
56  sink->setByteStream(&fileTarget);
57  bool result = writer->write(n,sink);
58  sink->release( );
59  return result;
60  }
61  template<typename T>
62  inline bool can_set_parameter( Parser *parser, const XMLCh *name, T value ) { return parser->getDomConfig()->canSetParameter(name,value); }
63  template<typename T>
64  inline void set_parameter( Parser *parser, const XMLCh *name, T value ) { return parser->getDomConfig()->setParameter(name,value); }
65 #else
66  typedef xercesc::DOMWriter Writer;
67  typedef xercesc::DOMBuilder Parser;
68 #if defined(DEFINE_CASA_XERCES_STATICS)
69  static const XMLCh *fgDOMValidate = xercesc::XMLUni::fgDOMValidation;
70 #endif
71  inline Writer *create_writer(void *impl) { return static_cast<xercesc::DOMImplementationLS*>(impl)->createDOMWriter( ); }
72  inline Parser *create_parser(void *impl) { return static_cast<xercesc::DOMImplementationLS*>(impl)->createDOMBuilder(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS, 0); }
73  inline XMLCh *write_to_string( Writer *writer, xercesc::DOMNode *n ) { return writer->writeToString(*n); }
74  inline xercesc::DOMDocument *dom_parse( Parser *parser, const xercesc::Wrapper4InputSource &source ) { return parser->parse(source); }
75  inline bool write_to_file( Writer *writer, xercesc::DOMNode *n, std::string file, const XMLCh * const encoding ) {
76  xercesc::LocalFileFormatTarget fileTarget(file.c_str());
77  writer->setEncoding(encoding);
78  return writer->writeNode(&fileTarget,*n);
79  }
80  template<typename T>
81  inline bool can_set_parameter( Parser *parser, const XMLCh *name, T value ) { return parser->canSetFeature(name,value); }
82  template<typename T>
83  inline void set_parameter( Parser *parser, const XMLCh *name, T value ) { return parser->setFeature(name,value); }
84 #endif
85  }
86 }
87 #endif
void set_parameter(Parser *parser, const XMLCh *name, T value)
Definition: xerces.h:83
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
XMLCh * write_to_string(Writer *writer, xercesc::DOMNode *n)
Definition: xerces.h:73
xercesc::DOMDocument * dom_parse(Parser *parser, const xercesc::Wrapper4InputSource &source)
Definition: xerces.h:74
bool write_to_file(Writer *writer, xercesc::DOMNode *n, std::string file, const XMLCh *const encoding)
Definition: xerces.h:75
xercesc::DOMWriter Writer
Definition: xerces.h:66
Writer * create_writer(void *impl)
Definition: xerces.h:71
xercesc::DOMBuilder Parser
Definition: xerces.h:67
Parser * create_parser(void *impl)
Definition: xerces.h:72
bool can_set_parameter(Parser *parser, const XMLCh *name, T value)
Definition: xerces.h:81
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100