1
0

ifc_metadataReader.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef NULLSOFT_AGAVE_METADATA_IFC_METADATAREADER_H
  2. #define NULLSOFT_AGAVE_METADATA_IFC_METADATAREADER_H
  3. #include <bfc/dispatch.h>
  4. class ifc_metadataReader : public Dispatchable
  5. {
  6. protected:
  7. ifc_metadataReader()
  8. {}
  9. ~ifc_metadataReader()
  10. {}
  11. public:
  12. /* If there are multiple values for the same field, these functions will concatenate the values in some
  13. manner as defined by the language pack */
  14. int GetField( const wchar_t *field, wchar_t *destination, size_t destinationCch );
  15. int GetFieldByKey( uint32_t field_key, wchar_t *destination, size_t destinationCch );
  16. int GetIndexedField( const wchar_t *field, uint32_t index, wchar_t *destination, size_t destinationCch );
  17. int GetIndexedFieldByKey( uint32_t field_key, uint32_t index, wchar_t *destination, size_t destinationCch );
  18. class ifc_fieldEnumerator : public Dispatchable
  19. {
  20. protected:
  21. ifc_fieldEnumerator();
  22. ~ifc_fieldEnumerator();
  23. public:
  24. const wchar_t *GetField();
  25. uint32_t GetKey();
  26. int Next();
  27. DISPATCH_CODES
  28. {
  29. DISP_GETFIELD = 0,
  30. DISP_GETKEY = 1,
  31. DISP_NEXT = 2,
  32. };
  33. };
  34. enum
  35. {
  36. ENUMERATORFLAG_MULTIPLE_FIELDS = 0, // if multiple values of the same field are present, return each one
  37. ENUMERATORFLAG_REMOVE_DUPLICATE_FIELDS = 1, // don't enumerate duplicate fields (with differing values)
  38. };
  39. ifc_fieldEnumerator *GetFieldEnumerator( int flags = ENUMERATORFLAG_MULTIPLE_FIELDS ); // Enumerate fields present in this file
  40. DISPATCH_CODES
  41. {
  42. DISP_GETFIELD = 0,
  43. DISP_GETFIELDKEY = 1,
  44. DISP_GETINDEXEDFIELD = 2,
  45. DISP_GETINDEXEDFIELDBYKEY = 3,
  46. DISP_GETFIELDENUMERATOR = 4,
  47. };
  48. enum
  49. {
  50. NOT_IMPLEMENTED = -1,
  51. SUCCESS = 0,
  52. FAILURE = 1,
  53. END_OF_ITERATOR = 2,
  54. };
  55. };
  56. inline int ifc_metadataReader::GetField(const wchar_t *field, wchar_t *destination, size_t destinationCch)
  57. {
  58. return _call(DISP_GETFIELD, (int)ifc_metadataReader::NOT_IMPLEMENTED, field, destination, destinationCch);
  59. }
  60. inline int ifc_metadataReader::GetFieldByKey(uint32_t field_key, wchar_t *destination, size_t destinationCch)
  61. {
  62. return _call(DISP_GETFIELDKEY, (int)ifc_metadataReader::NOT_IMPLEMENTED, field_key, destination, destinationCch);
  63. }
  64. inline int ifc_metadataReader::GetIndexedField(const wchar_t *field, uint32_t index, wchar_t *destination, size_t destinationCch)
  65. {
  66. return _call(DISP_GETINDEXEDFIELD, (int)ifc_metadataReader::NOT_IMPLEMENTED, field, index, destination, destinationCch);
  67. }
  68. inline int ifc_metadataReader::GetIndexedFieldByKey(uint32_t field_key, uint32_t index, wchar_t *destination, size_t destinationCch)
  69. {
  70. return _call(DISP_GETINDEXEDFIELDBYKEY, (int)ifc_metadataReader::NOT_IMPLEMENTED, field_key, index, destination, destinationCch);
  71. }
  72. inline ifc_metadataReader::ifc_fieldEnumerator *ifc_metadataReader::GetFieldEnumerator(int flags)
  73. {
  74. return _call(DISP_GETFIELDENUMERATOR, (ifc_metadataReader::ifc_fieldEnumerator *)0, flags);
  75. }
  76. inline const wchar_t *ifc_metadataReader::ifc_fieldEnumerator::GetField()
  77. {
  78. return _call(DISP_NEXT, (const wchar_t *)0);
  79. }
  80. inline uint32_t ifc_metadataReader::ifc_fieldEnumerator::GetKey()
  81. {
  82. return _call(DISP_NEXT, (int)ifc_metadataReader::NOT_IMPLEMENTED);
  83. }
  84. inline int ifc_metadataReader::ifc_fieldEnumerator::Next()
  85. {
  86. return _call(DISP_NEXT, (int)END_OF_ITERATOR);
  87. }
  88. #endif