summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-10-12 11:17:11 +0200
committerStephan Bergmann <sbergman@redhat.com>2023-10-12 18:17:49 +0200
commitdcea29c283680c8e75e4890f46b1624d0a55846f (patch)
tree1ca0e41d8d00f27d3b8d3dec5d99a6c2e5aebb91 /include
parent6056a0e320f0aabbde7adb28c42e00ed72ef2e5b (diff)
Make NC_ constexpr-friendly
...by moving the char8_t -> char reinterpret_cast out of any potential constexpr paths into a new TranslateId::getId. And demonstrate constexpr'ability by making the aCategories var in OApplicationIconControl::Fill (dbaccess/source/ui/app/AppIconControl.cxx) constexpr. (And there might be more such cases that could now be made constexpr.) Change-Id: I0b4e3292faf8f6b901f9b9e934e1aa6bf0f583ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157862 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/editeng/editrids.hrc2
-rw-r--r--include/fpicker/strings.hrc2
-rw-r--r--include/sfx2/strings.hrc2
-rw-r--r--include/svl/svl.hrc2
-rw-r--r--include/svtools/strings.hrc2
-rw-r--r--include/svx/strings.hrc2
-rw-r--r--include/svx/svxitems.hrc2
-rw-r--r--include/unotools/resmgr.hxx8
8 files changed, 13 insertions, 9 deletions
diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc
index 582c1f71fa61..9cbe225d730e 100644
--- a/include/editeng/editrids.hrc
+++ b/include/editeng/editrids.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC
#define INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
// enum SvxBreak ------------------------------------------------------------
#define RID_SVXITEMS_BREAK_NONE NC_("RID_SVXITEMS_BREAK_NONE", "No break")
diff --git a/include/fpicker/strings.hrc b/include/fpicker/strings.hrc
index efce3a69f9da..5ff2a07a0c0b 100644
--- a/include/fpicker/strings.hrc
+++ b/include/fpicker/strings.hrc
@@ -9,7 +9,7 @@
#ifndef INCLUDED_FPICKER_FPICKER_HRC
#define INCLUDED_FPICKER_FPICKER_HRC
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
#define STR_SVT_FILEPICKER_AUTO_EXTENSION NC_("STR_SVT_FILEPICKER_AUTO_EXTENSION", "~Automatic file name extension")
#define STR_SVT_FILEPICKER_PASSWORD NC_("STR_SVT_FILEPICKER_PASSWORD", "Save with pass~word")
diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 82257b7efc03..451012131537 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SFX2_INC_STRINGS_HRC
#define INCLUDED_SFX2_INC_STRINGS_HRC
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
#define STR_TEMPLATE_FILTER NC_("STR_TEMPLATE_FILTER", "Templates")
#define STR_SAVEDOC NC_("STR_SAVEDOC", "~Save")
diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc
index 205227377ff3..d4210e90764a 100644
--- a/include/svl/svl.hrc
+++ b/include/svl/svl.hrc
@@ -19,7 +19,7 @@
#ifndef INCLUDED_SVL_SVL_HRC
#define INCLUDED_SVL_SVL_HRC
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
// Internet Media Type Presentations
diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc
index 645b19b86567..3aa1e9770d66 100644
--- a/include/svtools/strings.hrc
+++ b/include/svtools/strings.hrc
@@ -19,7 +19,7 @@
#pragma once
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
// To translators: tdf#125447 use no mnemonic in this string
#define STR_UNDO NC_("STR_UNDO", "Undo: ")
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index b4a04c3a2c60..8dc2aa04639e 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -20,7 +20,7 @@
#ifndef INCLUDED_SVX_INC_STRINGS_HRC
#define INCLUDED_SVX_INC_STRINGS_HRC
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
#define STR_ObjNameSingulNONE NC_("STR_ObjNameSingulNONE", "Drawing object")
#define STR_ObjNamePluralNONE NC_("STR_ObjNamePluralNONE", "Drawing objects")
diff --git a/include/svx/svxitems.hrc b/include/svx/svxitems.hrc
index d42194497144..af1e5aa3375b 100644
--- a/include/svx/svxitems.hrc
+++ b/include/svx/svxitems.hrc
@@ -27,7 +27,7 @@
#include <unotools/resmgr.hxx>
#include <utility>
-#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+#define NC_(Context, String) TranslateId(Context, u8##String)
const std::pair<TranslateId, sal_uInt16> RID_ATTR_NAMES[] =
{
diff --git a/include/unotools/resmgr.hxx b/include/unotools/resmgr.hxx
index 142ec2de5b1f..816f4fadf71b 100644
--- a/include/unotools/resmgr.hxx
+++ b/include/unotools/resmgr.hxx
@@ -31,13 +31,17 @@ typedef OUString (*ResHookProc)(const OUString& rStr);
struct UNOTOOLS_DLLPUBLIC TranslateId
{
const char* mpContext;
- const char* mpId;
+ const char8_t* mpId;
inline constexpr TranslateId()
: mpContext(nullptr), mpId(nullptr) {}
- inline constexpr TranslateId(const char* pContext, const char* pId)
+ inline TranslateId(const char* pContext, const char* pId)
+ : mpContext(pContext), mpId(reinterpret_cast<char8_t const *>(pId)) {}
+ inline constexpr TranslateId(const char* pContext, const char8_t* pId)
: mpContext(pContext), mpId(pId) {}
+ char const * getId() const { return reinterpret_cast<char const *>(mpId); }
+
inline operator bool() const { return mpId != nullptr; }
bool operator==(const TranslateId& other) const;