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"
79 explicit ConstString(
const char *cstr,
size_t max_cstr_len);
95 explicit operator bool()
const {
return !
IsEmpty(); }
131 if (
m_string ==
nullptr && rhs !=
nullptr)
133 if (
m_string !=
nullptr && rhs ==
nullptr)
164 bool operator!=(
const char *rhs)
const {
return !(*
this == rhs); }
172 explicit operator std::string_view()
const {
177 explicit operator std::string()
const {
return GetString(); }
188 const char *
AsCString(
const char *value_if_empty =
nullptr)
const {
253 const bool case_sensitive =
true);
277 const bool case_sensitive =
true);
291 void Dump(
Stream *s,
const char *value_if_empty =
nullptr)
const;
410 template <
typename T,
typename Enable>
friend struct ::llvm::DenseMapInfo;
429 llvm::StringRef Options);
437 DenseMapInfo<const char *>::getEmptyKey());
441 DenseMapInfo<const char *>::getTombstoneKey());
444 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.
std::string GetString() const
Get the string value as a std::string.
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 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 SetString(llvm::StringRef s)
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 Mangled &obj)
raw_ostream & operator<<(raw_ostream &os, lldb_private::ConstString s)
size_t GetBytesUnused() const
size_t GetBytesTotal() const
size_t GetBytesUsed() const
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)