BinaryData.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef LOTRO_DAT_BINARYDATA_H
  2. #define LOTRO_DAT_BINARYDATA_H
  3. #include <cstdio>
  4. #include <vector>
  5. #include <string>
  6. namespace LOTRO_DAT
  7. {
  8. class Database;
  9. class BinaryData
  10. {
  11. public:
  12. BinaryData();
  13. BinaryData(const BinaryData &d);
  14. BinaryData(BinaryData&& other) noexcept;
  15. BinaryData(const char* data, unsigned int size);
  16. explicit BinaryData(unsigned int size);
  17. ~BinaryData();
  18. unsigned char& operator[] (const unsigned int &pos);
  19. const unsigned char& operator[] (const unsigned int &pos) const;
  20. BinaryData operator +(const BinaryData &b);
  21. bool operator == (const BinaryData &b) const;
  22. bool operator != (const BinaryData &b) const;
  23. bool Empty() const;
  24. void Append(const BinaryData &b, size_t offset = 0);
  25. template <unsigned int T>
  26. long long ToNumber(const long long &pos) const;
  27. template <unsigned int T>
  28. long long ToNumberRAW(const long long &pos) const;
  29. template <unsigned int T>
  30. static BinaryData FromNumber(const long long &number);
  31. template <unsigned int T>
  32. static BinaryData FromNumberRAW(const long long &number);
  33. size_t size() const;
  34. unsigned char* data() const;
  35. BinaryData& operator=(const BinaryData& data);
  36. BinaryData CutData(long long first = 0, long long last = -1) const;
  37. bool WriteToFile(const char *filename) const;
  38. bool WriteToFile(const std::string &filename) const;
  39. void ReadFromFile(const char *filename);
  40. void ReadFromFile(const std::string &filename);
  41. private:
  42. unsigned char *data_;
  43. size_t size_;
  44. };
  45. } // namespace LOTRO_DAT
  46. #endif //LOTRO_DAT_BINARYDATA_H