MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / stringToValue

Method stringToValue

tools/aapt/ResourceTable.cpp:2176–2237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2174}
2175
2176bool ResourceTable::stringToValue(Res_value* outValue, StringPool* pool,
2177 const String16& str,
2178 bool preserveSpaces, bool coerceType,
2179 uint32_t attrID,
2180 const Vector<StringPool::entry_style_span>* style,
2181 String16* outStr, void* accessorCookie,
2182 uint32_t attrType, const String8* configTypeName,
2183 const ConfigDescription* config)
2184{
2185 String16 finalStr;
2186
2187 bool res = true;
2188 if (style == NULL || style->size() == 0) {
2189 // Text is not styled so it can be any type... let's figure it out.
2190 res = mAssets->getIncludedResources()
2191 .stringToValue(outValue, &finalStr, str.string(), str.size(), preserveSpaces,
2192 coerceType, attrID, NULL, &mAssetsPackage, this,
2193 accessorCookie, attrType);
2194 } else {
2195 // Styled text can only be a string, and while collecting the style
2196 // information we have already processed that string!
2197 outValue->size = sizeof(Res_value);
2198 outValue->res0 = 0;
2199 outValue->dataType = outValue->TYPE_STRING;
2200 outValue->data = 0;
2201 finalStr = str;
2202 }
2203
2204 if (!res) {
2205 return false;
2206 }
2207
2208 if (outValue->dataType == outValue->TYPE_STRING) {
2209 // Should do better merging styles.
2210 if (pool) {
2211 String8 configStr;
2212 if (config != NULL) {
2213 configStr = config->toString();
2214 } else {
2215 configStr = "(null)";
2216 }
2217 NOISY(printf("Adding to pool string style #%d config %s: %s\n",
2218 style != NULL ? style->size() : 0,
2219 configStr.string(), String8(finalStr).string()));
2220 if (style != NULL && style->size() > 0) {
2221 outValue->data = pool->add(finalStr, *style, configTypeName, config);
2222 } else {
2223 outValue->data = pool->add(finalStr, true, configTypeName, config);
2224 }
2225 } else {
2226 // Caller will fill this in later.
2227 outValue->data = 0;
2228 }
2229
2230 if (outStr) {
2231 *outStr = finalStr;
2232 }
2233

Callers 2

prepareFlattenMethod · 0.45
parseValuesMethod · 0.45

Calls 4

stringMethod · 0.80
sizeMethod · 0.65
addMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected