Refactor message_data for consistency in formatting

- Updated code style in message_data.cc and message_data.h for uniformity, specifically adjusting spacing around references and pointers.
- Improved readability by ensuring consistent use of `const` and reference qualifiers in function signatures.
- No functional changes were made; this commit focuses solely on code style enhancements.
This commit is contained in:
scawful
2025-09-26 22:49:14 -04:00
parent 575dc55487
commit 9b295d5d75
2 changed files with 46 additions and 44 deletions

View File

@@ -1,8 +1,10 @@
#ifndef YAZE_APP_EDITOR_MESSAGE_MESSAGE_DATA_H
#define YAZE_APP_EDITOR_MESSAGE_MESSAGE_DATA_H
#include <optional>
#include <regex>
#include <string>
#include <unordered_map>
#include <vector>
#include "absl/strings/str_format.h"
@@ -80,7 +82,7 @@ constexpr uint8_t kLine1 = 0x74;
constexpr uint8_t kLine2 = 0x75;
constexpr uint8_t kLine3 = 0x76;
std::vector<DictionaryEntry> BuildDictionaryEntries(Rom *rom);
std::vector<DictionaryEntry> BuildDictionaryEntries(Rom* rom);
std::string ReplaceAllDictionaryWords(std::string str,
std::vector<DictionaryEntry> dictionary);
DictionaryEntry FindRealDictionaryEntry(
@@ -98,10 +100,10 @@ struct MessageData {
std::vector<uint8_t> DataParsed;
MessageData() = default;
MessageData(int id, int address, const std::string &rawString,
const std::vector<uint8_t> &rawData,
const std::string &parsedString,
const std::vector<uint8_t> &parsedData)
MessageData(int id, int address, const std::string& rawString,
const std::vector<uint8_t>& rawData,
const std::string& parsedString,
const std::vector<uint8_t>& parsedData)
: ID(id),
Address(address),
RawString(rawString),
@@ -110,7 +112,7 @@ struct MessageData {
DataParsed(parsedData) {}
// Copy constructor
MessageData(const MessageData &other) {
MessageData(const MessageData& other) {
ID = other.ID;
Address = other.Address;
RawString = other.RawString;
@@ -121,10 +123,10 @@ struct MessageData {
std::string OptimizeMessageForDictionary(
std::string_view message_string,
const std::vector<DictionaryEntry> &dictionary) {
const std::vector<DictionaryEntry>& dictionary) {
std::stringstream protons;
bool command = false;
for (const auto &c : message_string) {
for (const auto& c : message_string) {
if (c == '[') {
command = true;
} else if (c == ']') {
@@ -146,8 +148,8 @@ struct MessageData {
return final_string;
}
void SetMessage(const std::string &message,
const std::vector<DictionaryEntry> &dictionary) {
void SetMessage(const std::string& message,
const std::vector<DictionaryEntry>& dictionary) {
RawString = message;
ContentsParsed = OptimizeMessageForDictionary(message, dictionary);
}
@@ -163,8 +165,8 @@ struct TextElement {
bool HasArgument;
TextElement() = default;
TextElement(uint8_t id, const std::string &token, bool arg,
const std::string &description) {
TextElement(uint8_t id, const std::string& token, bool arg,
const std::string& description) {
ID = id;
Token = token;
if (arg) {
@@ -203,7 +205,7 @@ struct TextElement {
bool Empty() const { return ID == 0; }
// Comparison operator
bool operator==(const TextElement &other) const { return ID == other.ID; }
bool operator==(const TextElement& other) const { return ID == other.ID; }
};
const static std::string kWindowBorder = "Window border";
@@ -288,32 +290,32 @@ struct ParsedElement {
bool Active = false;
ParsedElement() = default;
ParsedElement(const TextElement &textElement, uint8_t value)
ParsedElement(const TextElement& textElement, uint8_t value)
: Parent(textElement), Value(value), Active(true) {}
};
ParsedElement FindMatchingElement(const std::string &str);
ParsedElement FindMatchingElement(const std::string& str);
std::string ParseTextDataByte(uint8_t value);
absl::StatusOr<MessageData> ParseSingleMessage(
const std::vector<uint8_t> &rom_data, int *current_pos);
const std::vector<uint8_t>& rom_data, int* current_pos);
std::vector<std::string> ParseMessageData(
std::vector<MessageData> &message_data,
const std::vector<DictionaryEntry> &dictionary_entries);
std::vector<MessageData>& message_data,
const std::vector<DictionaryEntry>& dictionary_entries);
constexpr int kTextData2 = 0x75F40;
constexpr int kTextData2End = 0x773FF;
// Reads all text data from the ROM and returns a vector of MessageData objects.
std::vector<MessageData> ReadAllTextData(uint8_t *rom, int pos = kTextData);
std::vector<MessageData> ReadAllTextData(uint8_t* rom, int pos = kTextData);
// Calls the file dialog and loads expanded messages from a BIN file.
absl::Status LoadExpandedMessages(std::string &expanded_message_path,
std::vector<std::string> &parsed_messages,
std::vector<MessageData> &expanded_messages,
std::vector<DictionaryEntry> &dictionary);
absl::Status LoadExpandedMessages(std::string& expanded_message_path,
std::vector<std::string>& parsed_messages,
std::vector<MessageData>& expanded_messages,
std::vector<DictionaryEntry>& dictionary);
} // namespace editor
} // namespace yaze