35 #include "eng3d/utils.hpp"
59 operator std::string()
const {
79 std::copy(str.begin(), str.end(), std::back_inserter(
strings));
99 template<
typename ... Args>
101 #pragma clang diagnostic push
102 #pragma clang diagnostic ignored "-Wformat-security"
103 int size_s = std::snprintf(
nullptr, 0, format.data(), std::forward<decltype(args)>(args)...) + 1;
105 CXX_THROW(std::runtime_error,
"Error during formatting");
106 size_t size =
static_cast<size_t>(size_s);
107 std::unique_ptr<char[]> buf = std::make_unique<char[]>(size);
108 std::snprintf(buf.get(), size, format.data(), args ...);
109 return std::string(buf.get(), buf.get() + size - 1);
110 #pragma clang diagnostic pop
116 void from_file(
const std::string& filename);
117 std::string
translate(
const std::string_view str);
127 template<
typename ... Args>
The string pool manager (singleton), used mainly for translation purpouses. But also helps to reduce ...
const std::string_view get_by_id(const Eng3D::StringRef ref) const
static StringManager & get_instance()
StringManager(Eng3D::State &_s)
std::vector< char > strings
Eng3D::StringRef insert(const std::string &str)
void from_file(const std::string &filename)
std::string translate(const std::string_view str)
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
A reference to a string on the global string pool.
constexpr bool operator==(const StringRef &) const noexcept=default
const char * c_str() const
constexpr auto operator<=>(const StringRef &) const noexcept=default
constexpr StringRef()=default
const std::string_view get_string() const
constexpr StringRef(size_t _id)
StringRef & operator=(const std::string &rhs)
#define CXX_THROW(class,...)