lsst.astshim  14.0-13-g7a60b79
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 
98  KeyMap(KeyMap const &) = default;
99  KeyMap(KeyMap &&) = default;
100  KeyMap &operator=(KeyMap const &) = delete;
101  KeyMap &operator=(KeyMap &&) = default;
102 
104  std::shared_ptr<KeyMap> copy() const {
105  return std::static_pointer_cast<KeyMap>(copyPolymorphic());
106  assertOK();
107  }
108 
114  bool defined(std::string const &key) const {
115  bool ret = static_cast<bool>(
116  astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
117  assertOK();
118  return ret;
119  }
120 
122  std::string key(int ind) const {
123  int const len = size();
124  if ((ind < 0) || (ind >= len)) {
125  std::ostringstream os;
126  os << "ind = " << ind << " not in range [0, " << len - 1 << "]";
127  throw std::invalid_argument(os.str());
128  }
129  const char *rawKey = astMapKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), ind);
130  assertOK();
131  return std::string(rawKey);
132  }
133 
139  bool hasKey(std::string const &key) const {
140  bool ret = static_cast<bool>(
141  astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
142  assertOK();
143  return ret;
144  }
145 
147  int length(std::string const &key) const {
148  int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
149  assertOK();
150  return len;
151  }
152 
154  int size() const {
155  int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
156  assertOK();
157  return size;
158  }
159 
161  double getD(std::string const &key, int ind) const {
162  double retVal;
163  if (!astMapGetElemD(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
164  throwKeyNotFound(key);
165  }
166  assertOK();
167  return retVal;
168  }
169 
171  std::vector<double> getD(std::string const &key) const {
172  int const size = length(key);
173  std::vector<double> retVec(size);
174  if (size > 0) {
175  int nret; // should equal size after the call
176  astMapGet1D(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
177  retVec.data());
178  }
179  assertOK();
180  return retVec;
181  }
182 
184  float getF(std::string const &key, int ind) const {
185  float retVal;
186  if (!astMapGetElemF(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
187  throwKeyNotFound(key);
188  }
189  assertOK();
190  return retVal;
191  }
192 
194  std::vector<float> getF(std::string const &key) const {
195  int const size = length(key);
196  std::vector<float> retVec(size);
197  if (size > 0) {
198  int nret; // should equal size after the call
199  astMapGet1F(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
200  retVec.data());
201  }
202  assertOK();
203  return retVec;
204  }
205 
207  int getI(std::string const &key, int ind) const {
208  int retVal;
209  if (!astMapGetElemI(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
210  throwKeyNotFound(key);
211  }
212  assertOK();
213  return retVal;
214  }
215 
217  std::vector<int> getI(std::string const &key) const {
218  int const size = length(key);
219  std::vector<int> retVec(size);
220  if (size > 0) {
221  int nret; // should equal size after the call
222  astMapGet1I(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
223  retVec.data());
224  }
225  assertOK();
226  return retVec;
227  }
228 
230  short int getS(std::string const &key, int ind) const {
231  short int retVal;
232  if (!astMapGetElemS(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
233  throwKeyNotFound(key);
234  }
235  assertOK();
236  return retVal;
237  }
238 
240  std::vector<short int> getS(std::string const &key) const {
241  int const size = length(key);
242  std::vector<short int> retVec(size);
243  if (size > 0) {
244  int nret; // should equal size after the call
245  astMapGet1S(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
246  retVec.data());
247  }
248  assertOK();
249  return retVec;
250  }
251 
253  char unsigned getB(std::string const &key, int ind) const {
254  char unsigned retVal;
255  if (!astMapGetElemB(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
256  throwKeyNotFound(key);
257  }
258  assertOK();
259  return retVal;
260  }
261 
263  std::vector<char unsigned> getB(std::string const &key) const {
264  int const size = length(key);
265  std::vector<char unsigned> retVec(size);
266  if (size > 0) {
267  int nret; // should equal size after the call
268  astMapGet1B(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
269  retVec.data());
270  }
271  assertOK();
272  return retVec;
273  }
274 
276  std::string getC(std::string const &key, int ind) const {
277  int const maxChar = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
278  char charArr[maxChar];
279  if (!astMapGetElemC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), maxChar, ind,
280  charArr)) {
281  throwKeyNotFound(key);
282  }
283  assertOK();
284  return std::string(charArr);
285  }
286 
288  std::vector<std::string> getC(std::string const &key) const {
289  int const size = length(key);
290  std::vector<std::string> retVec;
291  if (size > 0) {
292  // # of chars for each entry; the +1 is needed to provide space for the terminating null
293  int const eltLen = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
294  char charArr[size * eltLen];
295  int nret; // should equal size after the call
296  astMapGet1C(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), eltLen, size, &nret,
297  charArr);
298  for (int i = 0; i < size; ++i) {
299  retVec.push_back(std::string(charArr + i * eltLen));
300  }
301  }
302  assertOK();
303  return retVec;
304  }
305 
307  std::shared_ptr<Object> getA(std::string const &key, int ind) const {
308  std::shared_ptr<Object> retVal;
309  AstObject *rawObj;
310  if (!astMapGetElemA(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &rawObj)) {
311  throwKeyNotFound(key);
312  }
313  assertOK();
314  return Object::fromAstObject<Object>(rawObj, true);
315  }
316 
318  std::vector<std::shared_ptr<Object>> getA(std::string const &key) const {
319  int const size = length(key);
320  std::vector<std::shared_ptr<Object>> retVec;
321  for (int i = 0; i < size; ++i) {
322  retVec.push_back(getA(key, i));
323  }
324  return retVec;
325  }
326 
328  void putD(std::string const &key, double value, std::string const &comment = "") {
329  astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
330  assertOK();
331  }
332 
334  void putD(std::string const &key, std::vector<double> const &vec, std::string const &comment = "") {
335  _assertVectorNotEmpty(key, vec.size());
336  astMapPut1D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
337  comment.c_str());
338  assertOK();
339  }
340 
342  void putF(std::string const &key, float value, std::string const &comment = "") {
343  astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
344  assertOK();
345  }
346 
348  void putF(std::string const &key, std::vector<float> const &vec, std::string const &comment = "") {
349  _assertVectorNotEmpty(key, vec.size());
350  astMapPut1F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
351  comment.c_str());
352  assertOK();
353  }
354 
356  void putI(std::string const &key, int value, std::string const &comment = "") {
357  astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
358  assertOK();
359  }
360 
362  void putI(std::string const &key, std::vector<int> const &vec, std::string const &comment = "") {
363  _assertVectorNotEmpty(key, vec.size());
364  astMapPut1I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
365  comment.c_str());
366  assertOK();
367  }
368 
370  void putS(std::string const &key, short int value, std::string const &comment = "") {
371  astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
372  assertOK();
373  }
374 
376  void putS(std::string const &key, std::vector<short int> const &vec, std::string const &comment = "") {
377  _assertVectorNotEmpty(key, vec.size());
378  astMapPut1S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
379  comment.c_str());
380  assertOK();
381  }
382 
384  void putB(std::string const &key, char unsigned value, std::string const &comment = "") {
385  astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
386  assertOK();
387  }
388 
390  void putB(std::string const &key, std::vector<char unsigned> const &vec,
391  std::string const &comment = "") {
392  _assertVectorNotEmpty(key, vec.size());
393  astMapPut1B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
394  comment.c_str());
395  assertOK();
396  }
397 
399  void putC(std::string const &key, std::string const &value, std::string const &comment = "") {
400  astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
401  assertOK();
402  }
403 
405  void putC(std::string const &key, std::vector<std::string> const &vec, std::string const &comment = "") {
406  _assertVectorNotEmpty(key, vec.size());
407  // to simplify memory management, create the key with the first element and append the rest
408  for (int i = 0, size = vec.size(); i < size; ++i) {
409  if (i == 0) {
410  putC(key, vec[0]);
411  } else {
412  append(key, vec[i]);
413  }
414  }
415  }
416 
418  void putA(std::string const &key, Object const &obj, std::string const &comment = "") {
419  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(obj.getRawPtr()));
420  astMapPut0A(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), rawCopy, comment.c_str());
421  assertOK(rawCopy);
422  }
423 
425  void putA(std::string const &key, std::vector<std::shared_ptr<Object const>> const &vec,
426  std::string const &comment = "") {
427  _assertVectorNotEmpty(key, vec.size());
428  // to simplify memory management, create the key with the first element and append the rest
429  for (int i = 0, size = vec.size(); i < size; ++i) {
430  if (i == 0) {
431  // initialize the key with the first element
432  putA(key, *vec[0]);
433  } else {
434  append(key, *vec[i]);
435  }
436  }
437  }
438 
445  void putU(std::string const &key, std::string const &comment = "") {
446  astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
447  assertOK();
448  }
449 
451  void append(std::string const &key, double value) {
452  int const i = _getAppendIndex(key);
453  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
454  assertOK();
455  }
456 
458  void append(std::string const &key, float value) {
459  int const i = _getAppendIndex(key);
460  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
461  assertOK();
462  }
463 
465  void append(std::string const &key, int value) {
466  int const i = _getAppendIndex(key);
467  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
468  assertOK();
469  }
470 
472  void append(std::string const &key, short int value) {
473  int const i = _getAppendIndex(key);
474  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
475  assertOK();
476  }
477 
479  void append(std::string const &key, char unsigned value) {
480  int const i = _getAppendIndex(key);
481  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
482  assertOK();
483  }
484 
486  void append(std::string const &key, std::string const &value) {
487  int const i = _getAppendIndex(key);
488  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
489  assertOK();
490  }
491 
493  void append(std::string const &key, Object const &value) {
494  int const i = _getAppendIndex(key);
495  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
496  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
497  assertOK(rawCopy);
498  }
499 
501  void replace(std::string const &key, int i, double value) {
502  _assertReplaceIndexInRange(key, i);
503  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
504  assertOK();
505  }
506 
508  void replace(std::string const &key, int i, float value) {
509  _assertReplaceIndexInRange(key, i);
510  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
511  assertOK();
512  }
513 
515  void replace(std::string const &key, int i, int value) {
516  _assertReplaceIndexInRange(key, i);
517  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
518  assertOK();
519  }
520 
522  void replace(std::string const &key, int i, short int value) {
523  _assertReplaceIndexInRange(key, i);
524  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
525  assertOK();
526  }
527 
529  void replace(std::string const &key, int i, char unsigned value) {
530  _assertReplaceIndexInRange(key, i);
531  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
532  assertOK();
533  }
534 
536  void replace(std::string const &key, int i, std::string const &value) {
537  _assertReplaceIndexInRange(key, i);
538  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
539  assertOK();
540  }
541 
543  void replace(std::string const &key, int i, Object const &value) {
544  _assertReplaceIndexInRange(key, i);
545  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
546  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
547  assertOK(rawCopy);
548  }
549 
555  void remove(std::string const &key) {
556  astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
557  assertOK();
558  }
559 
565  void rename(std::string const &oldKey, std::string const &newKey) {
566  astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
567  assertOK();
568  }
569 
573  DataType type(std::string const &key) {
574  int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
575  assertOK();
576  return static_cast<DataType>(retVal);
577  }
578 
579 protected:
580  // Protected implementation of deep-copy.
581  virtual std::shared_ptr<Object> copyPolymorphic() const override {
582  return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
583  }
584 
588  explicit KeyMap(AstKeyMap *rawKeyMap) : Object(reinterpret_cast<AstObject *>(rawKeyMap)) {
589  if (!astIsAKeyMap(getRawPtr())) {
590  std::ostringstream os;
591  os << "this is a " << getClassName() << ", which is not a KeyMap";
592  throw std::invalid_argument(os.str());
593  }
594  assertOK();
595  }
596 
597 private:
598  void _assertVectorNotEmpty(std::string const &key, int size) const {
599  if (size == 0) {
600  std::ostringstream os;
601  os << "vector supplied for key \"" << key << "\" has zero elements";
602  throw std::invalid_argument(os.str());
603  }
604  }
605 
606  // replace silently fails if index out of range, so check it here
607  void _assertReplaceIndexInRange(std::string const &key, int i) const {
608  int const len = length(key);
609  if ((i < 0) || (i >= len)) {
610  std::ostringstream os;
611  os << "i = " << i << " not in range [0, " << len - 1 << "] for key \"" << key << "\"";
612  throw std::invalid_argument(os.str());
613  }
614  }
615 
616  // retrieve the index required to append a value to a key, and make sure the key exists
617  int _getAppendIndex(std::string const &key) const {
618  int const i = length(key);
619  if (i == 0) {
620  std::ostringstream os;
621  os << "key \"" << key << "\" not found";
622  throw std::invalid_argument(os.str());
623  }
624  return i;
625  }
626 };
627 
628 } // namespace ast
629 
630 #endif
void rename(std::string const &oldKey, std::string const &newKey)
Definition: KeyMap.h:565
void append(std::string const &key, short int value)
Append an element to a vector of short int in a KeyMap.
Definition: KeyMap.h:472
void replace(std::string const &key, int i, int value)
Replace an element of a vector of ints in a KeyMap.
Definition: KeyMap.h:515
void putI(std::string const &key, std::vector< int > const &vec, std::string const &comment="")
Add a vector of ints.
Definition: KeyMap.h:362
Definition: KeyMap.h:82
int getI(std::string const &key, int ind) const
Get one int value for a given key.
Definition: KeyMap.h:207
void putU(std::string const &key, std::string const &comment="")
Definition: KeyMap.h:445
short int getS(std::string const &key, int ind) const
Get one short int value for a given key.
Definition: KeyMap.h:230
AstObject const * getRawPtr() const
Definition: Object.h:291
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:536
virtual std::shared_ptr< Object > copyPolymorphic() const override
Definition: KeyMap.h:581
void putB(std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
Add a vector of chars.
Definition: KeyMap.h:390
std::string getClassName() const
Definition: Object.h:138
void putC(std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
Add a vector of strings.
Definition: KeyMap.h:405
bool defined(std::string const &key) const
Definition: KeyMap.h:114
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:288
void putI(std::string const &key, int value, std::string const &comment="")
Add an int.
Definition: KeyMap.h:356
double getD(std::string const &key, int ind) const
Get one double value for a given key.
Definition: KeyMap.h:161
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:522
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:147
int size() const
Get the number of keys.
Definition: KeyMap.h:154
void putF(std::string const &key, std::vector< float > const &vec, std::string const &comment="")
Add a vector of floats.
Definition: KeyMap.h:348
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
Definition: KeyMap.h:194
void append(std::string const &key, float value)
Append an element to a vector of floats in a KeyMap.
Definition: KeyMap.h:458
void replace(std::string const &key, int i, double value)
Replace an element of a vector of doubles in a KeyMap.
Definition: KeyMap.h:501
std::string getC(std::string const &key, int ind) const
Get one std::string value for a given key.
Definition: KeyMap.h:276
std::vector< double > getD(std::string const &key) const
Get all double values for a given key.
Definition: KeyMap.h:171
void replace(std::string const &key, int i, float value)
Replace an element of a vector of floats in a KeyMap.
Definition: KeyMap.h:508
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
Definition: KeyMap.h:240
void append(std::string const &key, int value)
Append an element to a vector of ints in a KeyMap.
Definition: KeyMap.h:465
void putS(std::string const &key, short int value, std::string const &comment="")
Add a short int.
Definition: KeyMap.h:370
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:451
void putB(std::string const &key, char unsigned value, std::string const &comment="")
Add a char.
Definition: KeyMap.h:384
void append(std::string const &key, std::string const &value)
Append an element to a vector of strings in a KeyMap.
Definition: KeyMap.h:486
void append(std::string const &key, char unsigned value)
Append an element to a vector of char in a KeyMap.
Definition: KeyMap.h:479
bool hasKey(std::string const &key) const
Definition: KeyMap.h:139
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:529
void putD(std::string const &key, std::vector< double > const &vec, std::string const &comment="")
Add a vector of double.
Definition: KeyMap.h:334
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:543
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:376
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
Definition: KeyMap.h:104
void putF(std::string const &key, float value, std::string const &comment="")
Add a float.
Definition: KeyMap.h:342
char unsigned getB(std::string const &key, int ind) const
Get one char value for a given key.
Definition: KeyMap.h:253
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
Definition: KeyMap.h:263
DataType
Definition: base.h:62
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:122
float getF(std::string const &key, int ind) const
Get one float value for a given key.
Definition: KeyMap.h:184
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:307
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:318
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:399
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:418
void append(std::string const &key, Object const &value)
Append an element to a vector of Objects in a KeyMap.
Definition: KeyMap.h:493
KeyMap(AstKeyMap *rawKeyMap)
Definition: KeyMap.h:588
Definition: Object.h:51
DataType type(std::string const &key)
Definition: KeyMap.h:573
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:425
void putD(std::string const &key, double value, std::string const &comment="")
Add a double value.
Definition: KeyMap.h:328
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
Definition: KeyMap.h:217