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

The chunk class responsible for parsing the raw data of a PNG file. More...

#include <png.hpp>

Public Member Functions

 ChunkPtr ()
 
 ChunkPtr (const ChunkPtr &other)
 
std::size_t length () const
 Return the length of this parsed chunk data.
 
ChunkTag tag () const
 Return the chunk tag of this parsed data.
 
std::vector< std::uint8_t > data () const
 Return a copy of the data in this chunk.
 
std::uint32_t crc () const
 Return the CRC value of this chunk.
 
bool validate () const
 Calculate the CRC value of this chunk and validate it against the stored CRC value.
 
std::size_t chunk_size () const
 Return the size, in bytes, of the full chunk.
 
std::vector< std::uint8_t > chunk_data () const
 Return all data representing this chunk.
 
ChunkVec to_chunk_vec () const
 Convert this ChunkPtr into a ChunkVec object.
 

Static Public Member Functions

static ChunkPtr parse (const void *ptr, std::size_t size, std::size_t offset)
 Parse the given buffer for chunk data.
 
static ChunkPtr parse (const std::vector< std::uint8_t > &vec, std::size_t offset)
 Parse the given vector for chunk data.
 

Detailed Description

The chunk class responsible for parsing the raw data of a PNG file.

This should only be used when either parsing chunk data directly from the PNG file or writing said data back into the PNG file. It relies on data outside of itself to function, and it is therefore possible to crash your program if you're not careful with it.

Constructor & Destructor Documentation

◆ ChunkPtr() [1/2]

facade::png::ChunkPtr::ChunkPtr ( )
inline

◆ ChunkPtr() [2/2]

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

Member Function Documentation

◆ chunk_data()

std::vector< std::uint8_t > ChunkPtr::chunk_data ( ) const

Return all data representing this chunk.

This differs from facade::png::ChunkPtr::data by returning all data, including the length, the tag and the CRC.

◆ chunk_size()

std::size_t ChunkPtr::chunk_size ( ) const

Return the size, in bytes, of the full chunk.

This differs from facade::png::ChunkPtr::length by calculating the length of the full chunk (i.e., includes the length and the CRC), rather than just the chunk's data length.

◆ crc()

std::uint32_t ChunkPtr::crc ( ) const

Return the CRC value of this chunk.

Note that this does not calculate the CRC value– it merely returns the CRC value within the chunk.

◆ data()

std::vector< std::uint8_t > ChunkPtr::data ( ) const

Return a copy of the data in this chunk.

◆ length()

std::size_t ChunkPtr::length ( ) const

Return the length of this parsed chunk data.

◆ parse() [1/2]

ChunkPtr ChunkPtr::parse ( const std::vector< std::uint8_t > &  vec,
std::size_t  offset 
)
static

Parse the given vector for chunk data.

Parameters
vecThe vector to check for chunk data.
offsetThe offset to begin parsing.
Returns
A parsed chunk.
See also
facade::png::ChunkPtr::parse(const void *, std::size_t, std::size_t)

◆ parse() [2/2]

ChunkPtr ChunkPtr::parse ( const void *  ptr,
std::size_t  size,
std::size_t  offset 
)
static

Parse the given buffer for chunk data.

Parameters
ptrThe pointer to the raw PNG chunk data.
sizeThe size of the buffer to look at.
offsetThe offset in the buffer to begin looking for a chunk.
Returns
A parsed chunk.
Exceptions
facade::exception::NullPointer
facade::exception::NoData
facade::exception::OutOfBounds

◆ tag()

ChunkTag ChunkPtr::tag ( ) const

Return the chunk tag of this parsed data.

◆ to_chunk_vec()

ChunkVec ChunkPtr::to_chunk_vec ( ) const

Convert this ChunkPtr into a ChunkVec object.

◆ validate()

bool ChunkPtr::validate ( ) const

Calculate the CRC value of this chunk and validate it against the stored CRC value.

Returns
True if the CRC is valid, false otherwise.

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