summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/Transform.h
blob: 50ea555715fc6e5bd72255154c3431ff241d8b24 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef TRANSFORM_H
#define TRANSFORM_H

#include <string>
#include <iosfwd>
#include <map>
#include <vector>

#include <dom/DOM.hpp>

class IllegalTransform
{
public:

    IllegalTransform(const char* file, int line) : _file(file), _line(line) { }
    ~IllegalTransform() { }

    const char* file() const { return _file; }
    int line() const { return _line; }

private:

    const char* _file;
    int _line;
};

::std::ostream& operator<<(::std::ostream&, const IllegalTransform&);

class IncompatibleSchema
{
public:

    IncompatibleSchema(const char* file, int line) : _file(file), _line(line) { }
    ~IncompatibleSchema() { }

    const char* file() const { return _file; }
    int line() const { return _line; }

private:

    const char* _file;
    int _line;
};

::std::ostream& operator<<(::std::ostream&, const IncompatibleSchema&);

class InvalidSchema
{
public:

    InvalidSchema(const char* file, int line) : _file(file), _line(line) { }
    ~InvalidSchema() { }

    const char* file() const { return _file; }
    int line() const { return _line; }

private:

    const char* _file;
    int _line;
};

::std::ostream& operator<<(::std::ostream&, const InvalidSchema&);

class SchemaViolation
{
public:

    SchemaViolation(const char* file, int line) : _file(file), _line(line) { }
    ~SchemaViolation() { }

    const char* file() const { return _file; }
    int line() const { return _line; }

private:

    const char* _file;
    int _line;
};

::std::ostream& operator<<(::std::ostream&, const SchemaViolation&);

struct DocumentInfo;

class Transform
{
public:

    Transform() { }
    virtual ~Transform() { }

    virtual void transform(::std::ostream&, const DocumentInfo*, const ::std::string&, DOM_Node) = 0;
    virtual ::std::ostream& print(::std::ostream&) = 0;
};

typedef ::std::map< ::std::string, Transform*> TransformMap;

class Transformer
{
public:

    Transformer(DOM_Document&, DOM_Document&);
    ~Transformer();

    void transform(::std::ostream&, DOM_Document&);

private:

    //
    // Map of local@uri element names to transforms. Needed for actual
    // transform.
    //
    TransformMap _elements;

    //
    // Map of local@uri class transforms (based on static type). This
    // information cached for creation of the transform.
    //
    TransformMap _staticClassTransforms;
};

#endif