API Documentation
Loading...
Searching...
No Matches
TranslatedString.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/String.h>
4#include <NDEVR/Dictionary.h>
5namespace NDEVR
6{
7 class TranslatedString;
8 /**--------------------------------------------------------------------------------------------------
9 \brief Any text displayed to the user should be defined as a TranslatedString which allows the
10 program to look up a translation, if available.
11 **/
13 {
14 public:
17 {
18 for (auto& iter : m_replacements)
19 delete iter.second;
20 }
23 NDEVR_BASE_API explicit TranslatedString(const char* const raw_string);
24 NDEVR_BASE_API explicit TranslatedString(const String& raw_string);
25 NDEVR_BASE_API TranslatedString(const String& translation_id, const String& english);
28 NDEVR_BASE_API String translation(const String& translation_id) const;
30 NDEVR_BASE_API TranslatedString& replace(const String& sub_string, const TranslatedString& replacement);
31 NDEVR_BASE_API TranslatedString& replace(const String& sub_string, const String& replacement);
34 NDEVR_BASE_API bool isEmpty() const;
41 NDEVR_BASE_API bool operator<(const TranslatedString& value) const;
42 NDEVR_BASE_API bool operator>(const TranslatedString& value) const;
43 protected:
45 //operator+=()
46 protected:
51 mutable bool m_is_translated;
52 };
53 template<class t_type>
55 {
58 return s;
59 }
61}
62
63namespace std//Define things to allow use within std libs
64{
65 template <>
66 struct hash<NDEVR::TranslatedString>
67 {
68 std::size_t operator()(const NDEVR::TranslatedString& s) const noexcept
69 {
70 return static_cast<size_t>(s.translationID().hash());
71 }
72 };
73};
#define NDEVR_BASE_API
Definition DLLInfo.h:57
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
The core String class for the NDEVR API.
Definition String.h:69
static TranslatedString DisplayString(const t_type &value)
Converts an object into a TranslatedString. To use this function an object must have overwritten Stri...
Definition TranslatedString.h:54
static void toDisplayString(const t_type &value, TranslatedString &string)
Logic for converting an object to an NDEVR API translated, user facing string. This allows the object...
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
TranslatedString & operator=(TranslatedString &&translation) noexcept
TranslatedString & replace(const String &sub_string, const TranslatedString &replacement)
bool operator==(const TranslatedString &translation) const
TranslatedString(const String &raw_string)
bool operator!=(const TranslatedString &translation) const
~TranslatedString()
Definition TranslatedString.h:16
String m_translation_id
Definition TranslatedString.h:48
TranslatedString(const TranslatedString &translation)
String translation(const String &translation_id) const
TranslatedString(const char *const raw_string)
String m_translation
Definition TranslatedString.h:50
bool isTranslatable() const
bool m_is_translated
Definition TranslatedString.h:51
TranslatedString(TranslatedString &&translation) noexcept
const String & translationID() const
TranslatedString(const String &translation_id, const String &english)
TranslatedString & operator=(const TranslatedString &translation) noexcept
const String & translation() const
bool operator>(const TranslatedString &value) const
TranslatedString & replace(const String &sub_string, const String &replacement)
Dictionary< String, TranslatedString * > m_replacements
Definition TranslatedString.h:47
const String & englishTranslation() const
bool operator<(const TranslatedString &value) const
String internalValue() const
bool hasReplacements() const
String m_english_string
Definition TranslatedString.h:49
Definition ACIColor.h:37
Definition File.h:211
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233