10 #include "ismrmrd/export.h"
122 void set(
const char *s) {
124 sscanf(s_.c_str(),
"%ld", &l_);
125 sscanf(s_.c_str(),
"%lf", &d_);
130 d_ =
static_cast<double>(l_);
131 std::stringstream strstream;
138 l_ =
static_cast<long>(d_);
139 std::stringstream strstream;
147 EXPORTISMRMRD
void deserialize(
const char *xml, MetaContainer &h);
149 EXPORTISMRMRD
void serialize(
const MetaContainer &h, std::ostream &o);
154 typedef std::map<std::string, std::vector<MetaValue> > map_t;
169 void set(
const char *name, T value) {
171 map_[std::string(name)] = std::vector<MetaValue>(1, value);
176 void append(
const char *name, T value) {
177 map_t::iterator it = map_.find(std::string(name));
178 if (it == map_.end()) {
182 it->second.push_back(v);
186 void remove(
const char *name) {
187 map_t::iterator it = map_.find(std::string(name));
188 if (it != map_.end()) {
195 map_t::const_iterator it = map_.find(std::string(name));
196 if (it != map_.end()) {
197 return it->second.size();
203 long as_long(
const char *name,
size_t index = 0)
const {
204 return value(name, index).as_long();
208 double as_double(
const char *name,
size_t index = 0)
const {
209 return value(name, index).as_double();
213 const char *as_str(
const char *name,
size_t index = 0)
const {
214 return value(name, index).as_str();
217 const MetaValue &value(
const char *name,
size_t index = 0)
const {
218 map_t::const_iterator it = map_.find(std::string(name));
219 if (it == map_.end()) {
220 throw std::runtime_error(
"Attempting to access unknown parameter");
222 if (index >= it->second.size()) {
223 throw std::runtime_error(
"Attempting to access indexed value out of bounds");
225 return it->second[index];
232 map_t::iterator begin() {
236 map_t::iterator end() {
240 map_t::const_iterator begin()
const {
244 map_t::const_iterator end()
const {