1 /*
2  * Copyright (c) 2021 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 FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_ROUTER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_ROUTER_H
18 
19 #include <list>
20 #include <memory>
21 #include <string>
22 
23 #include "base/json/json_util.h"
24 #include "base/memory/referenced.h"
25 #include "base/utils/noncopyable.h"
26 
27 namespace OHOS::Ace {
28 class JsonValue;
29 }
30 
31 namespace OHOS::Ace::Framework {
32 
33 class ManifestRouter : public Referenced {
34 public:
35     ManifestRouter() = default;
36     ~ManifestRouter() override = default;
37 
38     std::string GetPagePath(std::string& uri) const;
39     std::string GetPagePath(const std::string& uri, const std::string& suffix = ".js") const;
40     std::string GetEntry(const std::string& suffix = ".js") const;
41     const std::list<std::string>& GetPageList();
42     void RouterParse(const std::unique_ptr<JsonValue>& router);
43     void InsertPageList(const std::string& uri);
44 
45 private:
46     std::string pagePath_;
47     std::list<std::string> pages_;
48 
49     ACE_DISALLOW_COPY_AND_MOVE(ManifestRouter);
50 };
51 
52 } // namespace OHOS::Ace::Framework
53 
54 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_MANIFEST_MANIFEST_ROUTER_H
55