for(APE::ItemListMap::ConstIterator it = ape->itemListMap().begin();
it != ape->itemListMap().end(); ++it)
{
- cout << (*it).first << " - \"" << (*it).second.toString() << "\"" << endl;
+ if((*it).second.type() != APE::Item::Binary)
+ cout << (*it).first << " - \"" << (*it).second.toString() << "\"" << endl;
+ else
+ cout << (*it).first << " - Binary data (" << (*it).second.binaryData().size() << " bytes)" << endl;
}
}
else
{
d->type = Binary;
d->value = value;
+ d->text.clear();
}
ByteVector APE::Item::value() const
void APE::Item::setKey(const String &key)
{
- d->key = key;
+ d->key = key;
}
void APE::Item::setValue(const String &value)
{
- d->type = Text;
- d->text = value;
+ d->type = Text;
+ d->text = value;
+ d->value.clear();
}
void APE::Item::setValues(const StringList &value)
{
- d->type = Text;
- d->text = value;
+ d->type = Text;
+ d->text = value;
+ d->value.clear();
}
void APE::Item::appendValue(const String &value)
{
- d->type = Text;
- d->text.append(value);
+ d->type = Text;
+ d->text.append(value);
+ d->value.clear();
}
void APE::Item::appendValues(const StringList &values)
{
- d->type = Text;
- d->text.append(values);
+ d->type = Text;
+ d->text.append(values);
+ d->value.clear();
}
int APE::Item::size() const
String APE::Item::toString() const
{
- return isEmpty() ? String::null : d->text.front();
+ if(d->type == Text && !isEmpty())
+ return d->text.front();
+ else
+ return String::null;
}
bool APE::Item::isEmpty() const
d->key = String(data.mid(8), String::UTF8);
- d->value = data.mid(8 + d->key.size() + 1, valueLength);
+ const ByteVector value = data.mid(8 + d->key.size() + 1, valueLength);
setReadOnly(flags & 1);
setType(ItemTypes((flags >> 1) & 3));
- if(Text == d->type)
- d->text = StringList(ByteVectorList::split(d->value, '\0'), String::UTF8);
+ if(Text == d->type)
+ d->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
+ else
+ d->value = value;
}
ByteVector APE::Item::render() const
/*!
* Returns the binary value.
- * If the item type is not \a Binary, the returned contents are undefined
+ * If the item type is not \a Binary, always returns an empty ByteVector.
*/
ByteVector binaryData() const;
int size() const;
/*!
- * Returns the value as a single string. In case of multiple strings,
- * the first is returned.
+ * Returns the value as a single string. In case of multiple strings,
+ * the first is returned. If the data type is not \a Text, always returns
+ * an empty String.
*/
String toString() const;
#endif
/*!
- * Returns the list of text values.
+ * Returns the list of text values. If the data type is not \a Text, always
+ * returns an empty StringList.
*/
StringList values() const;