LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
KeyMap.h
Go to the documentation of this file.
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 #include <memory>
28 
29 #include "astshim/base.h"
30 #include "astshim/Channel.h"
31 #include "astshim/Object.h"
32 
33 namespace ast {
34 
35 namespace {
36 
37 void throwKeyNotFound(std::string const &key) {
38  // make sure there isn't some other error, first
39  assertOK();
41  os << "Key \"" << key << "\" not found or has an undefined value";
42  throw std::runtime_error(os.str());
43 }
44 
45 } // namespace
46 
83 class KeyMap : public Object {
84  friend class Object;
85  friend class Channel;
86 
87 public:
93  explicit KeyMap(std::string const &options = "")
94  : Object(reinterpret_cast<AstObject *>(astKeyMap("%s", options.c_str()))) {
95  assertOK();
96  }
97 
98  virtual ~KeyMap(){};
99 
101  KeyMap(KeyMap const &) = default;
102  KeyMap(KeyMap &&) = default;
103  KeyMap &operator=(KeyMap const &) = delete;
104  KeyMap &operator=(KeyMap &&) = default;
105 
108  return std::static_pointer_cast<KeyMap>(copyPolymorphic());
109  assertOK();
110  }
111 
117  bool defined(std::string const &key) const {
118  bool ret = static_cast<bool>(
119  astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
120  assertOK();
121  return ret;
122  }
123 
125  std::string key(int ind) const {
126  int const len = size();
127  if ((ind < 0) || (ind >= len)) {
129  os << "ind = " << ind << " not in range [0, " << len - 1 << "]";
130  throw std::invalid_argument(os.str());
131  }
132  const char *rawKey = astMapKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), ind);
133  assertOK();
134  return std::string(rawKey);
135  }
136 
142  bool hasKey(std::string const &key) const {
143  bool ret = static_cast<bool>(
144  astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
145  assertOK();
146  return ret;
147  }
148 
150  int length(std::string const &key) const {
151  int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
152  assertOK();
153  return len;
154  }
155 
157  int size() const {
158  int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
159  assertOK();
160  return size;
161  }
162 
164  double getD(std::string const &key, int ind) const {
165  double retVal;
166  if (!astMapGetElemD(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
167  throwKeyNotFound(key);
168  }
169  assertOK();
170  return retVal;
171  }
172 
175  int const size = length(key);
176  std::vector<double> retVec(size);
177  if (size > 0) {
178  int nret; // should equal size after the call
179  astMapGet1D(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
180  retVec.data());
181  }
182  assertOK();
183  return retVec;
184  }
185 
187  float getF(std::string const &key, int ind) const {
188  float retVal;
189  if (!astMapGetElemF(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
190  throwKeyNotFound(key);
191  }
192  assertOK();
193  return retVal;
194  }
195 
198  int const size = length(key);
199  std::vector<float> retVec(size);
200  if (size > 0) {
201  int nret; // should equal size after the call
202  astMapGet1F(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
203  retVec.data());
204  }
205  assertOK();
206  return retVec;
207  }
208 
210  int getI(std::string const &key, int ind) const {
211  int retVal;
212  if (!astMapGetElemI(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
213  throwKeyNotFound(key);
214  }
215  assertOK();
216  return retVal;
217  }
218 
221  int const size = length(key);
222  std::vector<int> retVec(size);
223  if (size > 0) {
224  int nret; // should equal size after the call
225  astMapGet1I(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
226  retVec.data());
227  }
228  assertOK();
229  return retVec;
230  }
231 
233  short int getS(std::string const &key, int ind) const {
234  short int retVal;
235  if (!astMapGetElemS(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
236  throwKeyNotFound(key);
237  }
238  assertOK();
239  return retVal;
240  }
241 
244  int const size = length(key);
246  if (size > 0) {
247  int nret; // should equal size after the call
248  astMapGet1S(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
249  retVec.data());
250  }
251  assertOK();
252  return retVec;
253  }
254 
256  char unsigned getB(std::string const &key, int ind) const {
257  char unsigned retVal;
258  if (!astMapGetElemB(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
259  throwKeyNotFound(key);
260  }
261  assertOK();
262  return retVal;
263  }
264 
267  int const size = length(key);
269  if (size > 0) {
270  int nret; // should equal size after the call
271  astMapGet1B(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
272  retVec.data());
273  }
274  assertOK();
275  return retVec;
276  }
277 
279  std::string getC(std::string const &key, int ind) const {
280  int const maxChar = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
281  std::unique_ptr<char[]> cstr(new char[maxChar]);
282  if (!astMapGetElemC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), maxChar, ind,
283  cstr.get())) {
284  throwKeyNotFound(key);
285  }
286  assertOK();
287  return std::string(cstr.get());
288  }
289 
292  int const size = length(key);
294  if (size > 0) {
295  // # of chars for each entry; the +1 is needed to provide space for the terminating null
296  int const eltLen = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
297  std::unique_ptr<char[]> cstr(new char[size * eltLen]);
298  int nret; // should equal size after the call
299  astMapGet1C(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), eltLen, size, &nret,
300  cstr.get());
301  for (int i = 0; i < size; ++i) {
302  retVec.push_back(std::string(cstr.get() + i * eltLen));
303  }
304  }
305  assertOK();
306  return retVec;
307  }
308 
310  std::shared_ptr<Object> getA(std::string const &key, int ind) const {
312  AstObject *rawObj;
313  if (!astMapGetElemA(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &rawObj)) {
314  throwKeyNotFound(key);
315  }
316  assertOK();
317  return Object::fromAstObject<Object>(rawObj, true);
318  }
319 
322  int const size = length(key);
324  for (int i = 0; i < size; ++i) {
325  retVec.push_back(getA(key, i));
326  }
327  return retVec;
328  }
329 
331  void putD(std::string const &key, double value, std::string const &comment = "") {
332  astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
333  assertOK();
334  }
335 
337  void putD(std::string const &key, std::vector<double> const &vec, std::string const &comment = "") {
338  _assertVectorNotEmpty(key, vec.size());
339  astMapPut1D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
340  comment.c_str());
341  assertOK();
342  }
343 
345  void putF(std::string const &key, float value, std::string const &comment = "") {
346  astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
347  assertOK();
348  }
349 
351  void putF(std::string const &key, std::vector<float> const &vec, std::string const &comment = "") {
352  _assertVectorNotEmpty(key, vec.size());
353  astMapPut1F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
354  comment.c_str());
355  assertOK();
356  }
357 
359  void putI(std::string const &key, int value, std::string const &comment = "") {
360  astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
361  assertOK();
362  }
363 
365  void putI(std::string const &key, std::vector<int> const &vec, std::string const &comment = "") {
366  _assertVectorNotEmpty(key, vec.size());
367  astMapPut1I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
368  comment.c_str());
369  assertOK();
370  }
371 
373  void putS(std::string const &key, short int value, std::string const &comment = "") {
374  astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
375  assertOK();
376  }
377 
379  void putS(std::string const &key, std::vector<short int> const &vec, std::string const &comment = "") {
380  _assertVectorNotEmpty(key, vec.size());
381  astMapPut1S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
382  comment.c_str());
383  assertOK();
384  }
385 
387  void putB(std::string const &key, char unsigned value, std::string const &comment = "") {
388  astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
389  assertOK();
390  }
391 
394  std::string const &comment = "") {
395  _assertVectorNotEmpty(key, vec.size());
396  astMapPut1B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
397  comment.c_str());
398  assertOK();
399  }
400 
402  void putC(std::string const &key, std::string const &value, std::string const &comment = "") {
403  astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
404  assertOK();
405  }
406 
408  void putC(std::string const &key, std::vector<std::string> const &vec, std::string const &comment = "") {
409  _assertVectorNotEmpty(key, vec.size());
410  // to simplify memory management, create the key with the first element and append the rest
411  for (int i = 0, size = vec.size(); i < size; ++i) {
412  if (i == 0) {
413  putC(key, vec[0]);
414  } else {
415  append(key, vec[i]);
416  }
417  }
418  }
419 
421  void putA(std::string const &key, Object const &obj, std::string const &comment = "") {
422  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(obj.getRawPtr()));
423  astMapPut0A(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), rawCopy, comment.c_str());
424  assertOK(rawCopy);
425  }
426 
429  std::string const &comment = "") {
430  _assertVectorNotEmpty(key, vec.size());
431  // to simplify memory management, create the key with the first element and append the rest
432  for (int i = 0, size = vec.size(); i < size; ++i) {
433  if (i == 0) {
434  // initialize the key with the first element
435  putA(key, *vec[0]);
436  } else {
437  append(key, *vec[i]);
438  }
439  }
440  }
441 
448  void putU(std::string const &key, std::string const &comment = "") {
449  astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
450  assertOK();
451  }
452 
454  void append(std::string const &key, double value) {
455  int const i = _getAppendIndex(key);
456  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
457  assertOK();
458  }
459 
461  void append(std::string const &key, float value) {
462  int const i = _getAppendIndex(key);
463  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
464  assertOK();
465  }
466 
468  void append(std::string const &key, int value) {
469  int const i = _getAppendIndex(key);
470  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
471  assertOK();
472  }
473 
475  void append(std::string const &key, short int value) {
476  int const i = _getAppendIndex(key);
477  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
478  assertOK();
479  }
480 
482  void append(std::string const &key, char unsigned value) {
483  int const i = _getAppendIndex(key);
484  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
485  assertOK();
486  }
487 
489  void append(std::string const &key, std::string const &value) {
490  int const i = _getAppendIndex(key);
491  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
492  assertOK();
493  }
494 
496  void append(std::string const &key, Object const &value) {
497  int const i = _getAppendIndex(key);
498  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
499  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
500  assertOK(rawCopy);
501  }
502 
504  void replace(std::string const &key, int i, double value) {
505  _assertReplaceIndexInRange(key, i);
506  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
507  assertOK();
508  }
509 
511  void replace(std::string const &key, int i, float value) {
512  _assertReplaceIndexInRange(key, i);
513  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
514  assertOK();
515  }
516 
518  void replace(std::string const &key, int i, int value) {
519  _assertReplaceIndexInRange(key, i);
520  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
521  assertOK();
522  }
523 
525  void replace(std::string const &key, int i, short int value) {
526  _assertReplaceIndexInRange(key, i);
527  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
528  assertOK();
529  }
530 
532  void replace(std::string const &key, int i, char unsigned value) {
533  _assertReplaceIndexInRange(key, i);
534  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
535  assertOK();
536  }
537 
539  void replace(std::string const &key, int i, std::string const &value) {
540  _assertReplaceIndexInRange(key, i);
541  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
542  assertOK();
543  }
544 
546  void replace(std::string const &key, int i, Object const &value) {
547  _assertReplaceIndexInRange(key, i);
548  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
549  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
550  assertOK(rawCopy);
551  }
552 
558  void remove(std::string const &key) {
559  astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
560  assertOK();
561  }
562 
568  void rename(std::string const &oldKey, std::string const &newKey) {
569  astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
570  assertOK();
571  }
572 
577  int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
578  assertOK();
579  return static_cast<DataType>(retVal);
580  }
581 
582 protected:
583  // Protected implementation of deep-copy.
584  virtual std::shared_ptr<Object> copyPolymorphic() const override {
585  return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
586  }
587 
591  explicit KeyMap(AstKeyMap *rawKeyMap) : Object(reinterpret_cast<AstObject *>(rawKeyMap)) {
592  if (!astIsAKeyMap(getRawPtr())) {
594  os << "this is a " << getClassName() << ", which is not a KeyMap";
595  throw std::invalid_argument(os.str());
596  }
597  assertOK();
598  }
599 
600 private:
601  void _assertVectorNotEmpty(std::string const &key, int size) const {
602  if (size == 0) {
604  os << "vector supplied for key \"" << key << "\" has zero elements";
605  throw std::invalid_argument(os.str());
606  }
607  }
608 
609  // replace silently fails if index out of range, so check it here
610  void _assertReplaceIndexInRange(std::string const &key, int i) const {
611  int const len = length(key);
612  if ((i < 0) || (i >= len)) {
614  os << "i = " << i << " not in range [0, " << len - 1 << "] for key \"" << key << "\"";
615  throw std::invalid_argument(os.str());
616  }
617  }
618 
619  // retrieve the index required to append a value to a key, and make sure the key exists
620  int _getAppendIndex(std::string const &key) const {
621  int const i = length(key);
622  if (i == 0) {
624  os << "key \"" << key << "\" not found";
625  throw std::invalid_argument(os.str());
626  }
627  return i;
628  }
629 };
630 
631 } // namespace ast
632 
633 #endif
Key< U > key
Definition: Schema.cc:281
std::ostream * os
Definition: Schema.cc:746
T c_str(T... args)
Channel provides input/output of AST objects.
Definition: Channel.h:60
KeyMap is used to store a set of values with associated keys which identify the values.
Definition: KeyMap.h:83
void append(std::string const &key, float value)
Append an element to a vector of floats in a KeyMap.
Definition: KeyMap.h:461
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:428
double getD(std::string const &key, int ind) const
Get one double value for a given key.
Definition: KeyMap.h:164
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:321
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
Definition: KeyMap.h:197
KeyMap(KeyMap const &)=default
Copy constructor: make a deep copy.
KeyMap(KeyMap &&)=default
KeyMap & operator=(KeyMap &&)=default
void append(std::string const &key, std::string const &value)
Append an element to a vector of strings in a KeyMap.
Definition: KeyMap.h:489
bool hasKey(std::string const &key) const
Does this map contain the specified key?
Definition: KeyMap.h:142
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:310
int getI(std::string const &key, int ind) const
Get one int value for a given key.
Definition: KeyMap.h:210
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:546
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:150
void putI(std::string const &key, std::vector< int > const &vec, std::string const &comment="")
Add a vector of ints.
Definition: KeyMap.h:365
void append(std::string const &key, short int value)
Append an element to a vector of short int in a KeyMap.
Definition: KeyMap.h:475
void putB(std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
Add a vector of chars.
Definition: KeyMap.h:393
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:402
void putB(std::string const &key, char unsigned value, std::string const &comment="")
Add a char.
Definition: KeyMap.h:387
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
Definition: KeyMap.h:220
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
Definition: KeyMap.h:584
void remove(std::string const &key)
Remove the specified entry.
Definition: KeyMap.h:558
float getF(std::string const &key, int ind) const
Get one float value for a given key.
Definition: KeyMap.h:187
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:525
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
Definition: KeyMap.h:243
bool defined(std::string const &key) const
Does this map contain the specified key, and if so, does it have a defined value?
Definition: KeyMap.h:117
void replace(std::string const &key, int i, float value)
Replace an element of a vector of floats in a KeyMap.
Definition: KeyMap.h:511
void putS(std::string const &key, short int value, std::string const &comment="")
Add a short int.
Definition: KeyMap.h:373
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:539
virtual ~KeyMap()
Definition: KeyMap.h:98
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
Definition: KeyMap.h:266
void replace(std::string const &key, int i, int value)
Replace an element of a vector of ints in a KeyMap.
Definition: KeyMap.h:518
void putU(std::string const &key, std::string const &comment="")
Add a new entry, but no value is stored with the entry.
Definition: KeyMap.h:448
void rename(std::string const &oldKey, std::string const &newKey)
Rename the specified entry.
Definition: KeyMap.h:568
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
Definition: KeyMap.h:107
std::vector< double > getD(std::string const &key) const
Get all double values for a given key.
Definition: KeyMap.h:174
short int getS(std::string const &key, int ind) const
Get one short int value for a given key.
Definition: KeyMap.h:233
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:125
int size() const
Get the number of keys.
Definition: KeyMap.h:157
KeyMap & operator=(KeyMap const &)=delete
void append(std::string const &key, char unsigned value)
Append an element to a vector of char in a KeyMap.
Definition: KeyMap.h:482
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:532
void replace(std::string const &key, int i, double value)
Replace an element of a vector of doubles in a KeyMap.
Definition: KeyMap.h:504
void putF(std::string const &key, float value, std::string const &comment="")
Add a float.
Definition: KeyMap.h:345
void putF(std::string const &key, std::vector< float > const &vec, std::string const &comment="")
Add a vector of floats.
Definition: KeyMap.h:351
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:454
void append(std::string const &key, int value)
Append an element to a vector of ints in a KeyMap.
Definition: KeyMap.h:468
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:379
std::string getC(std::string const &key, int ind) const
Get one std::string value for a given key.
Definition: KeyMap.h:279
void putC(std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
Add a vector of strings.
Definition: KeyMap.h:408
void putI(std::string const &key, int value, std::string const &comment="")
Add an int.
Definition: KeyMap.h:359
char unsigned getB(std::string const &key, int ind) const
Get one char value for a given key.
Definition: KeyMap.h:256
KeyMap(std::string const &options="")
Construct an empty KeyMap.
Definition: KeyMap.h:93
KeyMap(AstKeyMap *rawKeyMap)
Construct a KeyMap from a raw AstKeyMap.
Definition: KeyMap.h:591
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:421
void append(std::string const &key, Object const &value)
Append an element to a vector of Objects in a KeyMap.
Definition: KeyMap.h:496
std::vector< std::string > getC(std::string const &key) const
Get all std::string values for a given key.
Definition: KeyMap.h:291
DataType type(std::string const &key)
Get the type suffix for a given key.
Definition: KeyMap.h:576
void putD(std::string const &key, std::vector< double > const &vec, std::string const &comment="")
Add a vector of double.
Definition: KeyMap.h:337
void putD(std::string const &key, double value, std::string const &comment="")
Add a double value.
Definition: KeyMap.h:331
Abstract base class for all AST objects.
Definition: Object.h:51
std::string getClassName() const
Get Class: the name of the class (e.g.
Definition: Object.h:139
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:292
T data(T... args)
T get(T... args)
AST wrapper classes and functions.
DataType
Data types held by a KeyMap.
Definition: base.h:62
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
Definition: base.cc:49
T push_back(T... args)
T size(T... args)