home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libkcddb / cdinfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-01-19  |  4.0 KB  |  147 lines

  1. /*
  2.   Copyright (C) 2002 Rik Hemsley (rikkus) <rik@kde.org>
  3.   Copyright (C) 2002 Benjamin Meyer <ben-devel@meyerhome.net>
  4.   Copyright (C) 2002-2004 Nadeem Hasan <nhasan@nadmm.com>
  5.  
  6.   This library is free software; you can redistribute it and/or
  7.   modify it under the terms of the GNU Library General Public
  8.   License as published by the Free Software Foundation; either
  9.   version 2 of the License, or (at your option) any later version.
  10.  
  11.   This library is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.   Library General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU Library General Public License
  17.   along with this library; see the file COPYING.LIB.  If not, write to
  18.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.   Boston, MA 02111-1307, USA.
  20. */
  21.  
  22. #ifndef KCDDB_CDINFO_H
  23. #define KCDDB_CDINFO_H
  24.  
  25. #include <qstringlist.h>
  26. #include <qvaluelist.h>
  27. #include <kdemacros.h>
  28. #include <qvariant.h>
  29.  
  30. namespace KCDDB
  31. {
  32.   /**
  33.    * Information about a sepecific track in a cd.
  34.    */
  35.   class KDE_EXPORT TrackInfo
  36.   {
  37.     public:
  38.  
  39.       TrackInfo();
  40.       ~TrackInfo();
  41.       TrackInfo(const TrackInfo& clone);
  42.       TrackInfo& operator=(const TrackInfo& clone);
  43.  
  44.       /**
  45.        * Get data for type that has been assigned to this track.
  46.        * @p type is case insensitive.
  47.        * For example <code>get("title")</code>
  48.        */
  49.       QVariant get(const QString &type) const;
  50. #ifndef KDE_NO_COMPAT        
  51.       // Use get("title");
  52.       QString title;
  53.       // Use get("extt");
  54.       QString extt;
  55. #endif
  56.   };
  57.  
  58.   typedef QValueList<TrackInfo> TrackInfoList;
  59.  
  60.   /**
  61.    * Information about a CD
  62.    *
  63.    * Typically CDInfo is obtained from the client such as:
  64.    * <code>KCDDB::Client *cddb = new KCDDB::Client();
  65.    * cddb->lookup(discSignature);
  66.    * CDInfo info = cddb->bestLookupResponse();</code>
  67.    */
  68.   class KDE_EXPORT CDInfo
  69.   {
  70.     public:
  71.  
  72.       CDInfo();
  73.       ~CDInfo();
  74.       CDInfo(const CDInfo& clone);
  75.       CDInfo& operator=(const CDInfo& clone);
  76.  
  77.       /**
  78.        * Load CDInfo from a string that is CDDB compatible
  79.        * @return true if successful
  80.        */
  81.       bool load(const QString &);
  82.       /**
  83.        * Load CDInfo from a stringList that is CDDB compatible
  84.        * @return true if successful
  85.        */
  86.       bool load(const QStringList &);
  87.  
  88.       /**
  89.        * Clear all information, setting this to invalid
  90.        * internal
  91.        */
  92.       void clear();
  93.  
  94.       /**
  95.        * @return true if the cd information is valid
  96.        */
  97.       bool isValid() const;
  98.       /**
  99.        * @param submit If submit is true only returns CDDB compatible information
  100.        * @return a string containing all of the CD's information. 
  101.        */
  102.       QString toString(bool submit=false) const;
  103.       
  104.       /**
  105.        * Get data for type that has been assigned to this disc.
  106.        * @p type is case insensitive.
  107.        * For example <code>get("title")</code>
  108.        */
  109.       QVariant get(const QString &type) const;
  110.       // Use get(...)
  111.       QString       id;
  112.       QString       artist;
  113.       QString       title;
  114.       QString       genre;
  115.       QString       category;
  116.       QString       extd;
  117.       uint          year;
  118.       uint          length; // in milliseconds
  119.       uint          revision;
  120.  
  121.       TrackInfoList trackInfoList;
  122.  
  123.     protected:
  124.       /**
  125.        * @returns a valid CDDB line made up of name and value
  126.        */
  127.       QString createLine(const QString& name, const QString& value) const;
  128.       /**
  129.        * Checks to make sure that trackNumber exists
  130.        */
  131.       void checkTrack( uint );
  132.       /**
  133.        * escape's string for CDDB processing
  134.        */
  135.       static QString escape( const QString & );
  136.       /**
  137.        * fixes an escaped string that has been CDDB processed
  138.        */
  139.       static QString unescape( const QString & );
  140.   };
  141.  
  142.   typedef QValueList<CDInfo> CDInfoList;
  143. }
  144.  
  145. #endif // KCDDB_CDINFO_H
  146. // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1
  147.