]>
git.saurik.com Git - android/aapt.git/blob - ResourceFilter.cpp
2 // Copyright 2011 The Android Open Source Project
4 // Build resource files from raw assets.
7 #include "ResourceFilter.h"
10 ResourceFilter::parse(const char* arg
)
27 if (part
== "zz_ZZ") {
28 mContainsPseudo
= true;
32 if (AaptGroupEntry::parseNamePart(part
, &axis
, &value
)) {
33 fprintf(stderr
, "Invalid configuration: %s\n", arg
);
35 for (int i
=0; i
<p
-arg
; i
++) {
38 for (int i
=0; i
<q
-p
; i
++) {
41 fprintf(stderr
, "\n");
45 ssize_t index
= mData
.indexOfKey(axis
);
47 mData
.add(axis
, SortedVector
<uint32_t>());
49 SortedVector
<uint32_t>& sv
= mData
.editValueFor(axis
);
51 // if it's a locale with a region, also match an unmodified locale of the
53 if (axis
== AXIS_LANGUAGE
) {
54 if (value
& 0xffff0000) {
55 sv
.add(value
& 0x0000ffff);
67 ResourceFilter::isEmpty() const
69 return mData
.size() == 0;
73 ResourceFilter::match(int axis
, uint32_t value
) const
76 // they didn't specify anything so take everything
79 ssize_t index
= mData
.indexOfKey(axis
);
81 // we didn't request anything on this axis so take everything
84 const SortedVector
<uint32_t>& sv
= mData
.valueAt(index
);
85 return sv
.indexOf(value
) >= 0;
89 ResourceFilter::match(int axis
, const ResTable_config
& config
) const
91 return match(axis
, AaptGroupEntry::getConfigValueForAxis(config
, axis
));
95 ResourceFilter::match(const ResTable_config
& config
) const
97 for (int i
=AXIS_START
; i
<=AXIS_END
; i
++) {
98 if (!match(i
, AaptGroupEntry::getConfigValueForAxis(config
, i
))) {
105 const SortedVector
<uint32_t>* ResourceFilter::configsForAxis(int axis
) const
107 ssize_t index
= mData
.indexOfKey(axis
);
111 return &mData
.valueAt(index
);