• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
17 #define FOUNDATION_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
18 
19 #include <string>
20 #include "form_provider_data.h"
21 #include "parcel.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 /**
26  * @struct FormProviderInfo
27  * Defines form provider info.
28  */
29 class FormProviderInfo : public Parcelable {
30 public:
31     FormProviderInfo() = default;
32     ~FormProviderInfo() = default;
33 
34     /**
35      * @brief Set the form data.
36      * @param formProviderData The form data.
37      */
SetFormData(const FormProviderData & formProviderData)38     inline void SetFormData(const FormProviderData &formProviderData)
39     {
40         jsBindingData_ = formProviderData;
41     }
42 
43     /**
44      * @brief Get the form data.
45      * @return the form data.
46      */
GetFormData()47     inline FormProviderData GetFormData() const
48     {
49         return jsBindingData_;
50     }
51     /**
52      * @brief Get the form data.
53      * @return the form data.
54      */
GetFormDataString()55     inline std::string GetFormDataString() const
56     {
57         return jsBindingData_.GetDataString();
58     }
59 
60     /**
61      * @brief Set the upgrade flg.
62      * @param upgradeFlg The upgrade flg.
63      */
SetUpgradeFlg(const bool upgradeFlg)64     inline void SetUpgradeFlg(const bool upgradeFlg)
65     {
66         upgradeFlg_ = upgradeFlg;
67     }
68     /**
69      * @brief Get the upgrade flg.
70      * @return the upgrade flg.
71      */
GetUpgradeFlg()72     inline bool GetUpgradeFlg() const
73     {
74         return upgradeFlg_;
75     }
76 
77     /**
78      * @brief Set form date by string.
79      * @param dataString string json data.
80      */
81     void SetFormDataString(std::string &dataString);
82 
83     /**
84      * @brief Merge new data to FormProviderData.
85      * @param addJsonData data to merge to FormProviderData
86      */
87     void MergeData(nlohmann::json &addJsonData);
88 
89     bool ReadFromParcel(Parcel &parcel);
90     virtual bool Marshalling(Parcel &parcel) const override;
91     static FormProviderInfo *Unmarshalling(Parcel &parcel);
92 private:
93     FormProviderData jsBindingData_;
94     bool upgradeFlg_;
95 };
96 }  // namespace AppExecFwk
97 }  // namespace OHOS
98 #endif  // FOUNDATION_APPEXECFWK_OHOS_FORM_PROVIDER_INFO_H
99