3#include <twl/fs/fs_FileFormat.hpp>
4#include <twl/fmt/fmt_Common.hpp>
11 enum class Encoding : u8 {
18 static inline constexpr size_t GetCharacterSize(
const Encoding enc) {
20 case Encoding::CP1252: {
24 case Encoding::UTF16: {
25 return sizeof(char16_t);
27 case Encoding::UTF8: {
30 case Encoding::ShiftJIS: {
40 static inline constexpr bool IsValidEncoding(
const Encoding enc) {
41 return GetCharacterSize(enc) > 0;
60 static constexpr size_t OffsetSize =
sizeof(u32);
62 inline size_t GetAttributesSize() {
63 return this->entry_size - OffsetSize;
66 inline void SetAttributesSize(
const size_t size) {
67 this->entry_size = OffsetSize + size;
81 enum class MessageTokenType : u8 {
87 std::vector<u8> esc_data;
91 MessageTokenType type;
95 inline size_t GetByteLength(
const Encoding enc)
const {
97 case MessageTokenType::Escape: {
98 return GetCharacterSize(enc) + 1 + this->escape.esc_data.size();
100 case MessageTokenType::Text: {
101 return this->text.length() * GetCharacterSize(enc);
111 std::vector<MessageToken> msg;
112 std::vector<u8> attrs;
115 inline size_t GetByteLength(
const Encoding enc)
const {
116 size_t size = GetCharacterSize(enc);
117 for(
const auto &token: this->msg) {
118 size += token.GetByteLength(enc);
127 std::optional<MessageIdSection> msg_id;
128 std::vector<Message> messages;
134 inline bool HasMessageIds() {
135 return this->msg_id.has_value();
138 void CreateFrom(
const Encoding enc,
const bool has_message_ids,
const size_t attr_size,
const std::vector<Message> &msgs,
const u32 file_id);
Definition fs_File.hpp:232
Definition twl_Include.hpp:62
Definition fmt_BMG.hpp:71
Definition fmt_BMG.hpp:55
Definition fmt_BMG.hpp:86
Definition fmt_BMG.hpp:74
Definition fmt_BMG.hpp:90
Definition fmt_BMG.hpp:110
Definition fmt_Common.hpp:53
Definition fmt_Common.hpp:8