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); }
195 const char *
AsCString(
const char *value_if_empty =
nullptr)
const {
255 const bool case_sensitive =
true);
279 const bool case_sensitive =
true);
293 void Dump(
Stream *s,
const char *value_if_empty =
nullptr)
const;
328 void SetString(
const llvm::StringRef &s);
412 template <
typename T,
typename Enable>
friend struct ::llvm::DenseMapInfo;
431 llvm::StringRef Options);
439 DenseMapInfo<const char *>::getEmptyKey());
443 DenseMapInfo<const char *>::getTombstoneKey());
446 return DenseMapInfo<const char *>::getHashValue(val.
m_string);
A uniqued constant string class.
bool GetMangledCounterpart(ConstString &counterpart) const
Retrieve the mangled or demangled counterpart for a mangled or demangled ConstString.
size_t MemorySize() const
Get the memory cost of this object.
static MemoryStats GetMemoryStats()
bool IsNull() const
Test for null string.
void SetCStringWithLength(const char *cstr, size_t cstr_len)
Set the C string value with length.
void SetCString(const char *cstr)
Set the C string value.
static int Compare(ConstString lhs, ConstString rhs, const bool case_sensitive=true)
Compare two string objects.
ConstString()=default
Default constructor.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
void SetString(const llvm::StringRef &s)
void DumpDebug(Stream *s) const
Dump the object debug description to a stream.
bool IsEmpty() const
Test for empty string.
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 ...
bool operator==(const char *rhs) const
Equal to operator against a non-ConstString value.
bool operator==(ConstString rhs) const
Equal to operator.
size_t GetLength() const
Get the length in bytes of string value.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void Clear()
Clear this object's state.
bool operator!=(ConstString rhs) const
Not equal to operator.
bool operator<(ConstString rhs) const
static ConstString FromStringPoolPointer(const char *ptr)
Only used by DenseMapInfo.
const char * GetCString() const
Get the string value as a C string.
bool operator!=(const char *rhs) const
Not equal to operator against a non-ConstString value.
void SetStringWithMangledCounterpart(llvm::StringRef demangled, ConstString mangled)
Set the C string value and its mangled counterpart.
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
raw_ostream & operator<<(raw_ostream &os, lldb_private::ConstString s)
size_t GetBytesUnused() const
size_t GetBytesTotal() const
size_t GetBytesUsed() const
C string equality binary predicate function object for ConstString objects.
bool operator()(const char *lhs, const char *rhs) const
C equality test.
static lldb_private::ConstString getEmptyKey()
static unsigned getHashValue(lldb_private::ConstString val)
static lldb_private::ConstString getTombstoneKey()
static bool isEqual(lldb_private::ConstString LHS, lldb_private::ConstString RHS)