31 class KeyData :
public Keyword
35 KeyData (
const KeyData< T > &right);
36 KeyData (
const String &keyname,
41 bool isLongStr =
false);
44 virtual KeyData <T>* clone ()
const;
45 virtual void write ();
46 const T& keyval ()
const;
47 void keyval (
const T&
value);
52 virtual void copy (
const Keyword& right);
53 virtual bool compare (
const Keyword &right)
const;
54 virtual std::ostream & put (std::ostream &s)
const;
69 class KeyNull :
public Keyword
72 enum class ValState {Empty, NumData, StrData};
73 KeyNull (
const KeyNull &right);
74 KeyNull (
const String &keyname,
78 virtual KeyNull* clone ()
const;
79 virtual void write ();
80 double numValue()
const;
81 string stringValue()
const;
82 ValState state()
const;
83 void setStringValue(
const string& val);
84 void setNumValue(
double val,
ValueType writeAs);
86 virtual void copy (
const Keyword& right);
87 virtual bool compare (
const Keyword &right)
const;
88 virtual std::ostream & put (std::ostream &s)
const;
96#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
98 inline void KeyData<String>::write()
102 if (fits_update_key(fitsPointer(), Tstring,
103 const_cast<char *
>(name().c_str()),
104 const_cast<char*
>(m_keyval.c_str()),
105 const_cast<char *
>(comment().c_str()),
106 &status))
throw FitsError(status);
110template<>
void KeyData<String>::write();
113#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
115 inline void KeyData<bool>::write()
120 if (m_keyval) value=1;
121 if (fits_update_key(fitsPointer(), Tlogical,
122 const_cast<char *
>(name().c_str()),
124 const_cast<char *
>(comment().c_str()),
125 &status))
throw FitsError(status);
129template<>
void KeyData<bool>::write();
132#ifdef SPEC_TEMPLATE_DECL_DEFECT
134 inline const String& KeyData<String>::keyval()
const
140template<>
const String& KeyData<String>::keyval()
const;
143#ifndef SPEC_TEMPLATE_DECL_DEFECT
144template<>
void KeyData<String>::keyval(
const String& );
147#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
149 inline std::ostream & KeyData<String>::put (std::ostream &s)
const
152 s <<
"Keyword Name: " << setw(10) << name() <<
" Value: " << setw(14)
153 << keyval() <<
" Type: " << setw(20) <<
" string " <<
" Comment: " << comment();
158template<> std::ostream& KeyData<String>::put(std::ostream& s)
const;
162#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
164 inline std::ostream & KeyData<bool>::put (std::ostream &s)
const
167 s <<
"Keyword Name: " << setw(10) << name()
168 <<
" Value: " << std::boolalpha << setw(8) << keyval()
169 <<
" Type: " << setw(20) <<
" logical " <<
" Comment: " << comment();
174template<> std::ostream& KeyData<bool>::put(std::ostream& s)
const;
177#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
179 inline void KeyData<std::complex<float> >::write()
183 FITSUtil::auto_array_ptr<float> keyVal(
new float[2]);
184 keyVal[0] = m_keyval.real();
185 keyVal[1] = m_keyval.imag();
186 if (fits_update_key(fitsPointer(), Tcomplex,
187 const_cast<char *
>(name().c_str()),
189 const_cast<char *
>(comment().c_str()),
190 &status))
throw FitsError(status);
194template<>
void KeyData<std::complex<float> >::write();
197#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
199 inline void KeyData<std::complex<double> >::write()
203 FITSUtil::auto_array_ptr<double> keyVal(
new double[2]);
204 keyVal[0] = m_keyval.real();
205 keyVal[1] = m_keyval.imag();
206 if (fits_update_key(fitsPointer(), Tdblcomplex,
207 const_cast<char *
>(name().c_str()),
209 const_cast<char *
>(comment().c_str()),
210 &status))
throw FitsError(status);
214template<>
void KeyData<std::complex<double> >::write();
217#if SPEC_TEMPLATE_IMP_DEFECT || SPEC_TEMPLATE_DECL_DEFECT
219 inline std::ostream & KeyData<std::complex<float> >::put (std::ostream &s)
const
222 s <<
"Keyword Name: " << name() <<
" Value: " << m_keyval.real() <<
" + i "
223 << m_keyval.imag() <<
" Type: " << setw(20) <<
" complex<float> "
224 <<
" Comment: " << comment() << std::endl;
229 inline std::ostream & KeyData<std::complex<double> >::put (std::ostream &s)
const
232 s <<
"Keyword Name: " << name() <<
" Value: " << m_keyval.real() <<
" + i "
233 << m_keyval.imag() <<
" Type: " << setw(20) <<
" complex<double> "
234 <<
" Comment: " << comment() << std::endl;
239template<> std::ostream& KeyData<std::complex<float> >::put(std::ostream& s)
const;
240template<> std::ostream& KeyData<std::complex<double> >::put(std::ostream& s)
const;
243#ifdef SPEC_TEMPLATE_DECL_DEFECT
245 inline const std::complex<float>& KeyData<std::complex<float> >::keyval()
const
252 inline void KeyData<std::complex<float> >::keyval(
const std::complex<float>& newVal)
259 inline const std::complex<double>& KeyData<std::complex<double> >::keyval()
const
266 inline void KeyData<std::complex<double> >::keyval(
const std::complex<double>& newVal)
273template<>
const std::complex<float>& KeyData<std::complex<float> >::keyval()
const;
274template<>
void KeyData<std::complex<float> >::keyval(
const std::complex<float>& );
278template<>
const std::complex<double>& KeyData<std::complex<double> >::keyval()
const;
279template<>
void KeyData<std::complex<double> >::keyval(
const std::complex<double>& );
284 template <
typename T>
285 inline std::ostream & KeyData<T>::put (std::ostream &s)
const
287 s <<
"Keyword Name: " << name() <<
"\t Value: " << keyval() <<
288 "\t Type: " << keytype() <<
"\t Comment: " << comment();
293 template <
typename T>
294 inline const T& KeyData<T>::keyval ()
const
299 template <
typename T>
300 inline void KeyData<T>::keyval (
const T& value)
307 template <
typename T>
308 KeyData<T>::KeyData(
const KeyData<T> &right)
310 m_keyval(right.m_keyval)
314 template <
typename T>
315 KeyData<T>::KeyData (
const String &keyname,
319 const String &comment,
321 : Keyword(keyname, keytype, p, comment, isLongStr),
327 template <
typename T>
328 KeyData<T>::~KeyData()
333 template <
typename T>
334 void KeyData<T>::copy (
const Keyword& right)
336 Keyword::copy(right);
337 const KeyData<T>& that =
static_cast<const KeyData<T>&
>(right);
338 m_keyval = that.m_keyval;
341 template <
typename T>
342 bool KeyData<T>::compare (
const Keyword &right)
const
344 if ( !Keyword::compare(right) )
return false;
345 const KeyData<T>& that =
static_cast<const KeyData<T>&
>(right);
346 if (this->m_keyval != that.m_keyval)
return false;
350 template <
typename T>
351 KeyData <T>* KeyData<T>::clone ()
const
353 return new KeyData<T>(*
this);
356 template <
typename T>
357 void KeyData<T>::write ()
361 FITSUtil::MatchType<T> keyType;
362 if ( fits_update_key(fitsPointer(),keyType(),
363 const_cast<char *
>(name().c_str()),
365 const_cast<char *
>(comment().c_str()),
366 &status) )
throw FitsError(status);
369 inline double KeyNull::numValue()
const
374 inline string KeyNull::stringValue()
const
376 return m_stringValue;
379 inline KeyNull::ValState KeyNull::state()
const
384 inline void KeyNull::setNumValue(
double val, ValueType writeAs)
387 m_state = ValState::NumData;
391 inline void KeyNull::setStringValue(
const string& val)
394 m_state = ValState::StrData;
T & value(T &val) const
get the keyword value
Definition KeywordT.h:29
ValueType keytype() const
return the type of a keyword
Definition Keyword.h:302
virtual void write()
left in for historical reasons, this seldom needs to be called by users
Definition Keyword.cxx:97
const String & comment() const
return the comment field of the keyword
Definition Keyword.h:317
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition CCfits.h:81