File: ID3_PropertyMap.h

package info (click to toggle)
kwave 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,272 kB
  • sloc: cpp: 56,173; xml: 817; perl: 688; sh: 57; makefile: 11
file content (130 lines) | stat: -rw-r--r-- 4,772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*************************************************************************
    ID3_PropertyMap.h    -  map for translating properties to ID3 frame tags
                             -------------------
    begin                : Sat Jul 30 2012
    copyright            : (C) 2012 by Thomas Eschenbacher
    email                : Thomas.Eschenbacher@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef ID3_PROPERTY_MAP_H
#define ID3_PROPERTY_MAP_H

#include "config.h"

#include <QList>

#include <id3/globals.h>

#include "libkwave/FileInfo.h"

namespace Kwave
{

    class ID3_PropertyMap
    {
    public:

        /** encoding of the ID3 tag */
        typedef enum {
            ENC_NONE = 0,
            ENC_COMMENT,        /**< comment frame                     */
            ENC_GENRE_TYPE,     /**< genre type, numeric or text       */
            ENC_LENGTH,         /**< string with length in ms          */
            ENC_TERMS_OF_USE,   /**< terms of use                      */
            ENC_TEXT,           /**< text, appended by ';'             */
            ENC_TEXT_SLASH,     /**< text list, separated by slash '/' */
            ENC_TEXT_LIST,      /**< list of zero terminated strings   */
            ENC_TEXT_URL,       /**< URL                               */
            ENC_TEXT_PARTINSET, /**< part in set (x/y)                 */
            ENC_TEXT_TIMESTAMP, /**< ISO 8601 timestamp                */
            ENC_TRACK_NUM,      /**< track/tracks (x/y)                */
            ENC_BINARY          /**< binary/custom data                */
        } Encoding;

        /** Default constructor, with initializing */
        ID3_PropertyMap();

        /** Destructor */
        virtual ~ID3_PropertyMap() {}

        /**
         * Returns the frame ID of a property or an empty string
         * if nothing found (reverse lookup).
         */
        ID3_FrameID findProperty(const Kwave::FileProperty property) const;

        /** Returns true if the map contains a given property */
        bool containsProperty(const Kwave::FileProperty property) const;

        /**
         * insert a new property / frame ID mapping
         *
         * @param property a Kwave FileProperty
         * @param id a ID3 frame ID
         * @param encoding the type of the encoding of the tag
         */
        void insert(const Kwave::FileProperty property, const ID3_FrameID id,
                    const Encoding encoding);

        /**
         * returns true if a given ID3 frame ID is in the map
         *
         * @param id a ID3 frame ID
         * @return true if found, false if not
         */
        bool containsID(const ID3_FrameID id) const;

        /**
         * returns the encoding of the ID3 frame
         *
         * @param id a ID3 frame ID
         * @return the encoding of the content of the frame
         */
        Encoding encoding(const ID3_FrameID id) const;

        /** returns a list of all known ID3 frame IDs */
        QList<ID3_FrameID> knownIDs() const;

        /**
         * Returns the first FileProperty that matches a given ID3 frame ID
         *
         * @param id a ID3 frame ID
         * @return a FileProperty
         */
        Kwave::FileProperty property(const ID3_FrameID id) const;

        /** Returns a list with all supported properties */
        QList<Kwave::FileProperty> properties() const;

    private:

        /** returns true if a frame is supported by id3lib */
        bool supported(const ID3_FrameID id) const;

    private:
        /** container for one mapping */
        typedef struct
        {
            Kwave::FileProperty m_property; /**< the Kwave property */
            ID3_FrameID  m_frame_id;        /**< ID3 frame ID       */
            Encoding     m_encoding;        /**< data encoding      */
        } Mapping;

        /** list of mappings */
        QList<Mapping> m_list;
    };
}

#endif /* ID3_PROPERTY_MAP_H */

//***************************************************************************
//***************************************************************************