16#ifndef WPIUTIL_WPI_STRINGMAPENTRY_H
17#define WPIUTIL_WPI_STRINGMAPENTRY_H
41 template <
typename AllocatorTy>
47template <
typename AllocatorTy>
50 AllocatorTy &Allocator) {
51 size_t KeyLength = Key.size();
55 size_t AllocSize = EntrySize + KeyLength + 1;
56 void *Allocation = Allocator.Allocate(AllocSize, EntryAlign);
57 assert(Allocation &&
"Unhandled out-of-memory");
60 char *Buffer =
reinterpret_cast<char *
>(Allocation) + EntrySize;
62 ::memcpy(Buffer, Key.data(), KeyLength);
63 Buffer[KeyLength] = 0;
72template <
typename ValueTy>
79 template <
typename... InitTy>
82 second(
std::forward<InitTy>(initVals)...) {}
95 std::nullopt_t = std::nullopt)
99 std::nullopt_t
getValue()
const {
return std::nullopt; }
105template <
typename ValueTy>
120 return reinterpret_cast<const char *
>(
this + 1);
129 template <
typename AllocatorTy,
typename... InitTy>
131 InitTy &&... initVals) {
146 template <
typename AllocatorTy>
void Destroy(AllocatorTy &allocator) {
150 allocator.Deallocate(
static_cast<void *
>(
this), AllocSize,
156template <std::
size_t Index,
typename ValueTy>
158 static_assert(Index < 2);
159 if constexpr (Index == 0)
168template <
typename ValueTy>
169struct tuple_size<
wpi::StringMapEntry<ValueTy>>
170 : std::integral_constant<std::size_t, 2> {};
172template <std::
size_t I,
typename ValueTy>
173struct tuple_element<I,
wpi::StringMapEntry<ValueTy>>
174 : std::conditional<I == 0, std::string_view, ValueTy> {};
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
StringMapEntryBase - Shared base class of StringMapEntry instances.
Definition: StringMapEntry.h:29
static void * allocateWithKey(size_t EntrySize, size_t EntryAlign, std::string_view Key, AllocatorTy &Allocator)
Helper to tail-allocate Key.
Definition: StringMapEntry.h:48
StringMapEntryBase(size_t keyLength)
Definition: StringMapEntry.h:33
size_t getKeyLength() const
Definition: StringMapEntry.h:35
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:106
static StringMapEntry & GetStringMapEntryFromKeyData(const char *keyData)
GetStringMapEntryFromKeyData - Given key data that is known to be embedded into a StringMapEntry,...
Definition: StringMapEntry.h:139
std::string_view first() const
Definition: StringMapEntry.h:123
ValueTy ValueType
Definition: StringMapEntry.h:110
static StringMapEntry * create(std::string_view key, AllocatorTy &allocator, InitTy &&... initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
Definition: StringMapEntry.h:130
const char * getKeyData() const
getKeyData - Return the start of the string data that is the key for this value.
Definition: StringMapEntry.h:119
std::string_view getKey() const
Definition: StringMapEntry.h:112
void Destroy(AllocatorTy &allocator)
Destroy - Destroy this StringMapEntry, releasing memory back to the specified allocator.
Definition: StringMapEntry.h:146
std::nullopt_t getValue() const
Definition: StringMapEntry.h:99
StringMapEntryStorage(size_t keyLength, std::nullopt_t=std::nullopt)
Definition: StringMapEntry.h:94
StringMapEntryStorage(StringMapEntryStorage &entry)=delete
StringMapEntryStorage - Holds the value in a StringMapEntry.
Definition: StringMapEntry.h:73
StringMapEntryStorage(size_t keyLength)
Definition: StringMapEntry.h:77
const ValueTy & getValue() const
Definition: StringMapEntry.h:85
StringMapEntryStorage(size_t keyLength, InitTy &&...initVals)
Definition: StringMapEntry.h:80
void setValue(const ValueTy &V)
Definition: StringMapEntry.h:88
ValueTy & getValue()
Definition: StringMapEntry.h:86
StringMapEntryStorage(StringMapEntryStorage &e)=delete
ValueTy second
Definition: StringMapEntry.h:75
basic_string_view< char > string_view
Definition: core.h:501
static constexpr const charge::coulomb_t e(1.6021766208e-19)
elementary charge.
Definition: ntcore_cpp.h:26
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
Definition: PointerIntPair.h:270