11#ifndef __TextParameters_h
12#define __TextParameters_h
14#include "Pulsar/Parameters.h"
43 void set_text (
const std::string& t) { text = t; }
46 std::string
get_value (
const std::string& keyword)
const;
50 bool get_value (T& value,
const std::string& keyword,
51 bool exception=
true)
const;
55 T
get (
const std::string& keyword)
const
56 { T value;
get_value (value,keyword);
return value; }
68 bool equals (
const Row& that)
70 keyword == that.keyword &&
71 value == that.value &&
76 mutable std::vector<Row> rows;
78 void parse_rows ()
const;
84T parse (
const std::string& value)
86 return fromstring<T> (value);
89inline std::string defortran (std::string value)
91 std::string::size_type D = value.find (
'D');
92 if (D != std::string::npos)
99inline float parse<float> (
const std::string& value)
101 return fromstring<float> ( defortran(value) );
105inline double parse<double> (
const std::string& value)
107 return fromstring<double> ( defortran(value) );
113 const std::string& keyword,
114 bool exception)
const
116 std::string value_string =
get_value (keyword);
118 if (value_string.empty())
123 throw Error (InvalidParam,
"Pulsar::TextParameters::get_value<T>",
124 "keyword='" + keyword +
"' not found");
127 value = parse<T> (value_string);
A convenient exception handling class.
Definition Error.h:54
Storage of pulsar parameters used to create a Predictor.
Definition Parameters.h:23
Stores pulsar parameters as uninterpreted text.
Definition TextParameters.h:19
T get(const std::string &keyword) const
Return a value from the text, throw exeception if not found.
Definition TextParameters.h:55
void load(FILE *)
Load from an open stream.
Definition TextParameters.C:42
std::string get_name() const
Return the pulsar name.
Definition TextParameters.C:129
bool equals(const Parameters *that) const
Return true if *this == *that.
Definition TextParameters.C:19
std::string get_value(const std::string &keyword) const
Retrieve a string from the text.
Definition TextParameters.C:85
Parameters * clone() const
Return a new, copy constructed instance of self.
Definition TextParameters.C:14
void set_text(const std::string &t)
Set the text.
Definition TextParameters.h:43
void unload(FILE *) const
Unload to an open stream.
Definition TextParameters.C:52