1 /*
2  * Copyright (c) 2022 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.h"
27 #include "util/string_builder.h"
28 
29 namespace OHOS {
30 namespace Idl {
31 class MetadataDumper {
32 public:
MetadataDumper(MetaComponent * mc)33     explicit MetadataDumper(MetaComponent* mc)
34         : metaComponent_(mc)
35     {}
36 
37     ~MetadataDumper() = default;
38 
39     void Dump(const String& prefix);
40 
41 private:
42     String DumpMetaComponent(MetaComponent* mc, const String& prefix);
43 
44     void DumpMetaNamespace(StringBuilder& sb, MetaNamespace* mn, const String& prefix);
45 
46     void DumpMetaSequenceable(StringBuilder& sb, MetaSequenceable* mp, const String& prefix);
47 
48     void DumpMetaInterface(StringBuilder& sb, MetaInterface* mi, const String& prefix);
49 
50     void DumpMetaMethod(StringBuilder& sb, MetaMethod* mm, const String& prefix);
51 
52     void DumpMetaParameter(StringBuilder& sb, MetaParameter* mp, const String& prefix);
53 
54     String DumpMetaType(MetaType* mt);
55 
56     static const char* tab;
57     MetaComponent* metaComponent_;
58 };
59 } // namespace Idl
60 } // namespace OHOS
61 #endif // OHOS_IDL_METADATADUMPER_H
62