BinaryData.h 1.9 KB

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