diff options
Diffstat (limited to 'tools/aapt/AaptUtil.h')
-rw-r--r-- | tools/aapt/AaptUtil.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/aapt/AaptUtil.h b/tools/aapt/AaptUtil.h index 47a704a..89e1ee8 100644 --- a/tools/aapt/AaptUtil.h +++ b/tools/aapt/AaptUtil.h @@ -14,9 +14,11 @@ * limitations under the License. */ -#ifndef __AAPT_UTIL_H -#define __AAPT_UTIL_H +#ifndef H_AAPT_UTIL +#define H_AAPT_UTIL +#include <utils/KeyedVector.h> +#include <utils/SortedVector.h> #include <utils/String8.h> #include <utils/Vector.h> @@ -25,6 +27,38 @@ namespace AaptUtil { android::Vector<android::String8> split(const android::String8& str, const char sep); android::Vector<android::String8> splitAndLowerCase(const android::String8& str, const char sep); +template <typename KEY, typename VALUE> +void appendValue(android::KeyedVector<KEY, android::Vector<VALUE> >& keyedVector, + const KEY& key, const VALUE& value); + +template <typename KEY, typename VALUE> +void appendValue(android::KeyedVector<KEY, android::SortedVector<VALUE> >& keyedVector, + const KEY& key, const VALUE& value); + +// +// Implementations +// + +template <typename KEY, typename VALUE> +void appendValue(android::KeyedVector<KEY, android::Vector<VALUE> >& keyedVector, + const KEY& key, const VALUE& value) { + ssize_t idx = keyedVector.indexOfKey(key); + if (idx < 0) { + idx = keyedVector.add(key, android::Vector<VALUE>()); + } + keyedVector.editValueAt(idx).add(value); +} + +template <typename KEY, typename VALUE> +void appendValue(android::KeyedVector<KEY, android::SortedVector<VALUE> >& keyedVector, + const KEY& key, const VALUE& value) { + ssize_t idx = keyedVector.indexOfKey(key); + if (idx < 0) { + idx = keyedVector.add(key, android::SortedVector<VALUE>()); + } + keyedVector.editValueAt(idx).add(value); +} + } // namespace AaptUtil -#endif // __AAPT_UTIL_H +#endif // H_AAPT_UTIL |