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;
9 {
10 public:
13 {
14 for (auto& iter : m_replacements)
15 delete iter.second;
16 }
19 NDEVR_BASE_API explicit TranslatedString(const char* const raw_string);
20 NDEVR_BASE_API explicit TranslatedString(const String& raw_string);
21 NDEVR_BASE_API TranslatedString(const String& translation_id, const String& english);
23 NDEVR_BASE_API const String& translation() const;
24 NDEVR_BASE_API String translation(const String& translation_id) const;
25 NDEVR_BASE_API const String& translationID() const;
26 NDEVR_BASE_API TranslatedString& replace(const String& sub_string, const TranslatedString& replacement);
27 NDEVR_BASE_API TranslatedString& replace(const String& sub_string, const String& replacement);
28 NDEVR_BASE_API bool isTranslatable() const;
30 NDEVR_BASE_API bool isEmpty() const;
37 NDEVR_BASE_API bool operator<(const TranslatedString& value) const;
38 NDEVR_BASE_API bool operator>(const TranslatedString& value) const;
39 protected:
41 //operator+=()
42 protected:
47 mutable bool m_is_translated;
48 };
49 template<class t_type>
51 {
54 return s;
55 }
57}
58
59namespace std//Define things to allow use within std libs
60{
61 template <>
62 struct hash<NDEVR::TranslatedString>
63 {
64 std::size_t operator()(const NDEVR::TranslatedString& s) const noexcept
65 {
66 return static_cast<size_t>(s.translationID().hash());
67 }
68 };
69};
#define NDEVR_BASE_API
Definition DLLInfo.h:78
Definition Dictionary.h:48
Definition String.h:40
static TranslatedString DisplayString(const t_type &value)
Definition TranslatedString.h:50
static void toDisplayString(const t_type &value, TranslatedString &string)
Definition TranslatedString.h:9
NDEVR_BASE_API TranslatedString & operator=(TranslatedString &&translation) noexcept
Definition TranslatedString.cpp:182
NDEVR_BASE_API TranslatedString & replace(const String &sub_string, const TranslatedString &replacement)
Definition TranslatedString.cpp:51
NDEVR_BASE_API bool operator==(const TranslatedString &translation) const
Definition TranslatedString.cpp:235
NDEVR_BASE_API bool operator!=(const TranslatedString &translation) const
Definition TranslatedString.cpp:208
~TranslatedString()
Definition TranslatedString.h:12
String m_translation_id
Definition TranslatedString.h:44
String m_translation
Definition TranslatedString.h:46
NDEVR_BASE_API bool isTranslatable() const
Definition TranslatedString.cpp:58
bool m_is_translated
Definition TranslatedString.h:47
void calculateEnglishString()
Definition TranslatedString.cpp:75
NDEVR_BASE_API const String & translationID() const
Definition TranslatedString.cpp:134
NDEVR_BASE_API const String & translation() const
Definition TranslatedString.cpp:104
NDEVR_BASE_API bool operator>(const TranslatedString &value) const
Definition TranslatedString.cpp:231
Dictionary< String, TranslatedString * > m_replacements
Definition TranslatedString.h:43
NDEVR_BASE_API const String & englishTranslation() const
Definition TranslatedString.cpp:140
NDEVR_BASE_API TranslatedString()
Definition TranslatedString.cpp:5
NDEVR_BASE_API bool operator<(const TranslatedString &value) const
Definition TranslatedString.cpp:227
NDEVR_BASE_API bool isEmpty() const
Definition TranslatedString.cpp:67
NDEVR_BASE_API void retranslate()
Definition TranslatedString.cpp:47
NDEVR_BASE_API String internalValue() const
Definition TranslatedString.cpp:144
NDEVR_BASE_API bool hasReplacements() const
Definition TranslatedString.cpp:62
String m_english_string
Definition TranslatedString.h:45
Definition ACIColor.h:37
Definition File.h:213
Definition BaseValues.hpp:272
std::size_t operator()(const NDEVR::TranslatedString &s) const noexcept
Definition TranslatedString.h:64