summaryrefslogtreecommitdiff
path: root/cpp/src/slice2xsd/Gen.h
blob: 12ef3d09e1ce98ba81c26c133f9f509eff4f0440 (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
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef GEN_H
#define GEN_H

#include <Slice/Parser.h>
#include <IceUtil/OutputUtil.h>
#include <stack>

namespace Slice
{

class Gen : public ::IceUtil::noncopyable, public ParserVisitor
{
public:

    Gen(const std::string&,
	const std::string&,
	const std::string&,
	const std::vector<std::string>&,
	const std::string&);
    virtual ~Gen();

    bool operator!() const; // Returns true if there was a constructor error

    void generate(const UnitPtr&);

    virtual bool visitClassDefStart(const ClassDefPtr&);
    virtual bool visitExceptionStart(const ExceptionPtr&);
    virtual bool visitStructStart(const StructPtr&);
    virtual void visitOperation(const OperationPtr&);
    virtual void visitEnum(const EnumPtr&);
    virtual void visitConstDef(const ConstDefPtr&);
    virtual void visitSequence(const SequencePtr&);
    virtual void visitDictionary(const DictionaryPtr&);

private:

    void printHeader();
    void annotate(const ::std::string&);
    void emitElement(const ::std::string&, const TypePtr&);

    std::string containedToId(const ContainedPtr&);
    std::string toString(const SyntaxTreeBasePtr&);

    ::IceUtil::XMLOutput O;

    std::string _base;
    std::string _include;
    std::string _orgName;
    std::vector<std::string> _includePaths;
};

}

#endif