bool readOnly;
};
-APE::Item::Item()
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+APE::Item::Item() :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
}
-APE::Item::Item(const String &key, const String &value)
+APE::Item::Item(const String &key, const String &value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->key = key;
d->text.append(value);
}
-APE::Item::Item(const String &key, const StringList &values)
+APE::Item::Item(const String &key, const StringList &values) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->key = key;
d->text = values;
}
-APE::Item::Item(const String &key, const ByteVector &value, bool binary)
+APE::Item::Item(const String &key, const ByteVector &value, bool binary) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->key = key;
if(binary) {
d->type = Binary;
d->text.append(value);
}
-APE::Item::Item(const Item &item)
+APE::Item::Item(const Item &item) :
+ d(new ItemPrivate(*item.d))
{
- d = new ItemPrivate(*item.d);
}
APE::Item::~Item()
Item &APE::Item::operator=(const Item &item)
{
- if(&item != this) {
- delete d;
- d = new ItemPrivate(*item.d);
- }
+ Item(item).swap(*this);
return *this;
}
+void APE::Item::swap(Item &item)
+{
+ using std::swap;
+
+ swap(d, item.d);
+}
+
void APE::Item::setReadOnly(bool readOnly)
{
d->readOnly = readOnly;
*/
Item &operator=(const Item &item);
+ /*!
+ * Exchanges the content of this item by the content of \a item.
+ */
+ void swap(Item &item);
+
/*!
* Returns the key.
*/
// public members
////////////////////////////////////////////////////////////////////////////////
-ASF::Attribute::Attribute()
+ASF::Attribute::Attribute() :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = UnicodeType;
}
-ASF::Attribute::Attribute(const ASF::Attribute &other)
- : d(other.d)
+ASF::Attribute::Attribute(const ASF::Attribute &other) :
+ d(other.d)
{
d->ref();
}
-ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
-{
- if(&other != this) {
- if(d->deref())
- delete d;
- d = other.d;
- d->ref();
- }
- return *this;
-}
-
-ASF::Attribute::~Attribute()
+ASF::Attribute::Attribute(const String &value) :
+ d(new AttributePrivate())
{
- if(d->deref())
- delete d;
-}
-
-ASF::Attribute::Attribute(const String &value)
-{
- d = new AttributePrivate;
d->type = UnicodeType;
d->stringValue = value;
}
-ASF::Attribute::Attribute(const ByteVector &value)
+ASF::Attribute::Attribute(const ByteVector &value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = BytesType;
d->byteVectorValue = value;
}
-ASF::Attribute::Attribute(const ASF::Picture &value)
+ASF::Attribute::Attribute(const ASF::Picture &value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = BytesType;
d->pictureValue = value;
}
-ASF::Attribute::Attribute(unsigned int value)
+ASF::Attribute::Attribute(unsigned int value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = DWordType;
d->intValue = value;
}
-ASF::Attribute::Attribute(unsigned long long value)
+ASF::Attribute::Attribute(unsigned long long value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = QWordType;
d->longLongValue = value;
}
-ASF::Attribute::Attribute(unsigned short value)
+ASF::Attribute::Attribute(unsigned short value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = WordType;
d->shortValue = value;
}
-ASF::Attribute::Attribute(bool value)
+ASF::Attribute::Attribute(bool value) :
+ d(new AttributePrivate())
{
- d = new AttributePrivate;
d->type = BoolType;
d->boolValue = value;
}
+ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
+{
+ Attribute(other).swap(*this);
+ return *this;
+}
+
+void ASF::Attribute::swap(Attribute &other)
+{
+ using std::swap;
+
+ swap(d, other.d);
+}
+
+ASF::Attribute::~Attribute()
+{
+ if(d->deref())
+ delete d;
+}
+
ASF::Attribute::AttributeTypes ASF::Attribute::type() const
{
return d->type;
{
d->stream = value;
}
-
*/
ASF::Attribute &operator=(const Attribute &other);
+ /*!
+ * Exchanges the content of the Attribute by the content of \a other.
+ */
+ void swap(Attribute &other);
+
/*!
* Destroys the attribute.
*/
// Picture class members
////////////////////////////////////////////////////////////////////////////////
-ASF::Picture::Picture()
+ASF::Picture::Picture() :
+ d(new PicturePrivate())
{
- d = new PicturePrivate();
d->valid = true;
}
-ASF::Picture::Picture(const Picture& other)
- : d(other.d)
+ASF::Picture::Picture(const Picture& other) :
+ d(other.d)
{
d->ref();
}
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
{
- if(other.d != d) {
- if(d->deref())
- delete d;
- d = other.d;
- d->ref();
- }
+ Picture(other).swap(*this);
return *this;
}
+void ASF::Picture::swap(Picture &other)
+{
+ using std::swap;
+
+ swap(d, other.d);
+}
+
ByteVector ASF::Picture::render() const
{
if(!isValid())
ret.d->valid = false;
return ret;
}
-
*/
Picture& operator=(const Picture& other);
+ /*!
+ * Exchanges the content of the Picture by the content of \a other.
+ */
+ void swap(Picture &other);
+
/*!
* Returns true if Picture stores valid picture
*/
class MP4::CoverArt::CoverArtPrivate : public RefCounter
{
public:
- CoverArtPrivate() : RefCounter(), format(MP4::CoverArt::JPEG) {}
+ CoverArtPrivate() :
+ RefCounter(),
+ format(MP4::CoverArt::JPEG) {}
Format format;
ByteVector data;
};
-MP4::CoverArt::CoverArt(Format format, const ByteVector &data)
+////////////////////////////////////////////////////////////////////////////////
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+MP4::CoverArt::CoverArt(Format format, const ByteVector &data) :
+ d(new CoverArtPrivate())
{
- d = new CoverArtPrivate;
d->format = format;
d->data = data;
}
-MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d)
+MP4::CoverArt::CoverArt(const CoverArt &item) :
+ d(item.d)
{
d->ref();
}
MP4::CoverArt &
MP4::CoverArt::operator=(const CoverArt &item)
{
- if(&item != this) {
- if(d->deref())
- delete d;
- d = item.d;
- d->ref();
- }
+ CoverArt(item).swap(*this);
return *this;
}
+void
+MP4::CoverArt::swap(CoverArt &item)
+{
+ using std::swap;
+
+ swap(d, item.d);
+}
+
MP4::CoverArt::~CoverArt()
{
if(d->deref()) {
{
return d->data;
}
-
~CoverArt();
CoverArt(const CoverArt &item);
+
+ /*!
+ * Copies the contents of \a item into this CoverArt.
+ */
CoverArt &operator=(const CoverArt &item);
+ /*!
+ * Exchanges the content of the CoverArt by the content of \a item.
+ */
+ void swap(CoverArt &item);
+
//! Format of the image
Format format() const;
class MP4::Item::ItemPrivate : public RefCounter
{
public:
- ItemPrivate() : RefCounter(), valid(true), atomDataType(TypeUndefined) {}
+ ItemPrivate() :
+ RefCounter(),
+ valid(true),
+ atomDataType(TypeUndefined) {}
bool valid;
AtomDataType atomDataType;
MP4::CoverArtList m_coverArtList;
};
-MP4::Item::Item()
+MP4::Item::Item() :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->valid = false;
}
-MP4::Item::Item(const Item &item) : d(item.d)
+MP4::Item::Item(const Item &item) :
+ d(item.d)
{
d->ref();
}
MP4::Item &
MP4::Item::operator=(const Item &item)
{
- if(&item != this) {
- if(d->deref()) {
- delete d;
- }
- d = item.d;
- d->ref();
- }
+ Item(item).swap(*this);
return *this;
}
+void
+MP4::Item::swap(Item &item)
+{
+ using std::swap;
+
+ swap(d, item.d);
+}
+
MP4::Item::~Item()
{
- if(d->deref()) {
+ if(d->deref())
delete d;
- }
}
-MP4::Item::Item(bool value)
+MP4::Item::Item(bool value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_bool = value;
}
-MP4::Item::Item(int value)
+MP4::Item::Item(int value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_int = value;
}
-MP4::Item::Item(uchar value)
+MP4::Item::Item(uchar value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_byte = value;
}
-MP4::Item::Item(uint value)
+MP4::Item::Item(uint value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_uint = value;
}
-MP4::Item::Item(long long value)
+MP4::Item::Item(long long value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_longlong = value;
}
-MP4::Item::Item(int value1, int value2)
+MP4::Item::Item(int value1, int value2) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_intPair.first = value1;
d->m_intPair.second = value2;
}
-MP4::Item::Item(const ByteVectorList &value)
+MP4::Item::Item(const ByteVectorList &value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_byteVectorList = value;
}
-MP4::Item::Item(const StringList &value)
+MP4::Item::Item(const StringList &value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_stringList = value;
}
-MP4::Item::Item(const MP4::CoverArtList &value)
+MP4::Item::Item(const MP4::CoverArtList &value) :
+ d(new ItemPrivate())
{
- d = new ItemPrivate;
d->m_coverArtList = value;
}
{
return d->valid;
}
-
Item();
Item(const Item &item);
+
+ /*!
+ * Copies the contents of \a item into this Item.
+ */
Item &operator=(const Item &item);
+
+ /*!
+ * Exchanges the content of the Item by the content of \a item.
+ */
+ void swap(Item &item);
+
~Item();
Item(int value);