casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XMLFileReaderWriter.h
Go to the documentation of this file.
1 //# XMLFileReaderWriter.h: Implementation for reading/writing XML files.
2 //# Copyright (C) 2008
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 XMLFILEREADERWRITIER_H_
28 #define XMLFILEREADERWRITIER_H_
29 
30 #include <QtXml>
31 
33 
34 #include <casa/namespace.h>
35 
36 namespace casa {
37 
38 // Constants and methods for reading/writing RS XML files.
39  class RSXML {
40  public:
41  // Converts a casacore::Record to/from a QDomElement.
42  // <group>
43  static QDomElement recordToXML(const casacore::RecordInterface& record,
44  casacore::String elementName = "casa-record");
45  static casacore::Record XMLToRecord(const QDomElement& element);
46  // </group>
47 
48  private:
49  // Document used for creating nodes.
50  static QDomDocument DOCUMENT;
51 
52  // Constants.
53  // <group>
54  static const QString ARRAY;
55  static const QString FIELD;
56  static const QString NAME;
57  static const QString SHAPE;
58  static const QString TYPE;
59  static const QString VAL;
60  // </group>
61 
62  // Converts an casacore::IPosition to/from a QString.
63  // <group>
64  static QString shapeToString(const casacore::IPosition& shape);
65  static casacore::IPosition stringToShape(const QString& shape);
66  // </group>
67  };
68 
69 
70 // Implementation of RegionFileReader/RegionFileWriter for reading/writing
71 // CASA-XML files.
73  public:
74  // Static Members //
75 
76  // Returns the shapes represented by the given QDomElement. The top-level
77  // element MUST have tag name SHAPE_OPTIONS, and will have zero or more
78  // children elements, each representing a RegionShape, with tag name
79  // SHAPE.
80  static std::vector<RegionShape*> DOMToShapes(QDomElement& element);
81 
82  // Returns a QDomElement that represents the given shapes. The top-level
83  // element will have tag name SHAPE_OPTIONS, and will have zero or more
84  // children elements, each representing a RegionShape, with tag name SHAPE.
85  // The given document is used to create the element, but the element is NOT
86  // added to the document.
87  static QDomElement shapesToDOM(QDomDocument& document,
88  const std::vector<RegionShape*>& shapes);
89 
90  // XML file constants.
91  // <group>
92  static const QString DOCROOT_NAME;
93  static const pair<QString, QString> VERSION;
94  static const QString SHAPE_OPTIONS;
95  static const QString SHAPE;
96  // </group>
97 
98 
99  // Non-Static Members //
100 
101  // Constructor.
103 
104  // Destructor.
106 
107  // RSFileReader methods //
108 
109  // Implements RSFileReader::read.
110  bool read(std::vector<RegionShape*>& shapes);
111 
112  // RSFileWriter methods //
113 
114  // Implements RSFileWriter::optionsWidget.
115  QWidget* optionsWidget() const;
116 
117  // Implements RSFileWriter::setOptions.
118  void setOptions(const QWidget* widget);
119 
120  // Implements RSFileWriter::write.
121  bool write(const std::vector<RegionShape*>& shapes) const;
122  };
123 
124 }
125 
126 #endif /* XMLFILEREADERWRITIER_H_ */
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
static const QString DOCROOT_NAME
XML file constants.
bool read(std::vector< RegionShape * > &shapes)
RSFileReader methods //.
static QDomDocument DOCUMENT
Document used for creating nodes.
~XMLFileReaderWriter()
Destructor.
void setOptions(const QWidget *widget)
Implements RSFileWriter::setOptions.
XMLFileReaderWriter()
Non-Static Members //.
Abstract superclass for any class that reads a format that produces RegionShapes from a file...
static const QString SHAPE
static std::vector< RegionShape * > DOMToShapes(QDomElement &element)
Static Members //.
static QDomElement recordToXML(const casacore::RecordInterface &record, casacore::String elementName="casa-record")
Converts a casacore::Record to/from a QDomElement.
Abstract superclass for any class that writes RegionShapes to a region file format.
static casacore::Record XMLToRecord(const QDomElement &element)
static casacore::IPosition stringToShape(const QString &shape)
Constants and methods for reading/writing RS XML files.
static QString shapeToString(const casacore::IPosition &shape)
Converts an casacore::IPosition to/from a QString.
static const QString SHAPE_OPTIONS
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool write(const std::vector< RegionShape * > &shapes) const
Implements RSFileWriter::write.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
static QDomElement shapesToDOM(QDomDocument &document, const std::vector< RegionShape * > &shapes)
Returns a QDomElement that represents the given shapes.
static const pair< QString, QString > VERSION
QWidget * optionsWidget() const
RSFileWriter methods //.
static const QString SHAPE
static const QString TYPE
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static const QString VAL
static const QString NAME
static const QString ARRAY
Constants.
Abstract base class for Record classes.
Implementation of RegionFileReader/RegionFileWriter for reading/writing CASA-XML files.
static const QString FIELD