CSndHandler.h 1.5 KB

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