• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #ifndef OHOS_RESOURCE_MANAGER_RESCONFIG_IMPL_H
16 #define OHOS_RESOURCE_MANAGER_RESCONFIG_IMPL_H
17 
18 #include <stdint.h>
19 #include <unicode/locid.h>
20 #include "res_locale.h"
21 #include "res_common.h"
22 #include "res_config.h"
23 
24 using icu::Locale;
25 namespace OHOS {
26 namespace Global {
27 namespace Resource {
28 class ResConfigImpl : public ResConfig {
29 public:
30     ResConfigImpl();
31 
32     bool IsMoreSuitable(const ResConfigImpl *other, const ResConfigImpl *request) const;
33 
34     RState SetLocaleInfo(const char *language, const char *script, const char *region);
35 
36     RState SetLocaleInfo(Locale &localeInfo);
37 
38     void SetDeviceType(DeviceType deviceType);
39 
40     void SetDirection(Direction direction);
41 
42     void SetColorMode(ColorMode colorMode);
43 
44     void SetScreenDensity(ScreenDensity screenDensity);
45 
46     const Locale *GetLocaleInfo() const;
47 
48     const ResLocale *GetResLocale() const;
49 
50     Direction GetDirection() const;
51 
52     ScreenDensity GetScreenDensity() const;
53 
54     ColorMode GetColorMode() const;
55 
56     DeviceType GetDeviceType() const;
57 
58     bool Match(const ResConfigImpl *other) const;
59 
60     bool Copy(ResConfig &other);
61 
62     void CompleteScript();
63 
64     bool IsCompletedScript() const;
65 
66     virtual ~ResConfigImpl();
67 
68 private:
69     bool IsMoreSpecificThan(const ResConfigImpl *other) const;
70 
71     bool CopyLocale(ResConfig &other);
72 
73 private:
74     ResLocale *resLocale_;
75     Direction direction_;
76     ScreenDensity screenDensity_;
77     ColorMode colorMode_;
78     DeviceType deviceType_;
79     bool isCompletedScript_;
80     Locale *localeInfo_;
81 };
82 } // namespace Resource
83 } // namespace Global
84 } // namespace OHOS
85 #endif