Base: Added helper macro for caching transcode-ed string literal

This commit is contained in:
Kohei Takahashi
2024-12-25 10:42:33 +09:00
parent 6e5b6e3ead
commit f032b44f44
5 changed files with 146 additions and 118 deletions

View File

@@ -174,6 +174,12 @@ inline XStr::~XStr()
XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fUnicodeForm);
}
#define XStrLiteral(literal) \
([]() -> const XStr& { \
static const XStr str {literal}; \
return str; \
}())
// -----------------------------------------------------------------------
// Getter methods
@@ -210,6 +216,11 @@ inline XUTF8Str::XUTF8Str(const char* const fromTranscode)
inline XUTF8Str::~XUTF8Str() = default;
#define XUTF8StrLiteral(literal) \
([]() -> const XUTF8Str& { \
static const XUTF8Str str {literal}; \
return str; \
}())
// -----------------------------------------------------------------------
// Getter methods