BinaryData.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(const char* data, unsigned int size);
  19. explicit BinaryData(unsigned int size);
  20. ~BinaryData();
  21. unsigned char& operator[] (const unsigned int &pos);
  22. BinaryData operator +(const BinaryData &b);
  23. bool operator == (const BinaryData &b) const;
  24. bool operator != (const BinaryData &b) const;
  25. bool Empty() const;
  26. void Append(const BinaryData &b, size_t offset = 0);
  27. template <unsigned int T>
  28. long long ToNumber(const long long &pos) const;
  29. template <unsigned int T>
  30. long long ToNumberRAW(const long long &pos) const;
  31. template <unsigned int T>
  32. static BinaryData FromNumber(const long long &number);
  33. template <unsigned int T>
  34. static BinaryData FromNumberRAW(const long long &number);
  35. size_t size() const;
  36. unsigned char* data() const;
  37. BinaryData& operator=(const BinaryData& data);
  38. BinaryData CutData(long long first = 0, long long last = -1) const;
  39. bool WriteToFile(const char *filename) const;
  40. bool WriteToFile(const std::string &filename) const;
  41. void ReadFromFile(const char *filename);
  42. void ReadFromFile(const std::string &filename);
  43. bool CheckCompression() const;
  44. BinaryData DecompressData(unsigned int offset = 0) const;
  45. BinaryData CompressData(unsigned int offset = 0) const;
  46. private:
  47. unsigned char *data_;
  48. size_t size_;
  49. };
  50. }
  51. }
  52. #endif //LOTRO_DAT_PATCHER_BINARYDATA_H