CSndHandler.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. const char *data;
  50. };
  51. std::vector<boost::iostreams::mapped_file_source *> mfiles;
  52. boost::iostreams::mapped_file_source *add_file(std::string fname, bool important = true); //if not important, then we don't print warning when the file is missing
  53. public:
  54. std::vector<Entry> entries;
  55. std::map<std::string, int> fimap; // map of file and index
  56. ~CMediaHandler(); //d-tor
  57. void extract(std::string srcfile, std::string dstfile, bool caseSens=true); //saves selected file
  58. const char * extract (std::string srcfile, int & size); //return selecte file data, NULL if file doesn't exist
  59. void extract(int index, std::string dstfile); //saves selected file
  60. MemberFile getFile(std::string name);//nie testowane - sprawdzic
  61. const char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
  62. };
  63. class CSndHandler: public CMediaHandler
  64. {
  65. public:
  66. void add_file(std::string fname, bool important = true); //if not important, then we don't print warning when the file is missing
  67. };
  68. class CVidHandler: public CMediaHandler
  69. {
  70. public:
  71. void add_file(std::string fname);
  72. };
  73. #endif // __CSNDHANDLER_H__