| 3209 | } |
| 3210 | |
| 3211 | status_t ResourceTable::Entry::addToBag(const SourcePos& sourcePos, |
| 3212 | const String16& key, const String16& value, |
| 3213 | const Vector<StringPool::entry_style_span>* style, |
| 3214 | bool replace, bool isId, int32_t format) |
| 3215 | { |
| 3216 | status_t err = makeItABag(sourcePos); |
| 3217 | if (err != NO_ERROR) { |
| 3218 | return err; |
| 3219 | } |
| 3220 | |
| 3221 | Item item(sourcePos, isId, value, style, format); |
| 3222 | |
| 3223 | // XXX NOTE: there is an error if you try to have a bag with two keys, |
| 3224 | // one an attr and one an id, with the same name. Not something we |
| 3225 | // currently ever have to worry about. |
| 3226 | ssize_t origKey = mBag.indexOfKey(key); |
| 3227 | if (origKey >= 0) { |
| 3228 | if (!replace) { |
| 3229 | const Item& item(mBag.valueAt(origKey)); |
| 3230 | sourcePos.error("Resource entry %s already has bag item %s.\n" |
| 3231 | "%s:%d: Originally defined here.\n", |
| 3232 | String8(mName).string(), String8(key).string(), |
| 3233 | item.sourcePos.file.string(), item.sourcePos.line); |
| 3234 | return UNKNOWN_ERROR; |
| 3235 | } |
| 3236 | //printf("Replacing %s with %s\n", |
| 3237 | // String8(mBag.valueFor(key).value).string(), String8(value).string()); |
| 3238 | mBag.replaceValueFor(key, item); |
| 3239 | } |
| 3240 | |
| 3241 | mBag.add(key, item); |
| 3242 | return NO_ERROR; |
| 3243 | } |
| 3244 | |
| 3245 | status_t ResourceTable::Entry::emptyBag(const SourcePos& sourcePos) |
| 3246 | { |
no test coverage detected