LCOV - code coverage report
Current view: top level - source/ps/XML - RelaxNG.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 1 100.0 %
Date: 2023-01-19 00:18:29 Functions: 1 1 100.0 %

          Line data    Source code
       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;
      25             : typedef xmlRelaxNG *xmlRelaxNGPtr;
      26             : typedef struct _xmlDoc xmlDoc;
      27             : typedef xmlDoc *xmlDocPtr;
      28             : 
      29             : class RelaxNGValidator
      30             : {
      31             : public:
      32             :     RelaxNGValidator();
      33             :     ~RelaxNGValidator();
      34             : 
      35             :     bool LoadGrammar(const std::string& grammar);
      36             : 
      37             :     bool LoadGrammarFile(const PIVFS& vfs, const VfsPath& grammarPath);
      38             : 
      39         430 :     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:
      50             :     MD5 m_Hash;
      51             :     xmlRelaxNGPtr m_Schema;
      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

Generated by: LCOV version 1.13