aboutsummaryrefslogtreecommitdiff
path: root/include/openvic-dataloader/detail/SymbolIntern.hpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2024-07-06 21:10:34 +0200
committer GitHub <noreply@github.com>2024-07-06 21:10:34 +0200
commit161502024bd9f8b3c6dfef21d07f34730c7604a1 (patch)
tree376aa0c401ed72f61e74706fde4ceb367d7a4b41 /include/openvic-dataloader/detail/SymbolIntern.hpp
parent4a49007492152037bc1e9636b024cc67700e9dae (diff)
parent760523a45a348c26c87eb59657204f0e3cd90b26 (diff)
Merge pull request #51 from OpenVicProject/add/find_intern
Add find_intern to v2script Parser
Diffstat (limited to 'include/openvic-dataloader/detail/SymbolIntern.hpp')
-rw-r--r--include/openvic-dataloader/detail/SymbolIntern.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/openvic-dataloader/detail/SymbolIntern.hpp b/include/openvic-dataloader/detail/SymbolIntern.hpp
index d72a0ba..56576c5 100644
--- a/include/openvic-dataloader/detail/SymbolIntern.hpp
+++ b/include/openvic-dataloader/detail/SymbolIntern.hpp
@@ -173,6 +173,19 @@ namespace ovdl {
return success;
}
+ symbol find_intern(const CharT* str, std::size_t length) {
+ auto entry = _map.lookup_entry(typename traits::string_view { str, length }, traits { &_buffer });
+ if (entry)
+ return symbol(_buffer.c_str(entry.get()));
+
+ return symbol();
+ }
+ template<std::size_t N>
+ symbol find_intern(const CharT (&literal)[N]) {
+ DRYAD_PRECONDITION(literal[N - 1] == CharT(0));
+ return find_intern(literal, N - 1);
+ }
+
symbol intern(const CharT* str, std::size_t length) {
if (_map.should_rehash())
_map.rehash(_resource, traits { &_buffer });