File: ChunkPath.h

package info (click to toggle)
exempi 2.6.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,780 kB
  • sloc: cpp: 79,791; sh: 4,606; ansic: 538; makefile: 383
file content (191 lines) | stat: -rw-r--r-- 4,259 bytes parent folder | download | duplicates (2)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// =================================================================================================
// Copyright Adobe
// Copyright 2010 Adobe
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it. 
// =================================================================================================

#ifndef _ChunkPath_h_
#define _ChunkPath_h_

#include "public/include/XMP_Environment.h"	// ! This must be the first include.
#include "public/include/XMP_Const.h"

#include <limits.h>	// For UINT_MAX.
#include <vector>

namespace IFF_RIFF
{

/**
	A ChunkPath describes one certain chunk in the hierarchy of chunks
	of the IFF/RIFF file format.
	Each chunks gets identified by a structure of the type ChunkIdentifier.
	Which consists of the 4byte ID of the chunk and, if applicable, the 4byte
	type of the chunk.
*/

// IFF/RIFF ids
enum {
	// invalid ID
	kChunk_NONE = UINT_MAX,

	// format chunks
	kChunk_RIFF = 0x52494646,
	kChunk_RF64 = 0x52463634,
	kChunk_FORM = 0x464F524D,
	kChunk_JUNK = 0x4A554E4B,
	kChunk_JUNQ = 0x4A554E51,
	

	// other container chunks
	kChunk_LIST = 0x4C495354,

	// other relevant chunks
	kChunk_XMP  = 0x5F504D58, // "_PMX"

	kChunk_data	= 0x64617461,

	//should occur only in AVI
	kChunk_Cr8r = 0x43723872,
	kChunk_PrmL = 0x50726D4C,

	//should occur only in WAV
	kChunk_DISP = 0x44495350,
	kChunk_bext = 0x62657874,
	kChunk_cart = 0x63617274,
	kChunk_ds64 = 0x64733634,
	kChunk_iXML = 0x69584D4C,

	// AIFF
	kChunk_APPL	= 0x4150504C,
	kChunk_NAME = 0x4E414D45,
	kChunk_AUTH = 0x41555448,
	kChunk_CPR  = 0x28632920,
	kChunk_ANNO = 0x414E4E4F
};

// IFF/RIFF types
enum {
	kType_AVI_ = 0x41564920,
	kType_AVIX = 0x41564958,
	kType_WAVE = 0x57415645,
	kType_AIFF = 0x41494646,
	kType_AIFC = 0x41494643,
	kType_INFO = 0x494E464F,
	kType_Tdat = 0x54646174,

	// AIFF
	kType_XMP  = 0x584D5020,
	kType_FREE = 0x46524545,

	kType_NONE = UINT_MAX
};


struct ChunkIdentifier
{
   XMP_Uns32 id;
   XMP_Uns32 type;
};

/**
* calculates the size of a ChunkIdentifier array.
* Has to be a macro as the sizeof operator does nto work for pointer function parameters
*/
#define SizeOfCIArray(ciArray) ( sizeof(ciArray) / sizeof(ChunkIdentifier) )


class ChunkPath
{
public:
	/**
	ctor/dtor
	*/
							ChunkPath( const ChunkIdentifier* path = NULL, XMP_Uns32 size = 0 );
							ChunkPath( const ChunkPath& path );
							ChunkPath( const ChunkIdentifier& identifier );
						   ~ChunkPath();

	ChunkPath &				operator=( const ChunkPath &rhs );

	/**
	Append a ChunkIdentifier to the end of the path

	@param	id		4byte id of chunk
	@param	type	4byte type of chunk
	*/
	void					append( XMP_Uns32 id, XMP_Uns32 type = kType_NONE );
	void					append( const ChunkIdentifier& identifier );
	
	/**
	Append a whole path
	
	@param path Array of ChunkIdentifiert objects
	@param size number of elements in the given array
	*/
	void					append( const ChunkIdentifier* path = NULL, XMP_Uns32 size = 0 );

	/**
	Insert an identifier
	
	@param identifier	id and type
	@param pos			position within the path
	 */
	void					insert( const ChunkIdentifier& identifier, XMP_Uns32 pos = 0 );

	/**
	Remove the endmost ChunkIdentifier from the path
	*/
	void					remove();
	/**
	Remove the ChunkIdentifier at the passed position in the path.
	Throw exception if the position is out of range.

	@param	pos		Position of ChunkIdentifier in the path
	*/
	void					removeAt( XMP_Int32 pos );

	/**
	Return ChunkIdentifier at the passed position

	@param	pos		Position of ChunkIdentifier in the path
	@return			ChunkIdentifier at passed position (throw exception if
					the position is out of range)
	*/
	const ChunkIdentifier&	identifier( XMP_Int32 pos ) const;

	/**
	Return the number of ChunkIdentifier's in the path
	*/
	XMP_Int32				length() const;

	/**
	Remove all ChunkIdentifier's from the path
	*/
	void					clear();

	/**
	Compare the passed ChunkPath with this path.

	@param	path	Path to compare with this path
	@return			Match result
	*/
	enum MatchResult
	{
		kNoMatch	= 0,
		kPartMatch	= 1,
		kFullMatch	= 2
	};

	MatchResult				match( const ChunkPath& path ) const;

private:
	std::vector<ChunkIdentifier>	mPath;
};

}

#endif