libxspf  1.2.0
XspfData.h
Go to the documentation of this file.
1 /*
2  * libxspf - XSPF playlist handling library
3  *
4  * Copyright (C) 2006-2008, Sebastian Pipping / Xiph.Org Foundation
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer.
14  *
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials
18  * provided with the distribution.
19  *
20  * * Neither the name of the Xiph.Org Foundation nor the names of
21  * its contributors may be used to endorse or promote products
22  * derived from this software without specific prior written
23  * permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36  * OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  * Sebastian Pipping, sping@xiph.org
39  */
40 
46 #ifndef XSPF_DATA_H
47 #define XSPF_DATA_H
48 
49 #include "XspfDefines.h"
50 #include <deque>
51 
52 namespace Xspf {
53 
54 
55 class XspfExtension;
56 class XspfDataPrivate;
57 
58 
62 class XspfData {
63 
64  friend class XspfDataPrivate;
65 
66 private:
68  XspfDataPrivate * const d;
69 
71 protected:
75  XspfData();
76 
82  XspfData(XspfData const & source);
83 
89  XspfData & operator=(XspfData const & source);
90 
95  virtual ~XspfData();
96 
97 public:
107  void giveImage(XML_Char const * image, bool copy);
108 
118  void giveInfo(XML_Char const * info, bool copy);
119 
129  void giveAnnotation(XML_Char const * annotation, bool copy);
130 
140  void giveCreator(XML_Char const * creator, bool copy);
141 
151  void giveTitle(XML_Char const * title, bool copy);
152 
161  void giveAppendLink(XML_Char const * rel, bool copyRel, XML_Char const * content, bool copyContent);
162 
171  void giveAppendMeta(XML_Char const * rel, bool copyRel, XML_Char const * content, bool copyContent);
172 
179  void giveAppendExtension(XspfExtension const * extension, bool copy);
180 
188  void lendImage(XML_Char const * image);
189 
197  void lendInfo(XML_Char const * info);
198 
206  void lendAnnotation(XML_Char const * annotation);
207 
215  void lendCreator(XML_Char const * creator);
216 
224  void lendTitle(XML_Char const * title);
225 
234  void lendAppendLink(XML_Char const * rel, XML_Char const * content);
235 
244  void lendAppendMeta(XML_Char const * rel, XML_Char const * content);
245 
253  void lendAppendExtension(XspfExtension * extension);
254 
260  XML_Char * stealImage();
261 
267  XML_Char * stealInfo();
268 
274  XML_Char * stealAnnotation();
275 
281  XML_Char * stealCreator();
282 
288  XML_Char * stealTitle();
289 
298  std::pair<XML_Char *, XML_Char *> * stealFirstLink();
299 
308  std::pair<XML_Char *, XML_Char *> * stealFirstMeta();
309 
319 
325  XML_Char const * getImage() const;
326 
332  XML_Char const * getInfo() const;
333 
339  XML_Char const * getAnnotation() const;
340 
346  XML_Char const * getCreator() const;
347 
353  XML_Char const * getTitle() const;
354 
363  std::pair<XML_Char const *, XML_Char const *> * getLink(int index) const;
364 
373  std::pair<XML_Char const *, XML_Char const *> * getMeta(int index) const;
374 
383  XspfExtension const * getExtension(int index) const;
384 
390  int getLinkCount() const;
391 
397  int getMetaCount() const;
398 
404  int getExtensionCount() const;
405 
406 private:
416  static void appendHelper(std::deque<std::pair<
417  std::pair<XML_Char const *, bool> *,
418  std::pair<XML_Char const *, bool> *> *> * & container,
419  XML_Char const * rel,
420  bool ownRel,
421  XML_Char const * content,
422  bool ownContent);
423 
431  static void appendHelper(std::deque<
432  std::pair<XspfExtension const *, bool> *> * & container,
433  XspfExtension const * extenstion,
434  bool own);
435 
436 protected:
446  static XML_Char * stealHelper(XML_Char const * & property, bool own);
447 
448 private:
455  static std::pair<XML_Char *, XML_Char *> * stealFirstHelper(
456  std::deque<std::pair<std::pair<XML_Char const *, bool> *,
457  std::pair<XML_Char const *, bool> *> *> * & container);
458 
465  static XspfExtension * stealFirstHelper(std::deque<
466  std::pair<XspfExtension const *, bool> *> * & container);
467 
478  static std::pair<XML_Char const *, XML_Char const *> * getHelper(
479  std::deque<std::pair<std::pair<XML_Char const *, bool> *,
480  std::pair<XML_Char const *, bool> *> *> * & container,
481  int index);
482 
493  static XspfExtension const * getHelper(
494  std::deque<std::pair<XspfExtension const *, bool> *> * & container,
495  int index);
496 
497 protected:
499  void virtualHook(int methodId, void * parameters);
501 
502 public:
503  static bool const COPY;
504  static bool const TRANSFER;
505 
506 };
507 
508 
509 }
510 
511 #endif // XSPF_DATA_H
void lendAppendExtension(XspfExtension *extension)
void lendInfo(XML_Char const *info)
XspfExtension * stealFirstExtension()
std::pair< XML_Char const *, XML_Char const * > * getLink(int index) const
void giveImage(XML_Char const *image, bool copy)
void lendAppendMeta(XML_Char const *rel, XML_Char const *content)
XspfData & operator=(XspfData const &source)
void giveAppendMeta(XML_Char const *rel, bool copyRel, XML_Char const *content, bool copyContent)
void giveTitle(XML_Char const *title, bool copy)
XML_Char * stealCreator()
void giveAppendExtension(XspfExtension const *extension, bool copy)
XspfExtension const * getExtension(int index) const
static XML_Char * stealHelper(XML_Char const *&property, bool own)
int getExtensionCount() const
int getLinkCount() const
XML_Char * stealAnnotation()
XML_Char * stealInfo()
int getMetaCount() const
std::pair< XML_Char const *, XML_Char const * > * getMeta(int index) const
void lendAppendLink(XML_Char const *rel, XML_Char const *content)
XML_Char * stealTitle()
void giveAppendLink(XML_Char const *rel, bool copyRel, XML_Char const *content, bool copyContent)
void giveCreator(XML_Char const *creator, bool copy)
void lendImage(XML_Char const *image)
static bool const TRANSFER
Memory ownership is transfered.
Definition: XspfData.h:504
XML_Char const * getTitle() const
std::pair< XML_Char *, XML_Char * > * stealFirstLink()
XML_Char const * getAnnotation() const
XML_Char const * getInfo() const
static bool const COPY
Memory is copied.
Definition: XspfData.h:503
std::pair< XML_Char *, XML_Char * > * stealFirstMeta()
void lendTitle(XML_Char const *title)
void lendCreator(XML_Char const *creator)
XML_Char * stealImage()
void giveAnnotation(XML_Char const *annotation, bool copy)
void giveInfo(XML_Char const *info, bool copy)
XML_Char const * getImage() const
XML_Char const * getCreator() const
void lendAnnotation(XML_Char const *annotation)
virtual ~XspfData()