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 PREFERENCES_UTILS_H
17 #define PREFERENCES_UTILS_H
18 
19 #include <string>
20 
21 #include "preferences_value.h"
22 
23 namespace OHOS {
24 namespace NativePreferences {
25 /**
26 * @brief The constant Indicates the maximum length of the key in the preferences.
27 */
28 static constexpr uint32_t MAX_KEY_LENGTH = 1024;
29 /**
30  * @brief The constant Indicates the maximum length of the value in the preferences.
31  */
32 static constexpr uint32_t MAX_VALUE_LENGTH = 16 * 1024 * 1024;
33 
34 static const char *STR_BROKEN = ".broken";
35 static const char *STR_BACKUP = ".bak";
36 static const char *STR_LOCK = ".lock";
37 static const char *STR_QUERY = "?";
38 static const char *STR_SLASH = "/";
39 static const char *STR_SCHEME = "sharepreferences://";
40 
41 std::string MakeFilePath(const std::string &prefPath, const std::string &suffix);
42 
43 int CheckKey(const std::string &key);
44 
45 int CheckValue(const PreferencesValue &value);
46 } // End of namespace NativePreferences
47 } // End of namespace OHOS
48 #endif // End of #ifndef PREFERENCES_H
49