bool NavigationDataReceiver::parse(MemoryLibrary::Buffer& buffer) { int offset = 0; int header = buffer.MakeValueFromOffset<int32_t>(offset); if(header != 0x55667788) { std::cout << "NavigationDataReceiver::Parse FAIL, header != 0x55667788\n"; return false; } offset += 4; int state = buffer.MakeValueFromOffset<int32_t>(offset); parseState(state); offset += 4; myNavData.sequence = buffer.MakeValueFromOffset<int32_t>(offset); offset += 4; myNavData.visionFlag = buffer.MakeValueFromOffset<int32_t>(offset); offset += 4; while(offset < buffer.Size()) { int option_tag = (int)buffer.MakeValueFromOffset<unsigned short>(offset); offset += 2; int option_len = (int)buffer.MakeValueFromOffset<unsigned short>(offset); offset += 2; if(option_len == 0) { std::cout << "NavigationDataReceiver::Parse FAIL, option_len == 0\n"; return false; } switch(option_tag) { case NAVDATA_DEMO_TAG: parseNavigation(buffer, offset); break; case NAVDATA_CKS_TAG: break; case NAVDATA_VISION_DETECT_TAG: parseVision(buffer, offset); break; } offset = offset + option_len - 4; } //while return true; }
bool parse(const String8& str, ConfigDescription* out) { Vector<String8> parts = AaptUtil::splitAndLowerCase(str, '-'); ConfigDescription config; AaptLocaleValue locale; ssize_t index = 0; ssize_t localeIndex = 0; const ssize_t N = parts.size(); const char* part = parts[index].string(); if (str.length() == 0) { goto success; } if (parseMcc(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseMnc(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } // Locale spans a few '-' separators, so we let it // control the index. localeIndex = locale.initFromDirName(parts, index); if (localeIndex < 0) { return false; } else if (localeIndex > index) { locale.writeTo(&config); index = localeIndex; if (index >= N) { goto success; } part = parts[index].string(); } if (parseLayoutDirection(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseSmallestScreenWidthDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenWidthDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenHeightDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenLayoutSize(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenLayoutLong(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenRound(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseOrientation(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseUiModeType(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseUiModeNight(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseDensity(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseTouchscreen(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseKeysHidden(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseKeyboard(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseNavHidden(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseNavigation(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenSize(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseVersion(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } // Unrecognized. return false; success: if (out != NULL) { applyVersionForCompatibility(&config); *out = config; } return true; }
bool parse(const String8& str, ConfigDescription* out) { Vector<String8> parts = AaptUtil::splitAndLowerCase(str, '-'); ConfigDescription config; AaptLocaleValue locale; ssize_t index = 0; ssize_t localeIndex = 0; const ssize_t N = parts.size(); const char* part = parts[index].string(); if (str.length() == 0) { goto success; } if (parseMcc(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseMnc(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } // Locale spans a few '-' separators, so we let it // control the index. localeIndex = locale.initFromDirName(parts, index); if (localeIndex < 0) { return false; } else if (localeIndex > index) { locale.writeTo(&config); index = localeIndex; if (index >= N) { goto success; } part = parts[index].string(); } if (parseLayoutDirection(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseSmallestScreenWidthDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenWidthDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenHeightDp(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenLayoutSize(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenLayoutLong(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseOrientation(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseUiModeType(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseUiModeNight(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseDensity(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseTouchscreen(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseKeysHidden(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseKeyboard(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseNavHidden(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseNavigation(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseScreenSize(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } if (parseVersion(part, &config)) { index++; if (index == N) { goto success; } part = parts[index].string(); } // Unrecognized. return false; success: if (out != NULL) { #ifndef HAVE_ANDROID_OS applyVersionForCompatibility(&config); #else // Calling applyVersionForCompatibility when compiling a theme can cause // the path to be changed by AAPT which results in the themed assets not being // loaded. The only time (as of right now) that aapt is run on an android device // is when it is being used for themes, so this should be the correct behavior // in this case. If AAPT is ever used on an android device for some other reason, // we will need to change this. printf("AAPT is running on Android, skipping applyVersionForCompatibility"); #endif *out = config; } return true; }