Elaztek Developer Hub
Blamite Game Engine - Strings  00390.07.02.23.1947.blamite
A library containing general purpose utilities and classes for use in multiple projects.
strings.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <map>
5 #include <vector>
6 
7 #define STRING_TEXT(string_id) BlamStrings::Resources::Strings::LookupString(string_id)
8 #define ERROR_TEXT(error_code) BlamStrings::Resources::Strings::LookupErrorString(error_code)
9 
10 #ifdef STRINGS_EXPORTS
11 #define STRINGS_API __declspec(dllexport)
12 #else
13 #define STRINGS_API __declspec(dllimport)
14 #endif
15 
20 {
22 };
23 
30 {
31  std::string id;
32  std::string value;
33 };
34 
39 {
40 public:
41  std::string id;
42  std::string text;
43 
44  std::vector<BlamStringAttribute> attributes;
45 
53  bool HasAttribute(std::string id);
54 
64  std::string GetAttribute(std::string id);
65 };
66 
71 {
79  STRINGS_API bool LoadCommonStrings(std::string base_dir);
80 
88  STRINGS_API bool LoadStrings(std::string file_path);
89 
97  STRINGS_API bool LoadErrorStrings(std::string file_path);
98 
106  STRINGS_API std::string LookupString(std::string id);
107 
116  STRINGS_API std::string LookupErrorString(int error_code);
117 
123  STRINGS_API std::map<std::string, BlamEngineString>* GetUniversalStrings();
124 
130  STRINGS_API std::map<int, BlamEngineString*>* GetErrorStrings();
131 
139  STRINGS_API bool StringExists(std::string id);
140 
148  STRINGS_API bool ErrorStringExists(int error_code);
149 }
logger.h
BlamStrings::Utils::String::ParseStringFromXMLValue
STRINGS_API std::string ParseStringFromXMLValue(std::string string)
Performs a number of modifications and tweaks to a string.
Definition: string.cpp:322
BlamStrings::Resources::Strings::ErrorStringExists
STRINGS_API bool ErrorStringExists(int error_code)
Looks through the list of loaded error strings to see if a given error string has been loaded.
Definition: strings.cpp:265
BlamStrings::Converters::StringToInt
STRINGS_API int StringToInt(std::string string)
Converts a string representation of an integer to an int.
Definition: converters.cpp:127
string.h
BlamStrings::Resources::Strings::GetUniversalStrings
STRINGS_API std::map< std::string, BlamEngineString > * GetUniversalStrings()
Retrieves the list of all loaded strings.
Definition: strings.cpp:241
BlamStrings::Logger::LogEvent
STRINGS_API void LogEvent(BlamBasicLogMessage message)
Logs an event to the logger.
Definition: logger.cpp:41
BlamStrings::Resources::Strings::LoadCommonStrings
STRINGS_API bool LoadCommonStrings(std::string base_dir)
Loads the string tables editor_strings, error_strings, shared_strings, and config_strings.
Definition: strings.cpp:117
BlamStrings::Resources::Strings
Namespace containing functions for Blamite string resources.
Definition: strings.h:70
LoadStringListFromFile
std::vector< BlamEngineString > LoadStringListFromFile(std::string file_path)
Parses a list of strings from a file.
Definition: strings.cpp:76
en_US
@ en_US
Definition: strings.h:21
STRINGS_API
#define STRINGS_API
Definition: strings.h:13
BlamStrings::Resources::Strings::StringExists
STRINGS_API bool StringExists(std::string id)
Looks through the list of loaded engine strings to see if a given string has been loaded.
Definition: strings.cpp:251
universal_string_list
std::map< std::string, BlamEngineString > universal_string_list
Definition: strings.cpp:13
rapidxml::xml_attribute
Class representing attribute node of XML document.
Definition: rapidxml.hpp:138
BlamStringAttribute::value
std::string value
The attribute value.
Definition: strings.h:32
error_strings
std::map< int, BlamEngineString * > error_strings
Map containing a list of all error strings.
Definition: strings.cpp:14
rapidxml::xml_node::first_node
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets first child node, optionally matching node name.
Definition: rapidxml.hpp:936
BlamStrings::Resources::Strings::LookupErrorString
STRINGS_API std::string LookupErrorString(int error_code)
Finds a string message associated with a given error code.
Definition: strings.cpp:227
BlamEngineString::text
std::string text
The content of the string.
Definition: strings.h:42
BlamStrings::Resources::Strings::LoadStrings
STRINGS_API bool LoadStrings(std::string file_path)
Loads all strings in the given file into the universal string list.
Definition: strings.cpp:129
BlamStringAttribute
Structure representing a Blamite string attribute.
Definition: strings.h:29
BlamLogLevel::Error
@ Error
Indicates an error that could cause engine instability.
BlamEngineString::attributes
std::vector< BlamStringAttribute > attributes
The list of attributes present within the string.
Definition: strings.h:44
BlamEngineString::HasAttribute
bool HasAttribute(std::string id)
Checks whether the string has a given attribute.
Definition: BlamEngineString.cpp:3
res.h
strings.h
ParseString
BlamEngineString ParseString(rapidxml::xml_node<> *string_node)
Parses an XML node into a BlamEngineString.
Definition: strings.cpp:23
rapidxml::xml_document
This class represents root of the DOM hierarchy.
Definition: rapidxml.hpp:139
BlamStrings::Utils::IO::FileExists
STRINGS_API bool FileExists(std::string name)
Checks if the specified file or directory exists.
Definition: io.cpp:26
BlamEngineString
Class representing a Blamite string.
Definition: strings.h:38
rapidxml::xml_node
Class representing a node of XML document.
Definition: rapidxml.hpp:137
BlamStrings::Converters::StringToBool
STRINGS_API bool StringToBool(std::string string)
Converts a string to a boolean.
Definition: converters.cpp:60
BlamLanguage
BlamLanguage
Enum containing all supported languages within the engine.
Definition: strings.h:19
uuids::to_string
std::basic_string< CharT, Traits, Allocator > to_string(uuid const &id)
Definition: uuid.h:581
io.h
BlamEngineString::id
std::string id
The ID of the string.
Definition: strings.h:41
rapidxml::xml_attribute::next_attribute
xml_attribute< Ch > * next_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets next attribute, optionally matching attribute name.
Definition: rapidxml.hpp:856
converters.h
BlamStrings::Resources::Strings::LookupString
STRINGS_API std::string LookupString(std::string id)
Finds a string with a given ID.
Definition: strings.cpp:213
rapidxml.hpp
BlamStringAttribute::id
std::string id
The attribute ID.
Definition: strings.h:31
rapidxml::xml_node::first_attribute
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets first attribute of node, optionally matching attribute name.
Definition: rapidxml.hpp:1025
BlamStrings::Resources::Strings::LoadErrorStrings
STRINGS_API bool LoadErrorStrings(std::string file_path)
Loads all strings in the given file as error description strings.
Definition: strings.cpp:159
BlamLogLevel::Warning
@ Warning
Indicates a warning message. Not something critical, but something that could cause unexpected behavi...
BlamEngineString::GetAttribute
std::string GetAttribute(std::string id)
Retrieves the value of a given attribute.
Definition: BlamEngineString.cpp:16
BlamStrings::Resources::Strings::GetErrorStrings
STRINGS_API std::map< int, BlamEngineString * > * GetErrorStrings()
Retrieves the list of all loaded error code strings.
Definition: strings.cpp:246
rapidxml::xml_document::parse
void parse(Ch *text)
Parses zero-terminated XML string according to given flags.
Definition: rapidxml.hpp:1381
rapidxml::xml_node::next_sibling
xml_node< Ch > * next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Gets next sibling node, optionally matching node name.
Definition: rapidxml.hpp:1004