File: Schema.h

package info (click to toggle)
mediaconch 25.04-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,828 kB
  • sloc: ansic: 126,293; cpp: 39,636; javascript: 34,300; xml: 2,950; sh: 2,121; makefile: 200; python: 183
file content (73 lines) | stat: -rw-r--r-- 2,397 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license that can
 *  be found in the License.html file in the root of the source tree.
 */

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Schema functions
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//---------------------------------------------------------------------------
#ifndef SchemaH
#define SchemaH
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include <map>
#include <libxml/xmlerror.h>

namespace MediaConch {

//***************************************************************************
// Class Schema
//***************************************************************************

class Schema
{
public:
    //Constructor/Destructor
    Schema(bool no_https);
    virtual ~Schema();

    bool         register_schema_from_file(const char* filename);
    virtual bool register_schema_from_memory(const std::string& schem);
    virtual bool register_schema_from_doc(void* doc);

    virtual int  validate_xml(const std::string& xml, bool silent=true);
    virtual int  validate_xml_from_file(const char* file, bool silent=true);

    std::string  get_schema() const { return schema; }
    std::string  get_report() const { return report; }
    std::vector<std::string> get_errors() const { return errors; }

    void set_options(const std::map<std::string, std::string>& opt) { options = opt; }
    const std::map<std::string, std::string>& get_options() const { return options; }

    // Callbacks
    static void  manage_generic_error(void *userData, const char* msg, ...);
    static void  manage_error(void *userData, xmlErrorPtr err);

protected:
    std::string                        schema;
    std::string                        report;
    std::vector<std::string>           errors;
    std::map<std::string, std::string> options;
    bool                               no_https;

    // HELPER
    int          read_file(const char* filename, std::string& buffer);

private:
    Schema(const Schema&);
    Schema&     operator=(const Schema&);

};

}

#endif