1ca0551cfSopenharmony_ci/*
2ca0551cfSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3ca0551cfSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4ca0551cfSopenharmony_ci * you may not use this file except in compliance with the License.
5ca0551cfSopenharmony_ci * You may obtain a copy of the License at
6ca0551cfSopenharmony_ci *
7ca0551cfSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8ca0551cfSopenharmony_ci *
9ca0551cfSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10ca0551cfSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11ca0551cfSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12ca0551cfSopenharmony_ci * See the License for the specific language governing permissions and
13ca0551cfSopenharmony_ci * limitations under the License.
14ca0551cfSopenharmony_ci */
15ca0551cfSopenharmony_ci
16ca0551cfSopenharmony_ci#ifndef OHOS_IDL_METADATAREADER_H
17ca0551cfSopenharmony_ci#define OHOS_IDL_METADATAREADER_H
18ca0551cfSopenharmony_ci
19ca0551cfSopenharmony_ci#include <memory>
20ca0551cfSopenharmony_ci#include <cstdlib>
21ca0551cfSopenharmony_ci#include <unordered_map>
22ca0551cfSopenharmony_ci#include "util/autoptr.h"
23ca0551cfSopenharmony_ci#include "ast/ast.h"
24ca0551cfSopenharmony_ci#include "metadata/meta_component.h"
25ca0551cfSopenharmony_ci
26ca0551cfSopenharmony_cinamespace OHOS {
27ca0551cfSopenharmony_cinamespace Idl {
28ca0551cfSopenharmony_ciclass MetadataReader {
29ca0551cfSopenharmony_cipublic:
30ca0551cfSopenharmony_ci    explicit MetadataReader(MetaComponent* mc)
31ca0551cfSopenharmony_ci        : metaComponent_(mc)
32ca0551cfSopenharmony_ci    {}
33ca0551cfSopenharmony_ci
34ca0551cfSopenharmony_ci    ~MetadataReader() = default;
35ca0551cfSopenharmony_ci    static std::shared_ptr<MetaComponent> ReadMetadataFromFile(const std::string& filePath);
36ca0551cfSopenharmony_ci    std::unordered_map<std::string, AutoPtr<AST>> ReadMetadataToAst();
37ca0551cfSopenharmony_ci
38ca0551cfSopenharmony_ciprivate:
39ca0551cfSopenharmony_ci    AutoPtr<ASTType> ReadMetaType(MetaType* type);
40ca0551cfSopenharmony_ci    void ReadMetaSequenceable(MetaSequenceable* mp);
41ca0551cfSopenharmony_ci    void ReadMetaInterface(MetaInterface* mi);
42ca0551cfSopenharmony_ci    void ReadMetaMethod(AutoPtr<ASTInterfaceType>& interface, MetaMethod* mm);
43ca0551cfSopenharmony_ci    void ReadMetaParam(AutoPtr<ASTMethod>& interface, MetaParameter* mp);
44ca0551cfSopenharmony_ci    std::string MetaTypeName(MetaType* mt);
45ca0551cfSopenharmony_ci    static std::string tag_;
46ca0551cfSopenharmony_ci    MetaComponent* metaComponent_;
47ca0551cfSopenharmony_ci    AutoPtr<AST> ast_;
48ca0551cfSopenharmony_ci};
49ca0551cfSopenharmony_ci} // namespace Idl
50ca0551cfSopenharmony_ci} // namespace OHOS
51ca0551cfSopenharmony_ci#endif // OHOS_IDL_METADATAREADER_H
52