From 030f536009b56dbcc23d284541e51562bd9a6ed3 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 4 Mar 2015 13:54:20 -0800 Subject: Stop using namespace std. The pattern of #include and using namespace std here fails to build with GCC. At first glance it's a GCC bug rather than libc++ doing something wrong. Regardless, it can be worked around by just specifying std:: where appropriate. Bug: 19606303 Change-Id: I5652682eae7ca7559cf2a9307909859013440781 --- tools/aapt/Images.cpp | 5 +++-- tools/aapt/ResourceTable.cpp | 28 +++++++++++----------------- tools/aapt/ResourceTable.h | 12 +++++------- 3 files changed, 19 insertions(+), 26 deletions(-) (limited to 'tools/aapt') diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index 5ab177b..063b4e6 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -481,8 +481,9 @@ static void get_outline(image_info* image) // assuming the image is a round rect, compute the radius by marching // diagonally from the top left corner towards the center - image->outlineAlpha = max(max_alpha_over_row(image->rows[innerMidY], innerStartX, innerEndX), - max_alpha_over_col(image->rows, innerMidX, innerStartY, innerStartY)); + image->outlineAlpha = std::max( + max_alpha_over_row(image->rows[innerMidY], innerStartX, innerEndX), + max_alpha_over_col(image->rows, innerMidX, innerStartY, innerStartY)); int diagonalInset = 0; find_max_opacity(image->rows, innerStartX, innerStartY, innerMidX, innerMidY, 1, 1, diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 0ec1aeb..9861be2 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -1802,7 +1802,7 @@ status_t ResourceTable::addIncludedResources(Bundle* bundle, const sp >::iterator nameIter = mLocalizations.begin(); - nameIter != mLocalizations.end(); - nameIter++) { - const map& configSrcMap = nameIter->second; + for (const auto& nameIter : mLocalizations) { + const std::map& configSrcMap = nameIter.second; // Look for strings with no default localization if (configSrcMap.count(defaultLocale) == 0) { SourcePos().warning("string '%s' has no default translation.", - String8(nameIter->first).string()); + String8(nameIter.first).string()); if (mBundle->getVerbose()) { - for (map::const_iterator locales = configSrcMap.begin(); - locales != configSrcMap.end(); - locales++) { - locales->second.printf("locale %s found", locales->first.string()); + for (const auto& locale : configSrcMap) { + locale.second.printf("locale %s found", locale.first.string()); } } // !!! TODO: throw an error here in some circumstances @@ -2691,8 +2687,8 @@ ResourceTable::validateLocalizations(void) const char* allConfigs = mBundle->getConfigurations().string(); const char* start = allConfigs; const char* comma; - - set missingConfigs; + + std::set missingConfigs; AaptLocaleValue locale; do { String8 config; @@ -2726,13 +2722,11 @@ ResourceTable::validateLocalizations(void) if (!missingConfigs.empty()) { String8 configStr; - for (set::iterator iter = missingConfigs.begin(); - iter != missingConfigs.end(); - iter++) { - configStr.appendFormat(" %s", iter->string()); + for (const auto& iter : missingConfigs) { + configStr.appendFormat(" %s", iter.string()); } SourcePos().warning("string '%s' is missing %u required localizations:%s", - String8(nameIter->first).string(), + String8(nameIter.first).string(), (unsigned int)missingConfigs.size(), configStr.string()); } diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h index eac5dd3..a939dd3 100644 --- a/tools/aapt/ResourceTable.h +++ b/tools/aapt/ResourceTable.h @@ -16,8 +16,6 @@ #include #include -using namespace std; - class XMLNode; class ResourceTable; @@ -28,7 +26,7 @@ enum { XML_COMPILE_STRIP_WHITESPACE = 1<<3, XML_COMPILE_STRIP_RAW_VALUES = 1<<4, XML_COMPILE_UTF8 = 1<<5, - + XML_COMPILE_STANDARD_RESOURCE = XML_COMPILE_STRIP_COMMENTS | XML_COMPILE_ASSIGN_ATTRIBUTE_IDS | XML_COMPILE_STRIP_WHITESPACE | XML_COMPILE_STRIP_RAW_VALUES @@ -115,7 +113,7 @@ public: * and would mess up iteration order for the existing * resources. */ - queue& getWorkQueue() { + std::queue& getWorkQueue() { return mWorkQueue; } @@ -577,10 +575,10 @@ private: size_t mNumLocal; SourcePos mCurrentXmlPos; Bundle* mBundle; - + // key = string resource name, value = set of locales in which that name is defined - map > mLocalizations; - queue mWorkQueue; + std::map> mLocalizations; + std::queue mWorkQueue; }; #endif -- cgit v1.1