lsst.astshim  14.0-6-g52c7625
KeyMap.h
1 /*
2  * LSST Data Management System
3  * Copyright 2017 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #ifndef ASTSHIM_KEYMAP_H
23 #define ASTSHIM_KEYMAP_H
24 
25 #include <complex>
26 #include <ostream>
27 
28 #include "astshim/base.h"
29 #include "astshim/Channel.h"
30 #include "astshim/Object.h"
31 
32 namespace ast {
33 
34 namespace {
35 
36 void throwKeyNotFound(std::string const &key) {
37  // make sure there isn't some other error, first
38  assertOK();
39  std::ostringstream os;
40  os << "Key \"" << key << "\" not found or has an undefined value";
41  throw std::runtime_error(os.str());
42 }
43 
44 } // namespace
45 
82 class KeyMap : public Object {
83  friend class Object;
84  friend class Channel;
85 
86 public:
92  explicit KeyMap(std::string const &options = "")
93  : Object(reinterpret_cast<AstObject *>(astKeyMap("%s", options.c_str()))) {}
94 
95  virtual ~KeyMap(){};
96 
97  KeyMap(KeyMap const &) = delete;
98  KeyMap(KeyMap &&) = default;
99  KeyMap &operator=(KeyMap const &) = delete;
100  KeyMap &operator=(KeyMap &&) = default;
101 
103  std::shared_ptr<KeyMap> copy() const {
104  return std::static_pointer_cast<KeyMap>(copyPolymorphic());
105  assertOK();
106  }
107 
113  bool defined(std::string const &key) const {
114  bool ret = static_cast<bool>(
115  astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
116  assertOK();
117  return ret;
118  }
119 
121  std::string key(int ind) const {
122  int const len = size();
123  if ((ind < 0) || (ind >= len)) {
124  std::ostringstream os;
125  os << "ind = " << ind << " not in range [0, " << len - 1 << "]";
126  throw std::invalid_argument(os.str());
127  }
128  const char *rawKey = astMapKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), ind);
129  assertOK();
130  return std::string(rawKey);
131  }
132 
138  bool hasKey(std::string const &key) const {
139  bool ret = static_cast<bool>(
140  astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
141  assertOK();
142  return ret;
143  }
144 
146  int length(std::string const &key) const {
147  int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
148  assertOK();
149  return len;
150  }
151 
153  int size() const {
154  int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
155  assertOK();
156  return size;
157  }
158 
160  double getD(std::string const &key, int ind) const {
161  double retVal;
162  if (!astMapGetElemD(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
163  throwKeyNotFound(key);
164  }
165  assertOK();
166  return retVal;
167  }
168 
170  std::vector<double> getD(std::string const &key) const {
171  int const size = length(key);
172  std::vector<double> retVec(size);
173  if (size > 0) {
174  int nret; // should equal size after the call
175  astMapGet1D(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
176  retVec.data());
177  }
178  assertOK();
179  return retVec;
180  }
181 
183  float getF(std::string const &key, int ind) const {
184  float retVal;
185  if (!astMapGetElemF(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
186  throwKeyNotFound(key);
187  }
188  assertOK();
189  return retVal;
190  }
191 
193  std::vector<float> getF(std::string const &key) const {
194  int const size = length(key);
195  std::vector<float> retVec(size);
196  if (size > 0) {
197  int nret; // should equal size after the call
198  astMapGet1F(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
199  retVec.data());
200  }
201  assertOK();
202  return retVec;
203  }
204 
206  int getI(std::string const &key, int ind) const {
207  int retVal;
208  if (!astMapGetElemI(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
209  throwKeyNotFound(key);
210  }
211  assertOK();
212  return retVal;
213  }
214 
216  std::vector<int> getI(std::string const &key) const {
217  int const size = length(key);
218  std::vector<int> retVec(size);
219  if (size > 0) {
220  int nret; // should equal size after the call
221  astMapGet1I(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
222  retVec.data());
223  }
224  assertOK();
225  return retVec;
226  }
227 
229  short int getS(std::string const &key, int ind) const {
230  short int retVal;
231  if (!astMapGetElemS(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
232  throwKeyNotFound(key);
233  }
234  assertOK();
235  return retVal;
236  }
237 
239  std::vector<short int> getS(std::string const &key) const {
240  int const size = length(key);
241  std::vector<short int> retVec(size);
242  if (size > 0) {
243  int nret; // should equal size after the call
244  astMapGet1S(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
245  retVec.data());
246  }
247  assertOK();
248  return retVec;
249  }
250 
252  char unsigned getB(std::string const &key, int ind) const {
253  char unsigned retVal;
254  if (!astMapGetElemB(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
255  throwKeyNotFound(key);
256  }
257  assertOK();
258  return retVal;
259  }
260 
262  std::vector<char unsigned> getB(std::string const &key) const {
263  int const size = length(key);
264  std::vector<char unsigned> retVec(size);
265  if (size > 0) {
266  int nret; // should equal size after the call
267  astMapGet1B(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
268  retVec.data());
269  }
270  assertOK();
271  return retVec;
272  }
273 
275  std::string getC(std::string const &key, int ind) const {
276  int const maxChar = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
277  char charArr[maxChar];
278  if (!astMapGetElemC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), maxChar, ind,
279  charArr)) {
280  throwKeyNotFound(key);
281  }
282  assertOK();
283  return std::string(charArr);
284  }
285 
287  std::vector<std::string> getC(std::string const &key) const {
288  int const size = length(key);
289  std::vector<std::string> retVec;
290  if (size > 0) {
291  // # of chars for each entry; the +1 is needed to provide space for the terminating null
292  int const eltLen = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
293  char charArr[size * eltLen];
294  int nret; // should equal size after the call
295  astMapGet1C(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), eltLen, size, &nret,
296  charArr);
297  for (int i = 0; i < size; ++i) {
298  retVec.push_back(std::string(charArr + i * eltLen));
299  }
300  }
301  assertOK();
302  return retVec;
303  }
304 
306  std::shared_ptr<Object> getA(std::string const &key, int ind) const {
307  std::shared_ptr<Object> retVal;
308  AstObject *rawObj;
309  if (!astMapGetElemA(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &rawObj)) {
310  throwKeyNotFound(key);
311  }
312  assertOK();
313  return Object::fromAstObject<Object>(rawObj, true);
314  }
315 
317  std::vector<std::shared_ptr<Object>> getA(std::string const &key) const {
318  int const size = length(key);
319  std::vector<std::shared_ptr<Object>> retVec;
320  for (int i = 0; i < size; ++i) {
321  retVec.push_back(getA(key, i));
322  }
323  return retVec;
324  }
325 
327  void putD(std::string const &key, double value, std::string const &comment = "") {
328  astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
329  assertOK();
330  }
331 
333  void putD(std::string const &key, std::vector<double> const &vec, std::string const &comment = "") {
334  _assertVectorNotEmpty(key, vec.size());
335  astMapPut1D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
336  comment.c_str());
337  assertOK();
338  }
339 
341  void putF(std::string const &key, float value, std::string const &comment = "") {
342  astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
343  assertOK();
344  }
345 
347  void putF(std::string const &key, std::vector<float> const &vec, std::string const &comment = "") {
348  _assertVectorNotEmpty(key, vec.size());
349  astMapPut1F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
350  comment.c_str());
351  assertOK();
352  }
353 
355  void putI(std::string const &key, int value, std::string const &comment = "") {
356  astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
357  assertOK();
358  }
359 
361  void putI(std::string const &key, std::vector<int> const &vec, std::string const &comment = "") {
362  _assertVectorNotEmpty(key, vec.size());
363  astMapPut1I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
364  comment.c_str());
365  assertOK();
366  }
367 
369  void putS(std::string const &key, short int value, std::string const &comment = "") {
370  astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
371  assertOK();
372  }
373 
375  void putS(std::string const &key, std::vector<short int> const &vec, std::string const &comment = "") {
376  _assertVectorNotEmpty(key, vec.size());
377  astMapPut1S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
378  comment.c_str());
379  assertOK();
380  }
381 
383  void putB(std::string const &key, char unsigned value, std::string const &comment = "") {
384  astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
385  assertOK();
386  }
387 
389  void putB(std::string const &key, std::vector<char unsigned> const &vec,
390  std::string const &comment = "") {
391  _assertVectorNotEmpty(key, vec.size());
392  astMapPut1B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
393  comment.c_str());
394  assertOK();
395  }
396 
398  void putC(std::string const &key, std::string const &value, std::string const &comment = "") {
399  astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
400  assertOK();
401  }
402 
404  void putC(std::string const &key, std::vector<std::string> const &vec, std::string const &comment = "") {
405  _assertVectorNotEmpty(key, vec.size());
406  // to simplify memory management, create the key with the first element and append the rest
407  for (int i = 0, size = vec.size(); i < size; ++i) {
408  if (i == 0) {
409  putC(key, vec[0]);
410  } else {
411  append(key, vec[i]);
412  }
413  }
414  }
415 
417  void putA(std::string const &key, Object const &obj, std::string const &comment = "") {
418  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(obj.getRawPtr()));
419  astMapPut0A(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), rawCopy, comment.c_str());
420  assertOK(rawCopy);
421  }
422 
424  void putA(std::string const &key, std::vector<std::shared_ptr<Object const>> const &vec,
425  std::string const &comment = "") {
426  _assertVectorNotEmpty(key, vec.size());
427  // to simplify memory management, create the key with the first element and append the rest
428  for (int i = 0, size = vec.size(); i < size; ++i) {
429  if (i == 0) {
430  // initialize the key with the first element
431  putA(key, *vec[0]);
432  } else {
433  append(key, *vec[i]);
434  }
435  }
436  }
437 
444  void putU(std::string const &key, std::string const &comment = "") {
445  astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
446  assertOK();
447  }
448 
450  void append(std::string const &key, double value) {
451  int const i = _getAppendIndex(key);
452  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
453  assertOK();
454  }
455 
457  void append(std::string const &key, float value) {
458  int const i = _getAppendIndex(key);
459  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
460  assertOK();
461  }
462 
464  void append(std::string const &key, int value) {
465  int const i = _getAppendIndex(key);
466  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
467  assertOK();
468  }
469 
471  void append(std::string const &key, short int value) {
472  int const i = _getAppendIndex(key);
473  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
474  assertOK();
475  }
476 
478  void append(std::string const &key, char unsigned value) {
479  int const i = _getAppendIndex(key);
480  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
481  assertOK();
482  }
483 
485  void append(std::string const &key, std::string const &value) {
486  int const i = _getAppendIndex(key);
487  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
488  assertOK();
489  }
490 
492  void append(std::string const &key, Object const &value) {
493  int const i = _getAppendIndex(key);
494  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
495  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
496  assertOK(rawCopy);
497  }
498 
500  void replace(std::string const &key, int i, double value) {
501  _assertReplaceIndexInRange(key, i);
502  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
503  assertOK();
504  }
505 
507  void replace(std::string const &key, int i, float value) {
508  _assertReplaceIndexInRange(key, i);
509  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
510  assertOK();
511  }
512 
514  void replace(std::string const &key, int i, int value) {
515  _assertReplaceIndexInRange(key, i);
516  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
517  assertOK();
518  }
519 
521  void replace(std::string const &key, int i, short int value) {
522  _assertReplaceIndexInRange(key, i);
523  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
524  assertOK();
525  }
526 
528  void replace(std::string const &key, int i, char unsigned value) {
529  _assertReplaceIndexInRange(key, i);
530  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
531  assertOK();
532  }
533 
535  void replace(std::string const &key, int i, std::string const &value) {
536  _assertReplaceIndexInRange(key, i);
537  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
538  assertOK();
539  }
540 
542  void replace(std::string const &key, int i, Object const &value) {
543  _assertReplaceIndexInRange(key, i);
544  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
545  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
546  assertOK(rawCopy);
547  }
548 
554  void remove(std::string const &key) {
555  astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
556  assertOK();
557  }
558 
564  void rename(std::string const &oldKey, std::string const &newKey) {
565  astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
566  assertOK();
567  }
568 
572  DataType type(std::string const &key) {
573  int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
574  assertOK();
575  return static_cast<DataType>(retVal);
576  }
577 
578 protected:
579  // Protected implementation of deep-copy.
580  virtual std::shared_ptr<Object> copyPolymorphic() const override {
581  return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
582  }
583 
587  explicit KeyMap(AstKeyMap *rawKeyMap) : Object(reinterpret_cast<AstObject *>(rawKeyMap)) {
588  if (!astIsAKeyMap(getRawPtr())) {
589  std::ostringstream os;
590  os << "this is a " << getClassName() << ", which is not a KeyMap";
591  throw std::invalid_argument(os.str());
592  }
593  assertOK();
594  }
595 
596 private:
597  void _assertVectorNotEmpty(std::string const &key, int size) const {
598  if (size == 0) {
599  std::ostringstream os;
600  os << "vector supplied for key \"" << key << "\" has zero elements";
601  throw std::invalid_argument(os.str());
602  }
603  }
604 
605  // replace silently fails if index out of range, so check it here
606  void _assertReplaceIndexInRange(std::string const &key, int i) const {
607  int const len = length(key);
608  if ((i < 0) || (i >= len)) {
609  std::ostringstream os;
610  os << "i = " << i << " not in range [0, " << len - 1 << "] for key \"" << key << "\"";
611  throw std::invalid_argument(os.str());
612  }
613  }
614 
615  // retrieve the index required to append a value to a key, and make sure the key exists
616  int _getAppendIndex(std::string const &key) const {
617  int const i = length(key);
618  if (i == 0) {
619  std::ostringstream os;
620  os << "key \"" << key << "\" not found";
621  throw std::invalid_argument(os.str());
622  }
623  return i;
624  }
625 };
626 
627 } // namespace ast
628 
629 #endif
void rename(std::string const &oldKey, std::string const &newKey)
Definition: KeyMap.h:564
void append(std::string const &key, short int value)
Append an element to a vector of short int in a KeyMap.
Definition: KeyMap.h:471
void replace(std::string const &key, int i, int value)
Replace an element of a vector of ints in a KeyMap.
Definition: KeyMap.h:514
void putI(std::string const &key, std::vector< int > const &vec, std::string const &comment="")
Add a vector of ints.
Definition: KeyMap.h:361
Definition: KeyMap.h:82
int getI(std::string const &key, int ind) const
Get one int value for a given key.
Definition: KeyMap.h:206
void putU(std::string const &key, std::string const &comment="")
Definition: KeyMap.h:444
short int getS(std::string const &key, int ind) const
Get one short int value for a given key.
Definition: KeyMap.h:229
AstObject const * getRawPtr() const
Definition: Object.h:286
KeyMap(std::string const &options="")
Definition: KeyMap.h:92
AST wrapper classes and functions.
Definition: attributes_channel.dox:1
void replace(std::string const &key, int i, std::string const &value)
Replace an element of a vector of strings in a KeyMap.
Definition: KeyMap.h:535
virtual std::shared_ptr< Object > copyPolymorphic() const override
Definition: KeyMap.h:580
void putB(std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
Add a vector of chars.
Definition: KeyMap.h:389
std::string getClassName() const
Definition: Object.h:133
void putC(std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
Add a vector of strings.
Definition: KeyMap.h:404
bool defined(std::string const &key) const
Definition: KeyMap.h:113
Definition: Channel.h:60
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:49
std::vector< std::string > getC(std::string const &key) const
Get all std::string values for a given key.
Definition: KeyMap.h:287
void putI(std::string const &key, int value, std::string const &comment="")
Add an int.
Definition: KeyMap.h:355
double getD(std::string const &key, int ind) const
Get one double value for a given key.
Definition: KeyMap.h:160
void replace(std::string const &key, int i, short int value)
Replace an element of a vector of short int in a KeyMap.
Definition: KeyMap.h:521
int length(std::string const &key) const
Get the size of the vector for the specified key; return 0 if key not found or value is undefined...
Definition: KeyMap.h:146
int size() const
Get the number of keys.
Definition: KeyMap.h:153
void putF(std::string const &key, std::vector< float > const &vec, std::string const &comment="")
Add a vector of floats.
Definition: KeyMap.h:347
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
Definition: KeyMap.h:193
void append(std::string const &key, float value)
Append an element to a vector of floats in a KeyMap.
Definition: KeyMap.h:457
void replace(std::string const &key, int i, double value)
Replace an element of a vector of doubles in a KeyMap.
Definition: KeyMap.h:500
std::string getC(std::string const &key, int ind) const
Get one std::string value for a given key.
Definition: KeyMap.h:275
std::vector< double > getD(std::string const &key) const
Get all double values for a given key.
Definition: KeyMap.h:170
void replace(std::string const &key, int i, float value)
Replace an element of a vector of floats in a KeyMap.
Definition: KeyMap.h:507
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
Definition: KeyMap.h:239
void append(std::string const &key, int value)
Append an element to a vector of ints in a KeyMap.
Definition: KeyMap.h:464
void putS(std::string const &key, short int value, std::string const &comment="")
Add a short int.
Definition: KeyMap.h:369
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:450
void putB(std::string const &key, char unsigned value, std::string const &comment="")
Add a char.
Definition: KeyMap.h:383
void append(std::string const &key, std::string const &value)
Append an element to a vector of strings in a KeyMap.
Definition: KeyMap.h:485
void append(std::string const &key, char unsigned value)
Append an element to a vector of char in a KeyMap.
Definition: KeyMap.h:478
bool hasKey(std::string const &key) const
Definition: KeyMap.h:138
void replace(std::string const &key, int i, char unsigned value)
Replace an element of a vector of char in a KeyMap.
Definition: KeyMap.h:528
void putD(std::string const &key, std::vector< double > const &vec, std::string const &comment="")
Add a vector of double.
Definition: KeyMap.h:333
void replace(std::string const &key, int i, Object const &value)
Replace an element of a vector of Objects in a KeyMap.
Definition: KeyMap.h:542
void putS(std::string const &key, std::vector< short int > const &vec, std::string const &comment="")
Add a vector of short int.
Definition: KeyMap.h:375
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
Definition: KeyMap.h:103
void putF(std::string const &key, float value, std::string const &comment="")
Add a float.
Definition: KeyMap.h:341
char unsigned getB(std::string const &key, int ind) const
Get one char value for a given key.
Definition: KeyMap.h:252
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
Definition: KeyMap.h:262
DataType
Definition: base.h:62
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:121
float getF(std::string const &key, int ind) const
Get one float value for a given key.
Definition: KeyMap.h:183
std::shared_ptr< Object > getA(std::string const &key, int ind) const
Get one Object for a given key; the object is deep copied.
Definition: KeyMap.h:306
std::vector< std::shared_ptr< Object > > getA(std::string const &key) const
Get all Objects for a given key; each object is deep copied.
Definition: KeyMap.h:317
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:398
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:417
void append(std::string const &key, Object const &value)
Append an element to a vector of Objects in a KeyMap.
Definition: KeyMap.h:492
KeyMap(AstKeyMap *rawKeyMap)
Definition: KeyMap.h:587
Definition: Object.h:49
DataType type(std::string const &key)
Definition: KeyMap.h:572
void putA(std::string const &key, std::vector< std::shared_ptr< Object const >> const &vec, std::string const &comment="")
Add a vector of shared pointer to Object; the objects are deep copied.
Definition: KeyMap.h:424
void putD(std::string const &key, double value, std::string const &comment="")
Add a double value.
Definition: KeyMap.h:327
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
Definition: KeyMap.h:216