Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::LaunchText Class Reference

Immutable owning launch text with allocation-free empty, copy and move operations. Nonempty construction copies bytes into shared immutable storage and may throw std::bad_alloc. Default construction retains no string object, including on MSVC Debug. Views/pointers remain valid while any copy retaining the same storage remains alive. More...

#include <ui_app.hpp>

Public Member Functions

 LaunchText () noexcept=default
 Create empty text without allocating.
 LaunchText (std::string_view bytes)
 LaunchText (const std::string &bytes)
 LaunchText (const char *bytes)
 LaunchText (const LaunchText &other) noexcept=default
 LaunchText (LaunchText &&other) noexcept=default
LaunchText & operator= (const LaunchText &other) noexcept=default
LaunchText & operator= (LaunchText &&other) noexcept=default
const char * data () const noexcept
std::size_t size () const noexcept
bool empty () const noexcept
std::string_view view () const noexcept
std::size_t find (std::string_view text, std::size_t position=0) const noexcept

Friends

bool operator== (const LaunchText &left, const LaunchText &right) noexcept
bool operator== (const LaunchText &left, std::string_view right) noexcept
bool operator== (const LaunchText &left, const std::string &right) noexcept
bool operator== (const LaunchText &left, const char *right) noexcept
std::ostream & operator<< (std::ostream &stream, const LaunchText &text)

Detailed Description

Immutable owning launch text with allocation-free empty, copy and move operations. Nonempty construction copies bytes into shared immutable storage and may throw std::bad_alloc. Default construction retains no string object, including on MSVC Debug. Views/pointers remain valid while any copy retaining the same storage remains alive.

Constructor & Destructor Documentation

◆ LaunchText() [1/5]

portals::ui::LaunchText::LaunchText ( std::string_view bytes)
inline
Parameters
bytesBytes borrowed only during this owning copy; empty text allocates nothing.
Exceptions
std::bad_allocIf nonempty storage cannot be allocated.

◆ LaunchText() [2/5]

portals::ui::LaunchText::LaunchText ( const std::string & bytes)
inline
Parameters
bytesBorrowed string, including rvalues; bytes are copied without invoking a string move.
Exceptions
std::bad_allocIf nonempty storage cannot be allocated.

◆ LaunchText() [3/5]

portals::ui::LaunchText::LaunchText ( const char * bytes)
inline
Parameters
bytesNUL-terminated text borrowed only during copying; nullptr denotes empty text.
Exceptions
std::bad_allocIf nonempty storage cannot be allocated.

◆ LaunchText() [4/5]

portals::ui::LaunchText::LaunchText ( const LaunchText & other)
defaultnoexcept
Parameters
otherImmutable text whose ownership is shared without allocation.

◆ LaunchText() [5/5]

portals::ui::LaunchText::LaunchText ( LaunchText && other)
defaultnoexcept
Parameters
otherText whose storage is transferred; the source becomes empty.

Member Function Documentation

◆ data()

const char * portals::ui::LaunchText::data ( ) const
inlinenoexcept
Returns
Read-only NUL-terminated bytes; empty text returns a static empty buffer.

◆ empty()

bool portals::ui::LaunchText::empty ( ) const
inlinenoexcept
Returns
True when the owning text has no bytes.

◆ find()

std::size_t portals::ui::LaunchText::find ( std::string_view text,
std::size_t position = 0 ) const
inlinenoexcept
Parameters
textBorrowed bytes to find.
positionFirst byte position to inspect.
Returns
Matching byte position, or std::string_view::npos; no allocation occurs.

◆ operator=() [1/2]

LaunchText & portals::ui::LaunchText::operator= ( const LaunchText & other)
defaultnoexcept
Parameters
otherImmutable text whose ownership replaces this value without allocation.
Returns
This owning text after sharing the storage.

◆ operator=() [2/2]

LaunchText & portals::ui::LaunchText::operator= ( LaunchText && other)
defaultnoexcept
Parameters
otherText whose storage is transferred; the source becomes empty.
Returns
This owning text after transferring the storage.

◆ size()

std::size_t portals::ui::LaunchText::size ( ) const
inlinenoexcept
Returns
Number of owned bytes, excluding the trailing NUL.

◆ view()

std::string_view portals::ui::LaunchText::view ( ) const
inlinenoexcept
Returns
Borrowed read-only view, retained by this value or another copy sharing its storage.

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const LaunchText & text )
friend
Parameters
streamBorrowed output stream.
textImmutable owning text to write.
Returns
The same output stream after writing the complete byte view.

◆ operator== [1/4]

bool operator== ( const LaunchText & left,
const char * right )
friend
Parameters
leftOwning immutable text.
rightNUL-terminated bytes to compare; nullptr denotes empty text.
Returns
True for equal bytes, without allocating.

◆ operator== [2/4]

bool operator== ( const LaunchText & left,
const LaunchText & right )
friend
Parameters
leftOwning immutable text.
rightOwning immutable text to compare by byte value.
Returns
True for equal bytes, independently of storage identity.

◆ operator== [3/4]

bool operator== ( const LaunchText & left,
const std::string & right )
friend
Parameters
leftOwning immutable text.
rightBorrowed string to compare.
Returns
True for equal bytes, without constructing another owning value.

◆ operator== [4/4]

bool operator== ( const LaunchText & left,
std::string_view right )
friend
Parameters
leftOwning immutable text.
rightBorrowed bytes to compare.
Returns
True for equal bytes, without allocating.

The documentation for this class was generated from the following file: