avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::Dictionary::AvStringPtr Struct Reference

RAII holder for strings allocated by FFmpeg internals. More...

#include <dictionary.h>

Inheritance diagram for av::Dictionary::AvStringPtr:

Public Types

using base_class = std::unique_ptr<char, AvStringDeleter>
 The unique_ptr instantiation this holder builds on.

Public Member Functions

char * c_str () const noexcept
 Access to the holded string with std::string interface.
size_t length () const noexcept
 RAW string length in bytes.
char & operator[] (size_t index) const noexcept
 Array-like char access.

Detailed Description

Member Function Documentation

◆ c_str()

char * av::Dictionary::AvStringPtr::c_str ( ) const
inlinenoexcept
Returns
holded raw string pointer, or nullptr if string is not allocated

◆ length()

size_t av::Dictionary::AvStringPtr::length ( ) const
inlinenoexcept
Note
to avoid extra size and keeps sizeof(AvStringPtr) == sizeof(char*) we do not cache and holds string size. As a result string length calculates every call and complexity is O(n), where n - count of bytes in string exclude end zero.

8-bit based multibyte string like UTF-8 must be processes with appropriate libraries externally.

Returns
calculated length of string in bytes

◆ operator[]()

char & av::Dictionary::AvStringPtr::operator[] ( size_t index) const
inlinenoexcept

This call avoid any checks. When index is greater then length() behavior undefined.

Parameters
indexchar index to access
Returns
char reference to read/modify.

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