BinaryData.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Created by Иван_Архипов on 31.10.2017.
  3. //
  4. #ifndef LOTRO_DAT_PATCHER_BINARYDATA_H
  5. #define LOTRO_DAT_PATCHER_BINARYDATA_H
  6. #include <cstdio>
  7. #include <string>
  8. extern "C++"
  9. {
  10. namespace LOTRO_DAT
  11. {
  12. class Database;
  13. class BinaryData
  14. {
  15. public:
  16. BinaryData();
  17. BinaryData(const BinaryData &d);
  18. explicit BinaryData(unsigned int size);
  19. ~BinaryData();
  20. unsigned char& operator[] (const unsigned int &pos);
  21. BinaryData operator +(const BinaryData &b);
  22. template <int T>
  23. long long ToNumber(const long long &pos) const;
  24. template <int T>
  25. long long ToNumberRAW(const long long &pos) const;
  26. template <int T>
  27. void FromNumber(const long long &number);
  28. template <int T>
  29. void FromNumberRAW(const long long &number);
  30. size_t size() const;
  31. unsigned char* data() const;
  32. BinaryData& operator=(const BinaryData& data);
  33. BinaryData CutData(long long first = 0, long long last = -1) const;
  34. bool WriteToFile(const char *filename) const;
  35. bool WriteToFile(const std::string &filename) const;
  36. bool CheckCompression() const;
  37. BinaryData DecompressData(unsigned int offset = 0) const;
  38. BinaryData CompressData(unsigned int offset = 0) const;
  39. private:
  40. unsigned char *data_;
  41. size_t size_;
  42. };
  43. }
  44. }
  45. #endif //LOTRO_DAT_PATCHER_BINARYDATA_H