avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Public Types | Public Member Functions | List of all members
av::Dictionary::AvStringPtr Struct Reference

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

#include <dictionary.h>

Inheritance diagram for av::Dictionary::AvStringPtr:
Inheritance graph
[legend]
Collaboration diagram for av::Dictionary::AvStringPtr:
Collaboration graph
[legend]

Public Types

using base_class = std::unique_ptr< char, AvStringDeleter >
 

Public Member Functions

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

Detailed Description

RAII holder for strings allocated by FFmpeg internals.

Member Typedef Documentation

◆ base_class

Member Function Documentation

◆ c_str()

char* av::Dictionary::AvStringPtr::c_str ( ) const
inlinenoexcept

Access to the holded string with std::string interface.

Returns
holded raw string pointer, or nullptr if string is not allocated

◆ length()

size_t av::Dictionary::AvStringPtr::length ( ) const
inlinenoexcept

RAW string length in bytes.

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

Array-like char access.

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: