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_rawdata.h" 25 #include "metadata/meta_sequenceable.h" 26 #include "metadata/meta_type.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 std::string Dump(const std::string& prefix); 40 41 private: 42 std::string DumpMetaComponent(MetaComponent* mc, const std::string& prefix); 43 44 void DumpMetaNamespaces(StringBuilder& sb, MetaComponent* mc, const std::string& prefix); 45 46 void DumpMetaNamespace(StringBuilder& sb, MetaNamespace* mn, const std::string& prefix); 47 48 void GetDumpMetaNamespace(StringBuilder& sb, MetaNamespace* mn, const std::string& prefix); 49 50 void DumpMetaSequenceables(StringBuilder& sb, MetaComponent* mc, const std::string& prefix); 51 52 void DumpMetaSequenceable(StringBuilder& sb, MetaSequenceable* mp, const std::string& prefix); 53 54 void DumpMetaRawDatas(StringBuilder& sb, MetaComponent* mc, const std::string& prefix); 55 56 void DumpMetaRawData(StringBuilder& sb, MetaRawData* mp, const std::string& prefix); 57 58 void DumpMetaInterfaces(StringBuilder& sb, MetaComponent* mc, const std::string& prefix); 59 60 void DumpMetaInterface(StringBuilder& sb, MetaInterface* mi, const std::string& prefix); 61 62 void DumpMetaMethod(StringBuilder& sb, MetaMethod* mm, const std::string& prefix); 63 64 void DumpMetaParameter(StringBuilder& sb, MetaParameter* mp, const std::string& prefix); 65 66 std::string DumpMetaType(MetaType* mt); 67 68 std::string GetDumpMetaType(MetaType* mt); 69 70 static std::string tab_; 71 MetaComponent* metaComponent_; 72 }; 73 } // namespace Idl 74 } // namespace OHOS 75 #endif // OHOS_IDL_METADATADUMPER_H 76