EleFits  4.0.0
A modern C++ API on top of CFitsIO
List of all members
Euclid::Fits::Header Class Reference

#include <Header.h>

Class Description

Reader-writer for the header unit.

This class provides services to read and write records in the header units. Several groups of methods are available:

When reading or writing several records, it is recommended to use the Seq-suffixed methods (e.g. one call to writeSeq() instead of several calls to write()), which are optimized.

To write sequences of records, the following types are accepted, as well as their constant and reference counterparts:

For reading, the following return types are available:

Relying on VariantValue is the way to go when types are not all known at compile time, and can be the most comfortable option in many other cases. Indeed, working with a tuple might become a nightmare with many values, where std::vector<VariantValue> and RecordVec<VariantValue> (aka RecordSeq) can provide valuable help by reducing the boilerplate. The impact on runtime is negligible.

Note
As specified in the Fits definition, duplicated keywords lead to an undefined behavior.

Public Member Functions

Read the records of given categories
std::vector< std::stringreadKeywords (KeywordCategory categories=KeywordCategory::All) const
 List keywords. More...
 
std::map< std::string, std::stringreadKeywordsValues (KeywordCategory categories=KeywordCategory::All) const
 List keywords and their values. More...
 
std::string readAll (KeywordCategory categories=KeywordCategory::All) const
 Read the whole header as a single string. More...
 
RecordSeq parseAll (KeywordCategory categories=KeywordCategory::All) const
 Parse records of given categories. More...
 
Read a single record
bool has (const std::string &keyword) const
 Check whether the HDU contains a given keyword.
 
template<typename T >
Record< T > parse (const std::string &keyword) const
 Parse a record. More...
 
template<typename T >
Record< T > parseOr (const Record< T > &fallback) const
 Parse a record if it exists, return a fallback record otherwise. More...
 
template<typename T >
Record< T > parseOr (const std::string &keyword, T fallbackValue, const std::string &fallbackUnit="", const std::string &fallbackComment="") const
 Parse a record if it exists, return a fallback record otherwise. More...
 
Read a sequence of records as a vector or a tuple
template<typename T = VariantValue>
RecordVec< T > parseSeq (const std::vector< std::string > &keywords) const
 Parse a sequence of homogeneous records. More...
 
template<typename... Ts>
std::tuple< Record< Ts >... > parseSeq (const Named< Ts > &... keywords) const
 Parse a sequence of heterogeneous records. More...
 
template<typename TSeq >
TSeq parseSeqOr (TSeq &&fallbacks) const
 Parse a sequence of records if they exist, return fallbacks for those which don't. More...
 
template<typename... Ts>
std::tuple< Record< Ts >... > parseSeqOr (const Record< Ts > &... fallbacks) const
 Parse a heterogeneous sequence of records if they exist, return fallbacks for those which don't. More...
 
Read a sequence of records as a user-defined structure
template<typename TOut , typename... Ts>
TOut parseStruct (const Named< Ts > &... keywords) const
 Parse a sequence of records. More...
 
template<typename TOut , typename... Ts>
TOut parseStructOr (const Record< Ts > &... fallbacks) const
 Parse a sequence of records if they exist, return fallbacks for those which don't. More...
 
template<typename TOut , typename TSeq >
TOut parseStructOr (TSeq &&fallbacks) const
 Parse a sequence of records if they exist, return fallbacks for those which don't. More...
 
Write a single record
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename T >
void write (const Record< T > &record) const
 Write a record. More...
 
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename T >
void write (const std::string &k, T v, const std::string &u="", const std::string &c="") const
 Write a record. More...
 
void remove (const std::string &keyword) const
 Delete a record. More...
 
Write a sequence of records
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename... Ts>
void writeSeq (const Record< Ts > &... records) const
 Write a homogeneous sequence of records. More...
 
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename TSeq >
void writeSeq (TSeq &&records) const
 Write a homogeneous or heterogeneous sequence of records. More...
 
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename... Ts>
void writeSeqIn (const std::vector< std::string > &keywords, const Record< Ts > &... records) const
 Write a subset of a heterogeneous sequence of records. More...
 
template<RecordMode Mode = RecordMode::CreateOrUpdate, typename TSeq >
void writeSeqIn (const std::vector< std::string > &keywords, TSeq &&records) const
 Write a subset of a homogeneous or heterogeneous sequence of records. More...
 
Write comment records.
void writeComment (const std::string &comment) const
 Write a COMMENT record.
 
void writeHistory (const std::string &history) const
 Write a HISTORY record.
 

The documentation for this class was generated from the following file:
std::make_tuple
T make_tuple(T... args)
std::string
STL class.
std::vector
STL class.
Euclid::Fits::KeywordCategory::Reserved
static const KeywordCategory Reserved
Optional standard keywords excluding COMMENT and HISTORY.
Definition: KeywordCategory.h:44
std::cout
Euclid::Cfitsio::FileAccess::name
std::string name(fitsfile *fptr)
Get the file name.
std::endl
T endl(T... args)
Euclid::Fits::KeywordCategory::User
static const KeywordCategory User
User-defined keywords.
Definition: KeywordCategory.h:46
Euclid::Fits::RecordSeq
RecordVec< VariantValue > RecordSeq
A sequence of records of any type.
Definition: RecordVec.h:131
Euclid::Fits::KeywordCategory::Comment
static const KeywordCategory Comment
COMMENT and HISTORY keywords (non-valued reserved keywords).
Definition: KeywordCategory.h:45