blob: b13c9ee021a6236e1e78ce0363083a4bd060cb95 [file] [log] [blame]
Adam Lesinski40e8eef2014-09-16 14:43:29 -07001/*
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 H_ANDROID_SPLIT_SPLIT_DESCRIPTION
18#define H_ANDROID_SPLIT_SPLIT_DESCRIPTION
19
20#include "aapt/ConfigDescription.h"
21#include "Abi.h"
22
23#include <utils/String8.h>
24#include <utils/Vector.h>
25
26namespace split {
27
28struct SplitDescription {
29 SplitDescription();
Adam Lesinski40e8eef2014-09-16 14:43:29 -070030
31 ConfigDescription config;
32 abi::Variant abi;
33
34 int compare(const SplitDescription& rhs) const;
35 inline bool operator<(const SplitDescription& rhs) const;
36 inline bool operator==(const SplitDescription& rhs) const;
37 inline bool operator!=(const SplitDescription& rhs) const;
38
39 bool match(const SplitDescription& o) const;
40 bool isBetterThan(const SplitDescription& o, const SplitDescription& target) const;
41
42 android::String8 toString() const;
43
44 static bool parse(const android::String8& str, SplitDescription* outSplit);
45};
46
47ssize_t parseAbi(const android::Vector<android::String8>& parts, const ssize_t index,
48 SplitDescription* outSplit);
49
50bool SplitDescription::operator<(const SplitDescription& rhs) const {
51 return compare(rhs) < 0;
52}
53
54bool SplitDescription::operator==(const SplitDescription& rhs) const {
55 return compare(rhs) == 0;
56}
57
58bool SplitDescription::operator!=(const SplitDescription& rhs) const {
59 return compare(rhs) != 0;
60}
61
62} // namespace split
63
64#endif // H_ANDROID_SPLIT_SPLIT_DESCRIPTION