coastline 0.0.4
Loading...
Searching...
No Matches
stringresources.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <filesystem>
5#include <map>
6#include <set>
7#include <span>
8#include <string>
9#include <string_view>
10
11#include "language.h"
12
13namespace coastline {
14
23
30void AppendUtf8(std::string &text, char32_t c);
31
40char32_t NextCodePoint(std::string_view text, std::size_t &position);
41
48class GameText {
49public:
56 GameText(const std::filesystem::path &assets, std::string language);
60 GameText(const GameText &) = delete;
62 GameText &operator=(const GameText &) = delete;
63
65 static GameText *Active();
67 const std::string &Language() const {
68 return m_language;
69 }
70
71 bool Empty() const {
72 return m_strings.empty();
73 }
74
84
85private:
86 std::string m_language;
87 StringTable m_strings;
89};
90
96
103
104} // namespace coastline
GameText & operator=(const GameText &)=delete
Prevent assignment of the registered catalogue.
static GameText * Active()
~GameText()
Unregister the active catalogue and invalidate references to its strings.
const std::string * Find(std::string_view key) const
const std::string & Language() const
Definition stringresources.h:67
bool Empty() const
Definition stringresources.h:71
std::string_view Resolve(std::string_view key)
GameText(const std::filesystem::path &assets, std::string language)
Load strings and register the exclusive active catalogue with SDL.
GameText(const GameText &)=delete
Prevent copying the registered catalogue.
UTF-8 strings, language-specific fonts, and the selected cartridge assets.
Definition assetimport.h:11
char32_t NextCodePoint(std::string_view text, std::size_t &position)
Decode the code point of UTF-8 text at a position, and step past it.
std::string_view GameString(std::string_view key)
const std::string * FindString(std::string_view key)
std::map< unsigned, std::string > ReadLibraryStrings(std::span< const std::uint8_t > image)
Read the string resources of a Windows library.
std::map< std::string, std::string, std::less<> > StringTable
Strings by key, in UTF-8.
Definition language.h:23
void AppendUtf8(std::string &text, char32_t c)
Append a code point to UTF-8 text.