gphoto2pp
A C++ Wrapper for libgphoto2
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
gphoto2pp::CameraFileWrapper Class Reference

#include <camera_file_wrapper.hpp>

Public Member Functions

 CameraFileWrapper ()
 ~CameraFileWrapper ()
 CameraFileWrapper (CameraFileWrapper &&other)
CameraFileWrapperoperator= (CameraFileWrapper &&other)
 CameraFileWrapper (CameraFileWrapper const &other)
CameraFileWrapperoperator= (CameraFileWrapper const &other)
gphoto2::_CameraFile * getPtr () const
std::vector< char > getDataAndSize () const
 Gets the file's binary data in a std::string. This structure is acceptable for transportation of the camera file, as it has a size() method and c_str() to retrieve the relevant binary picture data.
void setDataAndSize (std::vector< char > const &file)
 Sets the camera file's binary data.
std::string getMimeType () const
 Gets the file's MIME type.
void setMimeType (std::string const &mimeType)
 Sets the file's MIME type.
std::string getFileName () const
 Gets the file's name.
void setFileName (std::string const &fileName)
 Sets the file's name.
void detectMimeType () const
 Detects the MIME type and updates the internal structures MIME type. If the MIME type is still unknown/unknown after this, then gphoto2 does not recognize the file type.
void adjustNameForMimeType ()
 Adjusts the file name to match the detected MIME type.
std::time_t getMtime () const
 Gets the timestamp of the file.
void setMtime (std::time_t mtime)
 Sets the timestamp of the file.
std::string getNameByType (std::string const &baseName, CameraFileTypeWrapper const &type) const
 Generates a file name using the file type, basename, and mime type.
void save (std::string const &filename) const
 Saves the current file to the current executing directory with the provided filename.

Detailed Description

A wrapper around the gphoto2 CameraFile struct.

Constructor & Destructor Documentation

gphoto2pp::CameraFileWrapper::CameraFileWrapper ( )
gphoto2pp::CameraFileWrapper::~CameraFileWrapper ( )
gphoto2pp::CameraFileWrapper::CameraFileWrapper ( CameraFileWrapper &&  other)
gphoto2pp::CameraFileWrapper::CameraFileWrapper ( CameraFileWrapper const &  other)
Note
this copy constructor does not actually copy the image, but rather makes a copy of this wrapper around the gphoto2 struct CameraFile.

Member Function Documentation

void gphoto2pp::CameraFileWrapper::adjustNameForMimeType ( )

Adjusts the file name to match the detected MIME type.

Recognized MIME Types:
  • RAW -> raw
  • JPEG -> jpg
  • PNG -> png
  • PPM -> ppm
  • PGM -> pgm
  • PNM -> pnm
  • TIFF -> tif
  • WAV -> wav
  • BMP -> bmp
  • AVI -> avi
  • CRW -> crw
  • CR2 -> cr2
Note
Direct wrapper for gp_file_adjust_name_for_mime_type(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraFileWrapper::detectMimeType ( ) const

Detects the MIME type and updates the internal structures MIME type. If the MIME type is still unknown/unknown after this, then gphoto2 does not recognize the file type.

Note
Direct wrapper for gp_file_detect_mime_type(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::vector< char > gphoto2pp::CameraFileWrapper::getDataAndSize ( ) const

Gets the file's binary data in a std::string. This structure is acceptable for transportation of the camera file, as it has a size() method and c_str() to retrieve the relevant binary picture data.

Returns
the picture
Note
Direct wrapper for gp_file_get_data_and_size(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::string gphoto2pp::CameraFileWrapper::getFileName ( ) const

Gets the file's name.

Returns
the file name
Note
Direct wrapper for gp_file_get_name(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::string gphoto2pp::CameraFileWrapper::getMimeType ( ) const

Gets the file's MIME type.

Returns
the mime type
Note
Direct wrapper for gp_file_get_mime_type(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::time_t gphoto2pp::CameraFileWrapper::getMtime ( ) const

Gets the timestamp of the file.

Note
Direct wrapper for gp_file_get_mtime(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
std::string gphoto2pp::CameraFileWrapper::getNameByType ( std::string const &  baseName,
CameraFileTypeWrapper const &  type 
) const

Generates a file name using the file type, basename, and mime type.

Parameters
[in]baseNamefor this file, which will appear after the file type and before the mime type
[in]typeof file that was captured (Image, Movie, Sound)
Note
Direct wrapper for gp_file_get_name_by_type(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
gphoto2::_CameraFile * gphoto2pp::CameraFileWrapper::getPtr ( ) const
CameraFileWrapper & gphoto2pp::CameraFileWrapper::operator= ( CameraFileWrapper &&  other)
CameraFileWrapper & gphoto2pp::CameraFileWrapper::operator= ( CameraFileWrapper const &  other)
Note
this copy assignments does not actually copy the image, but rather makes a copy of this wrapper around the gphoto2 struct CameraFile.
void gphoto2pp::CameraFileWrapper::save ( std::string const &  filename) const

Saves the current file to the current executing directory with the provided filename.

Parameters
[in]filenameto save as, ignoring any filename that may be set already
Note
Direct wrapper for gp_file_save(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraFileWrapper::setDataAndSize ( std::vector< char > const &  file)

Sets the camera file's binary data.

Parameters
[in]filewhich will be written into the gphoto2 CameraFile struct
Note
Direct wrapper for gp_file_set_data_and_size(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraFileWrapper::setFileName ( std::string const &  fileName)

Sets the file's name.

Parameters
[in]fileNameto set for this file
Note
Direct wrapper for gp_file_set_name(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraFileWrapper::setMimeType ( std::string const &  mimeType)

Sets the file's MIME type.

Parameters
[in]mimeTypeto set for this file
Note
Direct wrapper for gp_file_set_mime_type(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception
void gphoto2pp::CameraFileWrapper::setMtime ( std::time_t  mtime)

Sets the timestamp of the file.

Parameters
[in]mtimeto set for this file
Note
Direct wrapper for gp_file_set_mtime(...)
Exceptions
GPhoto2pp::exceptions::gphoto2_exception

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