1.. _module-pw_string-api: 2 3============= 4API Reference 5============= 6.. pigweed-module-subpage:: 7 :name: pw_string 8 9-------- 10Overview 11-------- 12This module provides two types of strings and utility functions for working 13with strings. 14 15**pw::StringBuilder** 16 17.. doxygenfile:: pw_string/string_builder.h 18 :sections: briefdescription 19 20**pw::InlineString** 21 22.. doxygenfile:: pw_string/string.h 23 :sections: briefdescription 24 25**String utility functions** 26 27.. doxygenfile:: pw_string/util.h 28 :sections: briefdescription 29 30**UTF-8 Helpers** 31 32.. doxygenfile:: pw_string/utf_codecs.h 33 :sections: briefdescription 34 35----------------- 36pw::StringBuilder 37----------------- 38.. doxygenfile:: pw_string/string_builder.h 39 :sections: briefdescription 40.. doxygenclass:: pw::StringBuilder 41 :members: 42 43---------------- 44pw::InlineString 45---------------- 46.. doxygenfile:: pw_string/string.h 47 :sections: detaileddescription 48 49.. doxygenclass:: pw::InlineBasicString 50 :members: 51 52.. doxygentypedef:: pw::InlineString 53 54------------------------ 55String utility functions 56------------------------ 57 58pw::string::Assign() 59-------------------- 60.. doxygenfunction:: pw::string::Assign(InlineString<> &string, std::string_view view) 61 62pw::string::Append() 63-------------------- 64.. doxygenfunction:: pw::string::Append(InlineString<>& string, std::string_view view) 65 66pw::string::ClampedCString() 67---------------------------- 68.. doxygenfunction:: pw::string::ClampedCString(const char* str, size_t max_len) 69.. doxygenfunction:: pw::string::ClampedCString(span<const char> str) 70 71pw::string::Copy() 72------------------ 73.. doxygenfunction:: pw::string::Copy(const char* source, char* dest, size_t num) 74.. doxygenfunction:: pw::string::Copy(const char* source, Span&& dest) 75.. doxygenfunction:: pw::string::Copy(std::string_view source, Span&& dest) 76 77It also has variants that provide a destination of ``pw::Vector<char>`` 78(see :ref:`module-pw_containers` for details) that do not store the null 79terminator in the vector. 80 81.. cpp:function:: StatusWithSize Copy(std::string_view source, pw::Vector<char>& dest) 82.. cpp:function:: StatusWithSize Copy(const char* source, pw::Vector<char>& dest) 83 84pw::string::Format() 85-------------------- 86.. doxygenfile:: pw_string/format.h 87 :sections: detaileddescription 88 89.. doxygenfunction:: pw::string::Format(span<char> buffer, const char* format, ...) 90.. doxygenfunction:: pw::string::FormatVaList(span<char> buffer, const char* format, va_list args) 91.. doxygenfunction:: pw::string::Format(InlineString<>& string, const char* format, ...) 92.. doxygenfunction:: pw::string::FormatVaList(InlineString<>& string, const char* format, va_list args) 93.. doxygenfunction:: pw::string::FormatOverwrite(InlineString<>& string, const char* format, ...) 94.. doxygenfunction:: pw::string::FormatOverwriteVaList(InlineString<>& string, const char* format, va_list args) 95 96pw::string::NullTerminatedLength() 97---------------------------------- 98.. doxygenfunction:: pw::string::NullTerminatedLength(const char* str, size_t max_len) 99.. doxygenfunction:: pw::string::NullTerminatedLength(span<const char> str) 100 101pw::string::PrintableCopy() 102--------------------------- 103.. doxygenfunction:: pw::string::PrintableCopy(std::string_view source, span<char> dest) 104 105------------- 106UTF-8 Helpers 107------------- 108.. doxygenfile:: pw_string/utf_codecs.h 109 :sections: detaileddescription 110 111.. doxygenfunction:: pw::utf8::EncodeCodePoint(uint32_t code_point) 112.. doxygenfunction:: pw::utf8::WriteCodePoint(uint32_t code_point, pw::StringBuilder& output) 113.. doxygenfunction:: pw::utf8::ReadCodePoint(std::string_view str) 114