neptools

Modding tools to Neptunia games
git clone https://git.neptards.moe/neptards/neptools.git
Log | Files | Refs | Submodules | README | LICENSE

pattern.hpp (591B)


      1 #ifndef UUID_741BE2A9_1F86_4DD5_A032_0D7D5CCBA762
      2 #define UUID_741BE2A9_1F86_4DD5_A032_0D7D5CCBA762
      3 #pragma once
      4 
      5 #include "utils.hpp"
      6 #include <libshit/except.hpp>
      7 #include <libshit/nonowning_string.hpp>
      8 
      9 namespace Neptools
     10 {
     11 
     12   struct Pattern
     13   {
     14     const Byte* pattern;
     15     const Byte* mask;
     16     size_t size;
     17 
     18     const Byte* MaybeFind(Libshit::StringView data) const noexcept;
     19 
     20     const Byte* Find(Libshit::StringView data) const
     21     {
     22       auto ret = MaybeFind(data);
     23       if (!ret) LIBSHIT_THROW(std::runtime_error, "Couldn't find pattern");
     24       return ret;
     25     }
     26   };
     27 
     28 }
     29 #endif