| 3179 | } |
| 3180 | |
| 3181 | status_t ResourceTable::Entry::setItem(const SourcePos& sourcePos, |
| 3182 | const String16& value, |
| 3183 | const Vector<StringPool::entry_style_span>* style, |
| 3184 | int32_t format, |
| 3185 | const bool overwrite) |
| 3186 | { |
| 3187 | Item item(sourcePos, false, value, style); |
| 3188 | |
| 3189 | if (mType == TYPE_BAG) { |
| 3190 | const Item& item(mBag.valueAt(0)); |
| 3191 | sourcePos.error("Resource entry %s is already defined as a bag.\n" |
| 3192 | "%s:%d: Originally defined here.\n", |
| 3193 | String8(mName).string(), |
| 3194 | item.sourcePos.file.string(), item.sourcePos.line); |
| 3195 | return UNKNOWN_ERROR; |
| 3196 | } |
| 3197 | if ( (mType != TYPE_UNKNOWN) && (overwrite == false) ) { |
| 3198 | sourcePos.error("Resource entry %s is already defined.\n" |
| 3199 | "%s:%d: Originally defined here.\n", |
| 3200 | String8(mName).string(), |
| 3201 | mItem.sourcePos.file.string(), mItem.sourcePos.line); |
| 3202 | return UNKNOWN_ERROR; |
| 3203 | } |
| 3204 | |
| 3205 | mType = TYPE_ITEM; |
| 3206 | mItem = item; |
| 3207 | mItemFormat = format; |
| 3208 | return NO_ERROR; |
| 3209 | } |
| 3210 | |
| 3211 | status_t ResourceTable::Entry::addToBag(const SourcePos& sourcePos, |
| 3212 | const String16& key, const String16& value, |