Exiv2
Functions
helper_functions.cpp File Reference

A collection of helper functions. More...

#include "helper_functions.hpp"
#include <string.h>

Functions

std::string string_from_unterminated (const char *data, size_t data_length)
 Convert a (potentially not null terminated) array into a std::string. More...
 

Detailed Description

A collection of helper functions.

Author
Dan Čermák (D4N) dan.cermak@cgc-instruments.com
Date
25-May-18, D4N: created

Function Documentation

◆ string_from_unterminated()

std::string string_from_unterminated ( const char *  data,
size_t  data_length 
)

Convert a (potentially not null terminated) array into a std::string.

Convert a C style string that may or may not be null terminated safely into a std::string. The string's termination is either set at the first \0 or after data_length characters.

Parameters
[in]dataA c-string from which the std::string shall be constructed. Does not need to be null terminated.
[in]data_lengthAn upper bound for the string length (must be at most the allocated length of buffer). If no null terminator is found in data, then the resulting std::string will be null terminated at data_length.

References Exiv2::string.

Referenced by Exiv2::JpegBase::printStructure().