removed second FixedString

This commit is contained in:
2026-06-19 02:03:17 +03:00
parent 58c082d399
commit 6a5771e57d
2 changed files with 21 additions and 31 deletions
+8 -25
View File
@@ -21,24 +21,6 @@
namespace omath::rev_eng namespace omath::rev_eng
{ {
template<std::size_t Length>
struct FixedString final
{
char data[Length]{};
// ReSharper disable once CppNonExplicitConvertingConstructor
constexpr FixedString(const char (&str)[Length]) noexcept // NOLINT(*-explicit-constructor)
{
std::ranges::copy_n(str, Length, data);
}
// ReSharper disable once CppNonExplicitConversionOperator
[[nodiscard("You forgot to use string")]]
constexpr operator std::string_view() const noexcept // NOLINT(*-explicit-constructor)
{
return {data, Length - 1};
}
};
template<std::size_t N>
FixedString(const char (&)[N]) -> FixedString<N>;
class InternalReverseEngineeredObject class InternalReverseEngineeredObject
{ {
@@ -78,14 +60,16 @@ namespace omath::rev_eng
return reinterpret_cast<MethodType>(const_cast<void*>(ptr))(this, arg_list...); return reinterpret_cast<MethodType>(const_cast<void*>(ptr))(this, arg_list...);
} }
template<FixedString ModuleName, FixedString Pattern, class ReturnType> template<PatternScanner::ConstevalPattern ModuleName, PatternScanner::ConstevalPattern Pattern,
class ReturnType>
ReturnType call_method(auto... arg_list) ReturnType call_method(auto... arg_list)
{ {
static const auto* address = resolve_pattern(ModuleName, Pattern); static const auto* address = resolve_pattern(ModuleName, Pattern);
return call_method<ReturnType>(address, arg_list...); return call_method<ReturnType>(address, arg_list...);
} }
template<FixedString ModuleName, FixedString Pattern, class ReturnType> template<PatternScanner::ConstevalPattern ModuleName, PatternScanner::ConstevalPattern Pattern,
class ReturnType>
ReturnType call_method(auto... arg_list) const ReturnType call_method(auto... arg_list) const
{ {
static const auto* address = resolve_pattern(ModuleName, Pattern); static const auto* address = resolve_pattern(ModuleName, Pattern);
@@ -100,7 +84,8 @@ namespace omath::rev_eng
} }
template<class ReturnType> template<class ReturnType>
ReturnType call_method(const std::string_view& module_name,const std::string_view& pattern, auto... arg_list) const ReturnType call_method(const std::string_view& module_name, const std::string_view& pattern,
auto... arg_list) const
{ {
static const auto* address = resolve_pattern(module_name, pattern); static const auto* address = resolve_pattern(module_name, pattern);
return call_method<ReturnType>(address, arg_list...); return call_method<ReturnType>(address, arg_list...);
@@ -121,8 +106,7 @@ namespace omath::rev_eng
template<std::ptrdiff_t TableOffset, std::size_t Id, class ReturnType> template<std::ptrdiff_t TableOffset, std::size_t Id, class ReturnType>
ReturnType call_virtual_method(auto... arg_list) ReturnType call_virtual_method(auto... arg_list)
{ {
auto sub_this = reinterpret_cast<void*>( auto sub_this = reinterpret_cast<void*>(reinterpret_cast<std::uintptr_t>(this) + TableOffset);
reinterpret_cast<std::uintptr_t>(this) + TableOffset);
const auto vtable = *reinterpret_cast<void***>(sub_this); const auto vtable = *reinterpret_cast<void***>(sub_this);
#ifdef _MSC_VER #ifdef _MSC_VER
using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...); using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
@@ -134,8 +118,7 @@ namespace omath::rev_eng
template<std::ptrdiff_t TableOffset, std::size_t Id, class ReturnType> template<std::ptrdiff_t TableOffset, std::size_t Id, class ReturnType>
ReturnType call_virtual_method(auto... arg_list) const ReturnType call_virtual_method(auto... arg_list) const
{ {
auto sub_this = reinterpret_cast<const void*>( auto sub_this = reinterpret_cast<const void*>(reinterpret_cast<std::uintptr_t>(this) + TableOffset);
reinterpret_cast<std::uintptr_t>(this) + TableOffset);
const auto vtable = *reinterpret_cast<void* const* const*>(sub_this); const auto vtable = *reinterpret_cast<void* const* const*>(sub_this);
#ifdef _MSC_VER #ifdef _MSC_VER
using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...); using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...);
+10 -3
View File
@@ -38,17 +38,24 @@ namespace omath
friend unit_test_pattern_scan_consteval_spacing_and_case_Test; friend unit_test_pattern_scan_consteval_spacing_and_case_Test;
public: public:
template<std::size_t N> template<std::size_t Length>
struct ConstevalPattern final struct ConstevalPattern final
{ {
char value[N]{}; char value[Length]{};
// ReSharper disable once CppNonExplicitConvertingConstructor // ReSharper disable once CppNonExplicitConvertingConstructor
constexpr ConstevalPattern(const char (&text)[N]) // NOLINT(*-explicit-constructor) constexpr ConstevalPattern(const char (&text)[Length]) // NOLINT(*-explicit-constructor)
{ {
std::ranges::copy(text, value); std::ranges::copy(text, value);
} }
[[nodiscard("You forgot to use string")]]
constexpr operator std::string_view() const noexcept // NOLINT(*-explicit-constructor)
{
return {value, Length - 1};
}
}; };
template<std::size_t N>
ConstevalPattern(const char (&)[N]) -> ConstevalPattern<N>;
[[nodiscard]] [[nodiscard]]
static std::span<std::byte>::iterator scan_for_pattern(const std::span<std::byte>& range, static std::span<std::byte>::iterator scan_for_pattern(const std::span<std::byte>& range,