EleFits  5.3.1
A modern C++ API on top of CFITSIO
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Public Member Functions | Public Attributes | Related Functions | List of all members
Record< T > Struct Template Reference

#include <Record.h>

Detailed Description

template<typename T>
struct Euclid::Fits::Record< T >

Keyword-value pair with optional unit and comment.

Template Parameters
TThe value type, which can be an integer, floating point, complex, std::string, const char *, or VariantValue for run-time type deduction.

Here's a record of type double with keyword "LIGHT", value 3.0e8, unit "m/s" and comment "speed of light":

Record<double> light_speed {"LIGHT", 3.0e8, "m/s", "speed of light"};
Keyword-value pair with optional unit and comment.
Definition: Record.h:101

In the FITS file, this record will appear in the header of an HDU as (padding blank spaces removed):

LIGHT = 3.0E8 / [m/s] speed of light

In the FITS definition, it is unclear if the "comment" encompasses only: speed of light, or also the unit, as: [m/s] speed of light. In EleFits, the former is named comment, while the latter is the raw comment. The raw comment can be get as Record::raw_comment().

Such a Record can be cast to double (records of value type T can be cast to T), or more precisely, it can be sliced as its value.

double millenium_falcon_speed = 1.5 * light_speed;
// Same as: 1.5 * light_speed.value

This is also usefull when aiming at reading record values only, and skip the keyword, unit and comment:

Record<int> the_record = h.parse<int>("KEYWORD");
int the_value = h.parse<int>("KEYWORD");

The "HIERARCH" convention for extended keywords is supported. It occurs when the keyword is longer than 8 characters, or contains non-standard characters like spaces or symbols. Such records are read and written transparently as:

HIERARCH the_long_keyword = value / [unit] comment
std::string unit
The unit.
Definition: Record.h:237
T value
The value.
Definition: Record.h:232
std::string comment
The comment without the unit.
Definition: Record.h:242

The maximum length of such a keyword is 67 characters, which gives room for a 1-byte long value.

CFITSIO convention on long string values (more than 68 characters) is supported. When writing a long string record, the value is wrapped automatically, and each new line starts with the CONTINUE keyword. An additional "LONGSTRN" record is written to the file, to warn the file user about the CFITSIO convention.

Examples
EleFitsTutorial.cpp.

Public Types

using Value = T
 The value type.
 

Static Public Member Functions

template<typename TFrom >
static T cast (TFrom value)
 Helper function to cast Record value types. Valid casts are: More...
 

Public Member Functions

template<typename TFrom >
 Record (const Record< TFrom > &other)
 Create a record from a Record of another type. More...
 
 Record (const std::string &k="", T v=T(), const std::string &u="", const std::string &c="")
 Constructor. More...
 
template<typename U >
Record< T > & assign (const Record< U > &other)
 Copy a Record of another type.
 
template<typename TFrom >
Record< T > & assign (const std::string &k="", TFrom v=TFrom(), const std::string &u="", const std::string &c="")
 Assign new fields to the record.
 
bool has_long_keyword () const
 Check whether the keyword of a record is long string (more than 8 characters). More...
 
bool has_long_string_value () const
 Check whether the value of a record is a long string (more than 68 characters). More...
 
bool hasLongKeyword () const
 
bool hasLongStringValue () const
 
 operator T () const
 Slice the record as its value. More...
 
std::string raw_comment () const
 Get the raw comment string. More...
 
std::string rawComment () const
 

Public Attributes

std::string comment
 The comment without the unit.
 
std::string keyword
 The keyword.
 
std::string unit
 The unit.
 
value
 The value.
 

Related Functions

(Note that these are not member functions.)

template<typename T >
bool operator!= (const Record< T > &lhs, const Record< T > &rhs)
 Check whether two records are different.
 
template<typename T >
std::ostreamoperator<< (std::ostream &os, const Record< T > &r)
 Serialize a record.
 
template<typename T >
bool operator== (const Record< T > &lhs, const Record< T > &rhs)
 Check whether two records are equal. More...
 

The documentation for this struct was generated from the following file: