Pyrogenesis  trunk
RelaxNG.h
Go to the documentation of this file.
1 /* Copyright (C) 2015 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 
29 class IRelaxNGGrammar;
30 
32 {
33 public:
36 
37  bool LoadGrammar(const std::string& grammar);
38 
39  bool LoadGrammarFile(const PIVFS& vfs, const VfsPath& grammarPath);
40 
41  MD5 GetGrammarHash() const { return m_Hash; }
42 
43  bool Validate(const std::wstring& filename, const std::wstring& document) const;
44 
45  bool ValidateEncoded(const std::wstring& filename, const std::string& document) const;
46 
47  bool ValidateEncoded(xmlDocPtr doc) const;
48 
49  bool CanValidate() const;
50 
51 private:
54 };
55 
56 /**
57  * There should be no references to validators or schemas outside of the cache anymore when calling this.
58  */
59 void ClearSchemaCache();
60 
61 #endif // INCLUDED_RELAXNG
bool LoadGrammarFile(const PIVFS &vfs, const VfsPath &grammarPath)
Definition: RelaxNG.cpp:119
~RelaxNGValidator()
Definition: RelaxNG.cpp:86
shared_ptr< IVFS > PIVFS
Definition: vfs.h:226
MD5 m_Hash
Definition: RelaxNG.h:52
xmlRelaxNGPtr m_Schema
Definition: RelaxNG.h:53
MD5 hashing algorithm.
Definition: MD5.h:27
Definition: path.h:77
bool ValidateEncoded(const std::wstring &filename, const std::string &document) const
Definition: RelaxNG.cpp:135
struct _xmlDoc xmlDoc
Definition: RelaxNG.h:26
bool Validate(const std::wstring &filename, const std::wstring &document) const
Definition: RelaxNG.cpp:128
xmlRelaxNG * xmlRelaxNGPtr
Definition: RelaxNG.h:25
RelaxNGValidator()
Definition: RelaxNG.cpp:81
struct _xmlRelaxNG xmlRelaxNG
Definition: RelaxNG.h:24
Definition: RelaxNG.h:31
MD5 GetGrammarHash() const
Definition: RelaxNG.h:41
bool LoadGrammar(const std::string &grammar)
Definition: RelaxNG.cpp:90
Definition: vfs_util.cpp:39
void ClearSchemaCache()
There should be no references to validators or schemas outside of the cache anymore when calling this...
Definition: RelaxNG.cpp:41
bool CanValidate() const
Definition: RelaxNG.cpp:180
xmlDoc * xmlDocPtr
Definition: RelaxNG.h:27