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_METADATAREADER_H 17 #define OHOS_IDL_METADATAREADER_H 18 19 #include <memory> 20 #include <cstdlib> 21 #include <unordered_map> 22 #include "util/autoptr.h" 23 #include "ast/ast.h" 24 #include "metadata/meta_component.h" 25 26 namespace OHOS { 27 namespace Idl { 28 class MetadataReader { 29 public: MetadataReader(MetaComponent * mc)30 explicit MetadataReader(MetaComponent* mc) 31 : metaComponent_(mc) 32 {} 33 34 ~MetadataReader() = default; 35 static std::shared_ptr<MetaComponent> ReadMetadataFromFile(const std::string& filePath); 36 std::unordered_map<std::string, AutoPtr<AST>> ReadMetadataToAst(); 37 38 private: 39 AutoPtr<ASTType> ReadMetaType(MetaType* type); 40 void ReadMetaSequenceable(MetaSequenceable* mp); 41 void ReadMetaInterface(MetaInterface* mi); 42 void ReadMetaMethod(AutoPtr<ASTInterfaceType>& interface, MetaMethod* mm); 43 void ReadMetaParam(AutoPtr<ASTMethod>& interface, MetaParameter* mp); 44 std::string MetaTypeName(MetaType* mt); 45 static std::string tag_; 46 MetaComponent* metaComponent_; 47 AutoPtr<AST> ast_; 48 }; 49 } // namespace Idl 50 } // namespace OHOS 51 #endif // OHOS_IDL_METADATAREADER_H 52