CSndHandler.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __CSNDHANDLER_H__
  2. #define __CSNDHANDLER_H__
  3. #include <vector>
  4. #include <iosfwd>
  5. #include <map>
  6. #include <SDL_stdinc.h>
  7. /*
  8. * CSndHandler.h, part of VCMI engine
  9. *
  10. * Authors: listed in file AUTHORS in main folder
  11. *
  12. * License: GNU General Public License v2.0 or later
  13. * Full text of license available in license.txt file, in main folder
  14. *
  15. */
  16. namespace boost
  17. {
  18. namespace iostreams
  19. {
  20. class mapped_file_source;
  21. }
  22. }
  23. struct MemberFile
  24. {
  25. std::ifstream * ifs;
  26. int length;
  27. };
  28. // sound entry structure in catalog
  29. struct soundEntry
  30. {
  31. char filename[40];
  32. Uint32 offset; /* little endian */
  33. Uint32 size; /* little endian */
  34. };
  35. // video entry structure in catalog
  36. struct videoEntry
  37. {
  38. char filename[40];
  39. Uint32 offset; /* little endian */
  40. };
  41. class CMediaHandler
  42. {
  43. protected:
  44. struct Entry
  45. {
  46. std::string name;
  47. unsigned int size;
  48. unsigned int offset;
  49. };
  50. boost::iostreams::mapped_file_source *mfile;
  51. public:
  52. std::vector<Entry> entries;
  53. std::map<std::string, int> fimap; // map of file and index
  54. ~CMediaHandler(); //d-tor
  55. CMediaHandler(std::string fname); //c-tor
  56. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  57. const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
  58. void extract(int index, std::string dstfile); //saves selected file
  59. MemberFile getFile(std::string name);//nie testowane - sprawdzic
  60. const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
  61. };
  62. class CSndHandler: public CMediaHandler
  63. {
  64. public:
  65. CSndHandler(std::string fname);
  66. };
  67. class CVidHandler: public CMediaHandler
  68. {
  69. public:
  70. CVidHandler(std::string fname);
  71. };
  72. #endif // __CSNDHANDLER_H__