OpenMS
Loading...
Searching...
No Matches
XMLFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
14
15namespace OpenMS
16{
17 namespace Internal
18 {
19 class XMLHandler;
20
37 class OPENMS_DLLAPI XMLFile
38 {
39
40public:
41
44
51 XMLFile(const std::string& schema_location, const std::string& version);
52
54 virtual ~XMLFile();
55
70 bool isValid(const std::string& filename, std::ostream& os);
71
73 const std::string& getVersion() const;
74
75protected:
94 void parse_(const std::string& filename, XMLHandler* handler);
95
111 void parseBuffer_(const std::string & buffer, XMLHandler * handler);
112
125 void save_(const std::string& filename, XMLHandler* handler) const;
126
127 std::string schema_location_;
128 std::string schema_version_;
129 std::string enforced_encoding_;
130
139 void enforceEncoding_(const std::string& encoding);
140 };
141
148 std::string OPENMS_DLLAPI encodeTab(const std::string& to_encode);
149 } // namespace Internal
150} // namespace OpenMS
151
Base class for loading and storing XML files via Xerces, with optional schema validation and transpar...
Definition XMLFile.h:38
std::string enforced_encoding_
Optional XML encoding override applied to the InputSource in parse_ and parseBuffer_; empty disables ...
Definition XMLFile.h:129
XMLFile(const std::string &schema_location, const std::string &version)
Construct with a schema location for later isValid calls.
XMLFile()
Construct an XMLFile without schema info; schema_location_ remains unset, so isValid cannot be used u...
void enforceEncoding_(const std::string &encoding)
Set or clear the XML-encoding override applied to subsequent parse_ / parseBuffer_ calls.
const std::string & getVersion() const
Return the schema version string passed to the parameterised constructor; empty for default-construct...
std::string schema_location_
Path of the XML schema for validation; empty when the default constructor was used (isValid then thro...
Definition XMLFile.h:127
bool isValid(const std::string &filename, std::ostream &os)
Check if filename validates against the bound XML schema.
void parse_(const std::string &filename, XMLHandler *handler)
Parse the XML file at filename through handler.
std::string schema_version_
Schema version string returned by getVersion.
Definition XMLFile.h:128
void save_(const std::string &filename, XMLHandler *handler) const
Stores the contents of the XML handler given by handler in the file given by filename.
virtual ~XMLFile()
Virtual destructor — defaulted; allows safe deletion through a base-class pointer.
void parseBuffer_(const std::string &buffer, XMLHandler *handler)
Parse an in-memory XML buffer through handler.
Base class for XML handlers.
Definition XMLHandler.h:316
std::string encodeTab(const std::string &to_encode)
Encodes tabs '\t' in the string as 	 and returns the encoded string.
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19