Go to the documentation of this file.
9 #ifndef LLDB_UTILITY_CONSTSTRING_H
10 #define LLDB_UTILITY_CONSTSTRING_H
12 #include "llvm/ADT/DenseMapInfo.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/FormatVariadic.h"
78 explicit ConstString(
const char *cstr,
size_t max_cstr_len);
91 bool operator()(
const char *lhs,
const char *rhs)
const {
110 explicit operator bool()
const {
return !
IsEmpty(); }
146 if (
m_string ==
nullptr && rhs !=
nullptr)
148 if (
m_string !=
nullptr && rhs ==
nullptr)
179 bool operator!=(
const char *rhs)
const {
return !(*
this == rhs); }
192 const char *
AsCString(
const char *value_if_empty =
nullptr)
const {
252 const bool case_sensitive =
true);
276 const bool case_sensitive =
true);
290 void Dump(
Stream *s,
const char *value_if_empty =
nullptr)
const;
325 void SetString(
const llvm::StringRef &s);
409 template <
typename T,
typename Enable>
friend struct ::llvm::DenseMapInfo;
428 llvm::StringRef Options);
436 DenseMapInfo<const char *>::getEmptyKey());
440 DenseMapInfo<const char *>::getTombstoneKey());
443 return DenseMapInfo<const char *>::getHashValue(val.
m_string);
458 #endif // LLDB_UTILITY_CONSTSTRING_H
size_t MemorySize() const
Get the memory cost of this object.
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
bool GetMangledCounterpart(ConstString &counterpart) const
Retrieve the mangled or demangled counterpart for a mangled or demangled ConstString.
static unsigned getHashValue(lldb_private::ConstString val)
bool IsNull() const
Test for null string.
void SetCString(const char *cstr)
Set the C string value.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
ConstString()=default
Default constructor.
bool operator==(const char *rhs) const
Equal to operator against a non-ConstString value.
static lldb_private::ConstString getEmptyKey()
bool operator!=(ConstString rhs) const
Not equal to operator.
void SetString(const llvm::StringRef &s)
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
bool IsEmpty() const
Test for empty string.
bool operator==(ConstString rhs) const
Equal to operator.
size_t GetBytesUnused() const
C string equality binary predicate function object for ConstString objects.
void SetCStringWithLength(const char *cstr, size_t cstr_len)
Set the C string value with length.
void SetTrimmedCStringWithLength(const char *cstr, size_t fixed_cstr_len)
Set the C string value with the minimum length between fixed_cstr_len and the actual length of the C ...
size_t GetLength() const
Get the length in bytes of string value.
void DumpDebug(Stream *s) const
Dump the object debug description to a stream.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
bool operator!=(const char *rhs) const
Not equal to operator against a non-ConstString value.
void Clear()
Clear this object's state.
size_t GetBytesUsed() const
bool operator<(ConstString rhs) const
static bool Equals(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Equal to operator.
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
bool operator()(const char *lhs, const char *rhs) const
C equality test.
static MemoryStats GetMemoryStats()
void SetStringWithMangledCounterpart(llvm::StringRef demangled, ConstString mangled)
Set the C string value and its mangled counterpart.
raw_ostream & operator<<(raw_ostream &os, lldb_private::ConstString s)
const char * GetCString() const
Get the string value as a C string.
A class that represents a running process on the host machine.
static ConstString FromStringPoolPointer(const char *ptr)
Only used by DenseMapInfo.
static lldb_private::ConstString getTombstoneKey()
static bool isEqual(lldb_private::ConstString LHS, lldb_private::ConstString RHS)
size_t GetBytesTotal() const