10 #include "ismrmrd/export.h"
121 void set(
const char *s) {
123 sscanf(s_.c_str(),
"%ld", &l_);
124 sscanf(s_.c_str(),
"%lf", &d_);
129 d_ =
static_cast<double>(l_);
130 std::stringstream strstream;
137 l_ =
static_cast<long>(d_);
138 std::stringstream strstream;
146 EXPORTISMRMRD
void deserialize(
const char *xml, MetaContainer &h);
148 EXPORTISMRMRD
void serialize(
const MetaContainer &h, std::ostream &o);
153 typedef std::map<std::string, std::vector<MetaValue> > map_t;
168 void set(
const char *name, T value) {
170 map_[std::string(name)] = std::vector<MetaValue>(1, value);
175 void append(
const char *name, T value) {
176 map_t::iterator it = map_.find(std::string(name));
177 if (it == map_.end()) {
181 it->second.push_back(v);
185 void remove(
const char *name) {
186 map_t::iterator it = map_.find(std::string(name));
187 if (it != map_.end()) {
194 map_t::const_iterator it = map_.find(std::string(name));
195 if (it != map_.end()) {
196 return it->second.size();
202 long as_long(
const char *name,
size_t index = 0)
const {
203 return value(name, index).as_long();
207 double as_double(
const char *name,
size_t index = 0)
const {
208 return value(name, index).as_double();
212 const char *as_str(
const char *name,
size_t index = 0)
const {
213 return value(name, index).as_str();
216 const MetaValue &value(
const char *name,
size_t index = 0)
const {
217 map_t::const_iterator it = map_.find(std::string(name));
218 if (it == map_.end()) {
219 throw std::runtime_error(
"Attempting to access unknown parameter");
221 if (index >= it->second.size()) {
222 throw std::runtime_error(
"Attempting to access indexed value out of bounds");
224 return it->second[index];
231 map_t::iterator begin() {
235 map_t::iterator end() {
239 map_t::const_iterator begin()
const {
243 map_t::const_iterator end()
const {
265 #endif //ISMRMRDMETA_H