1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __CONFIG_DESCRIPTION_H
18 #define __CONFIG_DESCRIPTION_H
19 
20 #include <androidfw/ResourceTypes.h>
21 
22 /**
23  * Subclass of ResTable_config that adds convenient
24  * initialization and comparison methods.
25  */
26 struct ConfigDescription : public android::ResTable_config {
ConfigDescriptionConfigDescription27     ConfigDescription() {
28         memset(this, 0, sizeof(*this));
29         size = sizeof(android::ResTable_config);
30     }
31 
ConfigDescriptionConfigDescription32     ConfigDescription(const android::ResTable_config&o) {
33         *static_cast<android::ResTable_config*>(this) = o;
34         size = sizeof(android::ResTable_config);
35     }
36 
ConfigDescriptionConfigDescription37     ConfigDescription(const ConfigDescription&o) {
38         *static_cast<android::ResTable_config*>(this) = o;
39     }
40 
41     ConfigDescription& operator=(const android::ResTable_config& o) {
42         *static_cast<android::ResTable_config*>(this) = o;
43         size = sizeof(android::ResTable_config);
44         return *this;
45     }
46 
47     ConfigDescription& operator=(const ConfigDescription& o) {
48         *static_cast<android::ResTable_config*>(this) = o;
49         return *this;
50     }
51 
52     inline bool operator<(const ConfigDescription& o) const { return compare(o) < 0; }
53     inline bool operator<=(const ConfigDescription& o) const { return compare(o) <= 0; }
54     inline bool operator==(const ConfigDescription& o) const { return compare(o) == 0; }
55     inline bool operator!=(const ConfigDescription& o) const { return compare(o) != 0; }
56     inline bool operator>=(const ConfigDescription& o) const { return compare(o) >= 0; }
57     inline bool operator>(const ConfigDescription& o) const { return compare(o) > 0; }
58 };
59 
60 #endif // __CONFIG_DESCRIPTION_H
61