1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_IDL_METADATADUMPER_H
17#define OHOS_IDL_METADATADUMPER_H
18
19#include "metadata/meta_component.h"
20#include "metadata/meta_interface.h"
21#include "metadata/meta_method.h"
22#include "metadata/meta_namespace.h"
23#include "metadata/meta_patameter.h"
24#include "metadata/meta_sequenceable.h"
25#include "metadata/meta_type.h"
26#include "util/string_builder.h"
27
28namespace OHOS {
29namespace Idl {
30class MetadataDumper {
31public:
32    explicit MetadataDumper(MetaComponent* mc)
33        : metaComponent_(mc)
34    {}
35
36    ~MetadataDumper() = default;
37
38    std::string Dump(const std::string& prefix);
39
40private:
41    std::string DumpMetaComponent(MetaComponent* mc, const std::string& prefix);
42
43    void DumpMetaNamespaces(StringBuilder& sb, MetaComponent* mc, const std::string& prefix);
44
45    void DumpMetaNamespace(StringBuilder& sb, MetaNamespace* mn, const std::string& prefix);
46
47    void DumpMetaSequenceables(StringBuilder& sb, MetaComponent* mc, const std::string& prefix);
48
49    void DumpMetaSequenceable(StringBuilder& sb, MetaSequenceable* mp, const std::string& prefix);
50
51    void DumpMetaInterfaces(StringBuilder& sb, MetaComponent* mc, const std::string& prefix);
52
53    void DumpMetaInterface(StringBuilder& sb, MetaInterface* mi, const std::string& prefix);
54
55    void DumpMetaMethod(StringBuilder& sb, MetaMethod* mm, const std::string& prefix);
56
57    void DumpMetaParameter(StringBuilder& sb, MetaParameter* mp, const std::string& prefix);
58
59    std::string DumpMetaType(MetaType* mt);
60
61    static std::string tab_;
62    MetaComponent* metaComponent_;
63};
64} // namespace Idl
65} // namespace OHOS
66#endif // OHOS_IDL_METADATADUMPER_H
67