7#ifndef CORE_FXCRT_STRING_TEMPLATE_H_
8#define CORE_FXCRT_STRING_TEMPLATE_H_
14#include "core/fxcrt/compiler_specific.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxcrt/span.h"
17#include "core/fxcrt/string_data_template.h"
18#include "core/fxcrt/string_view_template.h"
40 bool IsEmpty()
const {
return !GetLength(); }
64 : EmptyString(
static_cast<
CharType*>(
nullptr));
70 return m_pData ? m_pData->span() : pdfium::span<
const CharType>();
76 return reinterpret_span<
const UnsignedType>(span());
87 EmptyString(
static_cast<
CharType*>(
nullptr)), 1u));
96 return reinterpret_span<
const UnsignedType>(span_with_terminator());
164 return Find(str, start).has_value();
167 return Find(ch, start).has_value();
174 void SetAt(size_t index, T ch);
201 void AssignCopy(
const T* pSrcData, size_t nSrcLen);
202 void Concat(
const T* pSrcData, size_t nSrcLen);
207extern template class StringTemplate<
char>;
208extern template class StringTemplate<
wchar_t>;
uint32_t FX_HashCode_GetLoweredAsIfW(ByteStringView str)
fxcrt::ByteString ByteString
uint32_t FX_HashCode_GetLoweredA(ByteStringView str)
uint32_t FX_HashCode_GetAsIfW(ByteStringView str)
uint32_t FX_HashCode_GetA(ByteStringView str)
ByteString(const char *ptr)
bool EqualNoCase(ByteStringView str) const
static ByteString Format(const char *pFormat,...)
ByteString & operator+=(const ByteString &str)
bool operator!=(ByteStringView str) const
ByteString Substr(size_t first, size_t count) const
bool operator==(ByteStringView str) const
intptr_t ReferenceCountForTesting() const
ByteString & operator+=(char ch)
ByteString(ByteStringView bstrc)
static ByteString FormatInteger(int i)
bool operator==(const ByteString &other) const
bool operator==(const char *ptr) const
UNSAFE_BUFFER_USAGE ByteString(const char *pStr, size_t len)
bool operator<(ByteStringView str) const
ByteString(wchar_t)=delete
ByteString & operator+=(const char *str)
ByteString & operator+=(ByteStringView str)
UNSAFE_BUFFER_USAGE ByteString(const uint8_t *pStr, size_t len)
bool operator!=(const ByteString &other) const
ByteString & operator=(ByteStringView str)
ByteString(ByteStringView str1, ByteStringView str2)
ByteString & operator=(const char *str)
void TrimWhitespaceFront()
static ByteString FormatV(const char *pFormat, va_list argList)
ByteString Substr(size_t offset) const
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
ByteString(ByteString &&other) noexcept=default
bool operator<(const ByteString &other) const
ByteString(const std::initializer_list< ByteStringView > &list)
bool operator!=(const char *ptr) const
int Compare(ByteStringView str) const
ByteString(const ByteString &other)=default
ByteString(const fxcrt::ostringstream &outStream)
ByteString First(size_t count) const
void TrimWhitespaceBack()
bool operator<(const char *ptr) const
ByteString Last(size_t count) const
pdfium::span< T > GetBuffer(size_t nMinBufLength)
size_t Delete(size_t index, size_t count=1)
const_iterator begin() const
void AllocBeforeWrite(size_t nNewLen)
pdfium::span< const UnsignedType > unsigned_span_with_terminator() const
size_t Replace(StringView oldstr, StringView newstr)
StringTemplate(const StringTemplate &other)=default
pdfium::span< const CharType > span_with_terminator() const
~StringTemplate()=default
StringView AsStringView() const
void ReleaseBuffer(size_t nNewLength)
CharType operator[](const size_t index) const
pdfium::span< const UnsignedType > unsigned_span() const
StringDataTemplate< T > StringData
std::optional< size_t > ReverseFind(T ch) const
StringViewTemplate< T > StringView
void AssignCopy(const T *pSrcData, size_t nSrcLen)
RetainPtr< StringData > m_pData
std::optional< size_t > Find(StringView str, size_t start=0) const
void SetAt(size_t index, T ch)
const_reverse_iterator rbegin() const
const_iterator end() const
bool IsValidIndex(size_t index) const
bool Contains(T ch, size_t start=0) const
typename std::make_unsigned< CharType >::type UnsignedType
void TrimBack(StringView targets)
void Trim(StringView targets)
StringTemplate(StringTemplate &&other) noexcept=default
std::reverse_iterator< const_iterator > const_reverse_iterator
bool Contains(StringView str, size_t start=0) const
void Concat(const T *pSrcData, size_t nSrcLen)
size_t InsertAtFront(T ch)
size_t InsertAtBack(T ch)
std::optional< size_t > Find(T ch, size_t start=0) const
pdfium::span< const CharType > span() const
const UnsignedType * unsigned_str() const
bool IsValidLength(size_t length) const
size_t GetStringLength() const
void ReallocBeforeWrite(size_t nNewLen)
void TrimFront(StringView targets)
size_t Insert(size_t index, T ch)
const_reverse_iterator rend() const
const CharType * c_str() const
#define UNSAFE_BUFFERS(...)
#define UNSAFE_BUFFER_USAGE
CRYPT_md5_context CRYPT_MD5Start()
TEST(FXCRYPT, CryptToBase16)
TEST(FXCRYPT, MD5GenerateEmtpyData)
std::string CryptToBase16(const uint8_t *digest)
bool operator==(const char *lhs, const ByteString &rhs)
bool operator<(const ByteStringView &lhs, const char *rhs)
ByteString operator+(const ByteString &str1, const ByteString &str2)
ByteString operator+(ByteStringView str1, const char *str2)
bool operator<(const ByteStringView &lhs, const ByteString &rhs)
ByteString operator+(const ByteString &str1, char ch)
ByteString operator+(const ByteString &str1, const char *str2)
void PrintTo(const ByteString &str, std::ostream *os)
ByteString operator+(char ch, const ByteString &str2)
ByteString operator+(const ByteString &str1, ByteStringView str2)
ByteString operator+(const char *str1, const ByteString &str2)
constexpr const wchar_t * EmptyString(wchar_t *)
StringViewTemplate< char > ByteStringView
bool operator!=(ByteStringView lhs, const ByteString &rhs)
bool operator!=(const char *lhs, const ByteString &rhs)
ByteString operator+(ByteStringView str1, ByteStringView str2)
ByteString operator+(ByteStringView str1, char ch)
constexpr const char * EmptyString(char *)
bool operator<(const char *lhs, const ByteString &rhs)
ByteString operator+(char ch, ByteStringView str2)
ByteString operator+(ByteStringView str1, const ByteString &str2)
ByteString operator+(const char *str1, ByteStringView str2)
bool operator==(ByteStringView lhs, const ByteString &rhs)
fxcrt::ByteStringView ByteStringView
size_t operator()(const ByteString &str) const