TextSubFile.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Created by Иван_Архипов on 24.11.2017.
  3. //
  4. #ifndef LOTRO_DAT_LIBRARY_TEXTSUBFILE_H
  5. #define LOTRO_DAT_LIBRARY_TEXTSUBFILE_H
  6. #include "SubFile.h"
  7. #include <vector>
  8. #include <unordered_map>
  9. namespace LOTRO_DAT {
  10. class TextSubFile : public SubFile {
  11. public:
  12. TextSubFile() = delete;
  13. explicit TextSubFile(const TextSubFile &other) = delete;
  14. SubFile &operator =(const TextSubFile &other) = delete;
  15. TextSubFile(DatFile &dat, long long dictionary_offset, long long fragments_count, long long unknown1,
  16. long long file_id, long long file_offset, long long file_size, long long timestamp,
  17. long long version, long long block_size);
  18. FILE_TYPE FileType() const override;
  19. std::string Extension() const override;
  20. SubfileData PrepareForExport(const BinaryData &file_data) override;
  21. BinaryData MakeForImport(const BinaryData &old_data, const SubfileData &data) override;
  22. private:
  23. std::vector<SubfileData> FileFragments;
  24. private:
  25. std::vector<std::u16string> MakePieces(const BinaryData &data, long long &offset);
  26. std::vector<long long> MakeArgumentReferences(const BinaryData &data, long long &offset);
  27. std::vector<std::vector<BinaryData>> MakeArgumentStrings(const BinaryData &data, long long &offset);
  28. std::unordered_map<long long, SubfileData> ParsePatchFragments(const SubfileData &data);
  29. BinaryData BuildPieces(const BinaryData &data, const SubfileData &new_data, long long &offset);
  30. BinaryData BuildArgumentReferences(const BinaryData &data, const SubfileData &new_data, long long &offset);
  31. BinaryData BuildArgumentStrings(const BinaryData &data, const SubfileData &new_data, long long &offset);
  32. BinaryData GetPieceData(const BinaryData &data, long long &offset) const;
  33. BinaryData GetArgumentReferenceData(const BinaryData &data, long long &offset) const;
  34. BinaryData GetArgumentStringsData(const BinaryData &data, long long &offset) const;
  35. };
  36. };
  37. #endif //LOTRO_DAT_LIBRARY_TEXTSUBFILE_H