OpenMS
XMLFile.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS includes
12 #include <OpenMS/CONCEPT/Types.h>
14 
15 namespace OpenMS
16 {
17  namespace Internal
18  {
19  class XMLHandler;
20 
22  class OPENMS_DLLAPI XMLFile
23  {
24 
25 public:
26 
30  XMLFile(const String& schema_location, const String& version);
32  virtual ~XMLFile();
33 
45  bool isValid(const String& filename, std::ostream& os);
46 
48  const String& getVersion() const;
49 
50 protected:
57  void parse_(const String& filename, XMLHandler* handler);
58 
66  void parseBuffer_(const std::string & buffer, XMLHandler * handler);
67 
73  void save_(const String& filename, XMLHandler* handler) const;
74 
77 
80 
83 
84  void enforceEncoding_(const String& encoding);
85  };
86 
93  String OPENMS_DLLAPI encodeTab(const String& to_encode);
94  } // namespace Internal
95 } // namespace OpenMS
96 
97 
Base class for loading/storing XML files that have a handler derived from XMLHandler.
Definition: XMLFile.h:23
const String & getVersion() const
return the version of the schema
XMLFile()
Default constructor.
String schema_version_
Version string.
Definition: XMLFile.h:79
String enforced_encoding_
Encoding string that replaces the encoding (system dependent or specified in the XML)....
Definition: XMLFile.h:82
void enforceEncoding_(const String &encoding)
void parse_(const String &filename, XMLHandler *handler)
Parses the XML file given by filename using the handler given by handler.
XMLFile(const String &schema_location, const String &version)
Constructor that sets the schema location.
void save_(const String &filename, XMLHandler *handler) const
Stores the contents of the XML handler given by handler in the file given by filename.
virtual ~XMLFile()
Destructor.
String schema_location_
XML schema file location.
Definition: XMLFile.h:76
void parseBuffer_(const std::string &buffer, XMLHandler *handler)
Parses the in-memory buffer given by buffer using the handler given by handler.
bool isValid(const String &filename, std::ostream &os)
Checks if a file validates against the XML schema.
Base class for XML handlers.
Definition: XMLHandler.h:300
A more convenient string class.
Definition: String.h:34
String encodeTab(const String &to_encode)
Encodes tabs '\t' in the string as &#x9; and returns the encoded string.
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22