libfacade 1.1
A library for manipulating PNG images with payloads.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
facade::png::Text Class Reference

A tEXt chunk object. More...

#include <png.hpp>

Inheritance diagram for facade::png::Text:
facade::png::ChunkVec

Public Member Functions

 Text ()
 
 Text (std::string keyword, std::string text)
 
 Text (const Text &other)
 
bool has_keyword () const
 Check if this tEXt chunk has a keyword set.
 
std::string keyword () const
 The keyword value, if present.
 
void set_keyword (std::string keyword, bool validate=true)
 Set the keyword of this tEXt chunk, with the option to validate the value given.
 
bool has_text () const
 Check if the given tEXt chunk has a text value.
 
std::string text () const
 Get the text data from this tEXt chunk.
 
void set_text (std::string text)
 Set the text data for this `tEXt chunk.
 
- Public Member Functions inherited from facade::png::ChunkVec
 ChunkVec (const ChunkTag tag)
 
 ChunkVec (const ChunkTag tag, const void *ptr, std::size_t size)
 
 ChunkVec (const ChunkTag tag, const std::vector< std::uint8_t > &data)
 
 ChunkVec (const ChunkVec &other)
 
bool operator== (const ChunkVec &other) const
 
std::size_t length () const
 Return the length of this chunk's data.
 
ChunkTagtag ()
 Return the chunk tag reference associated with this chunk.
 
const ChunkTagtag () const
 Return a const chunk tag reference associated with this chunk.
 
std::vector< std::uint8_t > & data ()
 Return the chunk data reference associated with this chunk.
 
const std::vector< std::uint8_t > & data () const
 Return const chunk data reference associated with this chunk.
 
void set_data (std::vector< std::uint8_t > &data)
 Set the chunk data for this chunk.
 
std::uint32_t crc () const
 Calculate the CRC value of this chunk.
 
std::pair< std::vector< std::uint8_t >, ChunkPtrto_chunk_ptr () const
 Convert this ChunkVec to a facade::png::ChunkPtr.
 
template<typename T >
T & upcast ()
 Create a reference to a higher-level ChunkVec object, such as facade::png::Header.
 
template<typename T >
const T & upcast () const
 Create a const reference to a higher-level ChunkVec object, such as facade::png::Header.
 
ChunkVecas_chunk_vec ()
 Interpret this ChunkVec derivative as a ChunkVec object.
 
const ChunkVecas_chunk_vec () const
 Interpret this ChunkVec derivative as a const ChunkVec object.
 

Protected Member Functions

std::optional< std::size_t > null_terminator () const
 Get the null terminator, if present, separating the keyword from the text value.
 
std::size_t text_offset () const
 Return the offset to the underlying text data.
 

Detailed Description

A tEXt chunk object.

Constructor & Destructor Documentation

◆ Text() [1/3]

facade::png::Text::Text ( )
inline

◆ Text() [2/3]

facade::png::Text::Text ( std::string  keyword,
std::string  text 
)
inline

◆ Text() [3/3]

facade::png::Text::Text ( const Text other)
inline

Member Function Documentation

◆ has_keyword()

bool Text::has_keyword ( ) const

Check if this tEXt chunk has a keyword set.

Returns
True if a keyword is present, false otherwise.

◆ has_text()

bool Text::has_text ( ) const

Check if the given tEXt chunk has a text value.

Returns
True if text data is present, false otherwise.

◆ keyword()

std::string Text::keyword ( ) const

The keyword value, if present.

Returns
A std::string representation of the keyword.
Exceptions
facade::exception::NoKeyword

◆ null_terminator()

std::optional< std::size_t > Text::null_terminator ( ) const
protected

Get the null terminator, if present, separating the keyword from the text value.

Returns
std::nullopt if no null terminator is present, the offset to the null terminator otherwise.

◆ set_keyword()

void Text::set_keyword ( std::string  keyword,
bool  validate = true 
)

Set the keyword of this tEXt chunk, with the option to validate the value given.

Parameters
keywordThe keyword string to set.
validateValidate with an exception if the keyword is too long. Default is true.
Exceptions
facade::exception::KeywordTooLong

◆ set_text()

void Text::set_text ( std::string  text)

Set the text data for this `tEXt chunk.

◆ text()

std::string Text::text ( ) const

Get the text data from this tEXt chunk.

◆ text_offset()

std::size_t Text::text_offset ( ) const
protected

Return the offset to the underlying text data.


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