aboutsummaryrefslogtreecommitdiff
path: root/Src/Agave/Metadata/ifc_metadataReader.h
blob: 16749795d5e0d7165045d01ef5a098eeef8c3b39 (plain) (blame)
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
#ifndef NULLSOFT_AGAVE_METADATA_IFC_METADATAREADER_H
#define NULLSOFT_AGAVE_METADATA_IFC_METADATAREADER_H

#include <bfc/dispatch.h>

class ifc_metadataReader : public Dispatchable
{
protected:
	ifc_metadataReader()
	{}
	~ifc_metadataReader()
	{}
public:
	/* If there are multiple values for the same field, these functions will concatenate the values in some
	 manner as defined by the language pack */
	int GetField( const wchar_t *field, wchar_t *destination, size_t destinationCch );
	int GetFieldByKey( uint32_t field_key, wchar_t *destination, size_t destinationCch );

	int GetIndexedField( const wchar_t *field, uint32_t index, wchar_t *destination, size_t destinationCch );
	int GetIndexedFieldByKey( uint32_t field_key, uint32_t index, wchar_t *destination, size_t destinationCch );

	class ifc_fieldEnumerator : public Dispatchable
	{
	protected:
		ifc_fieldEnumerator();
		~ifc_fieldEnumerator();

	public:
		const wchar_t *GetField();
		uint32_t GetKey();
		int Next();

		DISPATCH_CODES
		{
			DISP_GETFIELD = 0,
			DISP_GETKEY   = 1,
			DISP_NEXT     = 2,
		};

	};

	enum
	{
		ENUMERATORFLAG_MULTIPLE_FIELDS         = 0, // if multiple values of the same field are present, return each one
		ENUMERATORFLAG_REMOVE_DUPLICATE_FIELDS = 1, // don't enumerate duplicate fields (with differing values)
	};

	ifc_fieldEnumerator *GetFieldEnumerator( int flags = ENUMERATORFLAG_MULTIPLE_FIELDS ); // Enumerate fields present in this file

	DISPATCH_CODES
	{
		DISP_GETFIELD             = 0,
		DISP_GETFIELDKEY          = 1,
		DISP_GETINDEXEDFIELD      = 2,
		DISP_GETINDEXEDFIELDBYKEY = 3,
		DISP_GETFIELDENUMERATOR   = 4,
	};

	enum
	{
		NOT_IMPLEMENTED = -1,
		SUCCESS         = 0,
		FAILURE         = 1,
		END_OF_ITERATOR = 2,
	};
};

inline int ifc_metadataReader::GetField(const wchar_t *field, wchar_t *destination, size_t destinationCch)
{
	return _call(DISP_GETFIELD, (int)ifc_metadataReader::NOT_IMPLEMENTED, field, destination, destinationCch);
}

inline int ifc_metadataReader::GetFieldByKey(uint32_t field_key, wchar_t *destination, size_t destinationCch)
{
	return _call(DISP_GETFIELDKEY, (int)ifc_metadataReader::NOT_IMPLEMENTED, field_key, destination, destinationCch);
}

inline int ifc_metadataReader::GetIndexedField(const wchar_t *field, uint32_t index, wchar_t *destination, size_t destinationCch)
{
	return _call(DISP_GETINDEXEDFIELD, (int)ifc_metadataReader::NOT_IMPLEMENTED, field, index, destination, destinationCch);
}

inline int ifc_metadataReader::GetIndexedFieldByKey(uint32_t field_key, uint32_t index, wchar_t *destination, size_t destinationCch)
{
	return _call(DISP_GETINDEXEDFIELDBYKEY, (int)ifc_metadataReader::NOT_IMPLEMENTED, field_key, index, destination, destinationCch);
}

inline ifc_metadataReader::ifc_fieldEnumerator *ifc_metadataReader::GetFieldEnumerator(int flags)
{
	return _call(DISP_GETFIELDENUMERATOR, (ifc_metadataReader::ifc_fieldEnumerator *)0, flags);
}

inline const wchar_t *ifc_metadataReader::ifc_fieldEnumerator::GetField()
{
	return _call(DISP_NEXT, (const wchar_t *)0);
}

inline uint32_t ifc_metadataReader::ifc_fieldEnumerator::GetKey()
{
	return _call(DISP_NEXT, (int)ifc_metadataReader::NOT_IMPLEMENTED);
}

inline int ifc_metadataReader::ifc_fieldEnumerator::Next()
{
	return _call(DISP_NEXT, (int)END_OF_ITERATOR);
}
#endif