ContentReader.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "Logger.h"
  3. #include "BinaryReader.h"
  4. #include "TypeReaderManager.h"
  5. // Parses an XNB file, calling into the appropriate TypeReader
  6. // helper to read whatever type(s) of object it contains.
  7. class ContentReader : public BinaryReader
  8. {
  9. public:
  10. ContentReader(FILE* file, TypeReaderManager* typeReaderManager);
  11. // Helper for printing out the file contents.
  12. Logger Log;
  13. // Parses the entire contents of an XNB file.
  14. void ReadXnb();
  15. // Reads a single polymorphic object from the current location.
  16. void ReadObject();
  17. // Reads either a raw value or polymorphic object, depending on whether the specified typeReader represents a value type.
  18. void ReadValueOrObject(TypeReader* typeReader);
  19. // Reads the typeId from the start of a polymorphic object, and looks up the appropriate TypeReader implementation.
  20. TypeReader* ReadTypeId();
  21. // Reads a typeId, and validates that it is the expected type.
  22. void ValidateTypeId(wstring const& expectedType);
  23. // Reads a shared resource ID, which indexes into the table of shared object instances that come after the primary asset.
  24. void ReadSharedResource();
  25. private:
  26. // Reads the XNB file header (version number, size, etc.).
  27. uint32_t ReadHeader();
  28. // Reads the manifest of what types are contained in this XNB file.
  29. void ReadTypeManifest();
  30. // Manager provides reader implementations for all supported data types.
  31. TypeReaderManager* typeReaderManager;
  32. // Table of the readers used by this particular .xnb file.
  33. vector<TypeReader*> typeReaders;
  34. };