Pyrogenesis  trunk
RelaxNG.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_RELAXNG
19 #define INCLUDED_RELAXNG
20 
21 #include "lib/file/vfs/vfs.h"
22 #include "maths/MD5.h"
23 
24 typedef struct _xmlRelaxNG xmlRelaxNG;
26 typedef struct _xmlDoc xmlDoc;
27 typedef xmlDoc *xmlDocPtr;
28 
30 {
31 public:
34 
35  bool LoadGrammar(const std::string& grammar);
36 
37  bool LoadGrammarFile(const PIVFS& vfs, const VfsPath& grammarPath);
38 
39  MD5 GetGrammarHash() const { return m_Hash; }
40 
41  bool Validate(const std::string& filename, const std::string& document) const;
42 
43  bool ValidateEncoded(const std::string& filename, const std::string& document) const;
44 
45  bool ValidateEncoded(xmlDocPtr doc) const;
46 
47  bool CanValidate() const;
48 
49 private:
52 };
53 
54 /**
55  * There should be no references to validators or schemas outside of the cache anymore when calling this.
56  */
57 void ClearSchemaCache();
58 
59 #endif // INCLUDED_RELAXNG
bool LoadGrammarFile(const PIVFS &vfs, const VfsPath &grammarPath)
Definition: RelaxNG.cpp:121
~RelaxNGValidator()
Definition: RelaxNG.cpp:88
xmlDoc * xmlDocPtr
Definition: XMBStorage.h:26
bool ValidateEncoded(const std::string &filename, const std::string &document) const
Definition: RelaxNG.cpp:137
std::shared_ptr< IVFS > PIVFS
Definition: vfs.h:220
MD5 GetGrammarHash() const
Definition: RelaxNG.h:39
MD5 m_Hash
Definition: RelaxNG.h:50
xmlRelaxNGPtr m_Schema
Definition: RelaxNG.h:51
MD5 hashing algorithm.
Definition: MD5.h:27
bool CanValidate() const
Definition: RelaxNG.cpp:182
bool Validate(const std::string &filename, const std::string &document) const
Definition: RelaxNG.cpp:130
Definition: path.h:79
xmlRelaxNG * xmlRelaxNGPtr
Definition: RelaxNG.h:25
RelaxNGValidator()
Definition: RelaxNG.cpp:83
struct _xmlRelaxNG xmlRelaxNG
Definition: RelaxNG.h:24
Definition: RelaxNG.h:29
bool LoadGrammar(const std::string &grammar)
Definition: RelaxNG.cpp:92
Definition: vfs_util.cpp:39
struct _xmlDoc xmlDoc
Definition: XMBStorage.h:25
void ClearSchemaCache()
There should be no references to validators or schemas outside of the cache anymore when calling this...
Definition: RelaxNG.cpp:43
xmlDoc * xmlDocPtr
Definition: RelaxNG.h:27