1 /***************************************************************************
2 copyright : (C) 2008 by Serkan Kalyoncu
3 copyright : (C) 2008 by Scott Wheeler
4 email : wheeler@kde.org
5 ***************************************************************************/
7 /***************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License version *
10 * 2.1 as published by the Free Software Foundation. *
12 * This library is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * Lesser General Public License for more details. *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with this library; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
22 * Alternatively, this file is available under the Mozilla Public *
23 * License Version 1.1. You may obtain a copy of the License at *
24 * http://www.mozilla.org/MPL/ *
25 ***************************************************************************/
27 #include <tbytevectorlist.h>
31 #include "privateframe.h"
33 using namespace TagLib;
34 using namespace ID3v2;
37 class PrivateFrame::PrivateFramePrivate
44 ////////////////////////////////////////////////////////////////////////////////
46 ////////////////////////////////////////////////////////////////////////////////
48 PrivateFrame::PrivateFrame() : Frame("PRIV")
50 d = new PrivateFramePrivate;
53 PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data)
55 d = new PrivateFramePrivate;
59 PrivateFrame::~PrivateFrame()
64 String PrivateFrame::toString() const
69 String PrivateFrame::owner() const
74 ByteVector PrivateFrame::data() const
79 void PrivateFrame::setOwner(const String &s)
84 void PrivateFrame::setData(const ByteVector & data)
89 ////////////////////////////////////////////////////////////////////////////////
91 ////////////////////////////////////////////////////////////////////////////////
93 void PrivateFrame::parseFields(const ByteVector &data)
96 debug("A private frame must contain at least 2 bytes.");
100 // Owner identifier is assumed to be Latin1
102 const int byteAlign = 1;
103 const int endOfOwner = data.find(textDelimiter(String::Latin1), 0, byteAlign);
105 d->owner = String(data.mid(0, endOfOwner));
106 d->data = data.mid(endOfOwner + 1);
109 ByteVector PrivateFrame::renderFields() const
113 v.append(d->owner.data(String::Latin1));
114 v.append(textDelimiter(String::Latin1));
120 ////////////////////////////////////////////////////////////////////////////////
122 ////////////////////////////////////////////////////////////////////////////////
124 PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h)
126 d = new PrivateFramePrivate();
127 parseFields(fieldData(data));