summaryrefslogtreecommitdiff
path: root/cpp/src/slice2docbook/Gen.h
blob: 88db0e266ba8240b822bfe558881a879bbc3c379 (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
// **********************************************************************
//
// Copyright (c) 2001
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#ifndef GEN_H
#define GEN_H

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

namespace Slice
{

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

    Gen(const std::string&, const std::string&, bool, bool);
    virtual ~Gen();

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

    void generate(const UnitPtr&);

    virtual void visitUnitStart(const UnitPtr&);
    virtual void visitUnitEnd(const UnitPtr&);
    virtual void visitModuleStart(const ModulePtr&);
    virtual void visitContainer(const ContainerPtr&);
    virtual void visitClassDefStart(const ClassDefPtr&);
    virtual void visitStructStart(const StructPtr&);

private:

    void printHeader();
    StringList getTagged(const std::string&, std::string&);
    void printComment(const ContainedPtr&);
    void printSummary(const ContainedPtr&);
    void start(const std::string&);
    void start(const std::string&, const std::string&);
    void end();

    std::string scopedToId(const std::string&);
    std::string getScopedMinimized(const ContainedPtr&, const ContainerPtr&);
    std::string toString(const SyntaxTreeBasePtr&, const ContainerPtr&);
    std::string toString(const std::string&, const ContainerPtr&);

    Output O;

    bool _standAlone;
    bool _noGlobals;
    std::string _chapter;
    std::stack<std::string> _elementStack;
    std::string _idPrefix;
    std::map<std::string, int> _idMap;
    int _nextId;
};

}

#endif