BinaryData.h 1.8 KB

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