LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
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 
96  virtual ~KeyMap(){};
97 
99  KeyMap(KeyMap const &) = default;
100  KeyMap(KeyMap &&) = default;
101  KeyMap &operator=(KeyMap const &) = delete;
102  KeyMap &operator=(KeyMap &&) = default;
103 
107  assertOK();
108  }
109 
115  bool defined(std::string const &key) const {
116  bool ret = static_cast<bool>(
117  astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
118  assertOK();
119  return ret;
120  }
121 
123  std::string key(int ind) const {
124  int const len = size();
125  if ((ind < 0) || (ind >= len)) {
127  os << "ind = " << ind << " not in range [0, " << len - 1 << "]";
128  throw std::invalid_argument(os.str());
129  }
130  const char *rawKey = astMapKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), ind);
131  assertOK();
132  return std::string(rawKey);
133  }
134 
140  bool hasKey(std::string const &key) const {
141  bool ret = static_cast<bool>(
142  astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
143  assertOK();
144  return ret;
145  }
146 
148  int length(std::string const &key) const {
149  int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
150  assertOK();
151  return len;
152  }
153 
155  int size() const {
156  int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
157  assertOK();
158  return size;
159  }
160 
162  double getD(std::string const &key, int ind) const {
163  double retVal;
164  if (!astMapGetElemD(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
165  throwKeyNotFound(key);
166  }
167  assertOK();
168  return retVal;
169  }
170 
173  int const size = length(key);
174  std::vector<double> retVec(size);
175  if (size > 0) {
176  int nret; // should equal size after the call
177  astMapGet1D(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
178  retVec.data());
179  }
180  assertOK();
181  return retVec;
182  }
183 
185  float getF(std::string const &key, int ind) const {
186  float retVal;
187  if (!astMapGetElemF(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
188  throwKeyNotFound(key);
189  }
190  assertOK();
191  return retVal;
192  }
193 
196  int const size = length(key);
197  std::vector<float> retVec(size);
198  if (size > 0) {
199  int nret; // should equal size after the call
200  astMapGet1F(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
201  retVec.data());
202  }
203  assertOK();
204  return retVec;
205  }
206 
208  int getI(std::string const &key, int ind) const {
209  int retVal;
210  if (!astMapGetElemI(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
211  throwKeyNotFound(key);
212  }
213  assertOK();
214  return retVal;
215  }
216 
219  int const size = length(key);
220  std::vector<int> retVec(size);
221  if (size > 0) {
222  int nret; // should equal size after the call
223  astMapGet1I(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
224  retVec.data());
225  }
226  assertOK();
227  return retVec;
228  }
229 
231  short int getS(std::string const &key, int ind) const {
232  short int retVal;
233  if (!astMapGetElemS(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
234  throwKeyNotFound(key);
235  }
236  assertOK();
237  return retVal;
238  }
239 
242  int const size = length(key);
243  std::vector<short int> retVec(size);
244  if (size > 0) {
245  int nret; // should equal size after the call
246  astMapGet1S(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
247  retVec.data());
248  }
249  assertOK();
250  return retVec;
251  }
252 
254  char unsigned getB(std::string const &key, int ind) const {
255  char unsigned retVal;
256  if (!astMapGetElemB(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &retVal)) {
257  throwKeyNotFound(key);
258  }
259  assertOK();
260  return retVal;
261  }
262 
265  int const size = length(key);
266  std::vector<char unsigned> retVec(size);
267  if (size > 0) {
268  int nret; // should equal size after the call
269  astMapGet1B(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), size, &nret,
270  retVec.data());
271  }
272  assertOK();
273  return retVec;
274  }
275 
277  std::string getC(std::string const &key, int ind) const {
278  int const maxChar = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
279  std::unique_ptr<char[]> cstr(new char[maxChar]);
280  if (!astMapGetElemC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), maxChar, ind,
281  cstr.get())) {
282  throwKeyNotFound(key);
283  }
284  assertOK();
285  return std::string(cstr.get());
286  }
287 
290  int const size = length(key);
292  if (size > 0) {
293  // # of chars for each entry; the +1 is needed to provide space for the terminating null
294  int const eltLen = 1 + astMapLenC(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
295  std::unique_ptr<char[]> cstr(new char[size * eltLen]);
296  int nret; // should equal size after the call
297  astMapGet1C(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), eltLen, size, &nret,
298  cstr.get());
299  for (int i = 0; i < size; ++i) {
300  retVec.push_back(std::string(cstr.get() + i * eltLen));
301  }
302  }
303  assertOK();
304  return retVec;
305  }
306 
308  std::shared_ptr<Object> getA(std::string const &key, int ind) const {
310  AstObject *rawObj;
311  if (!astMapGetElemA(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str(), ind, &rawObj)) {
312  throwKeyNotFound(key);
313  }
314  assertOK();
315  return Object::fromAstObject<Object>(rawObj, true);
316  }
317 
320  int const size = length(key);
322  for (int i = 0; i < size; ++i) {
323  retVec.push_back(getA(key, i));
324  }
325  return retVec;
326  }
327 
329  void putD(std::string const &key, double value, std::string const &comment = "") {
330  astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
331  assertOK();
332  }
333 
335  void putD(std::string const &key, std::vector<double> const &vec, std::string const &comment = "") {
336  _assertVectorNotEmpty(key, vec.size());
337  astMapPut1D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
338  comment.c_str());
339  assertOK();
340  }
341 
343  void putF(std::string const &key, float value, std::string const &comment = "") {
344  astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
345  assertOK();
346  }
347 
349  void putF(std::string const &key, std::vector<float> const &vec, std::string const &comment = "") {
350  _assertVectorNotEmpty(key, vec.size());
351  astMapPut1F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
352  comment.c_str());
353  assertOK();
354  }
355 
357  void putI(std::string const &key, int value, std::string const &comment = "") {
358  astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
359  assertOK();
360  }
361 
363  void putI(std::string const &key, std::vector<int> const &vec, std::string const &comment = "") {
364  _assertVectorNotEmpty(key, vec.size());
365  astMapPut1I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
366  comment.c_str());
367  assertOK();
368  }
369 
371  void putS(std::string const &key, short int value, std::string const &comment = "") {
372  astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
373  assertOK();
374  }
375 
377  void putS(std::string const &key, std::vector<short int> const &vec, std::string const &comment = "") {
378  _assertVectorNotEmpty(key, vec.size());
379  astMapPut1S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
380  comment.c_str());
381  assertOK();
382  }
383 
385  void putB(std::string const &key, char unsigned value, std::string const &comment = "") {
386  astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
387  assertOK();
388  }
389 
392  std::string const &comment = "") {
393  _assertVectorNotEmpty(key, vec.size());
394  astMapPut1B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), vec.size(), vec.data(),
395  comment.c_str());
396  assertOK();
397  }
398 
400  void putC(std::string const &key, std::string const &value, std::string const &comment = "") {
401  astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
402  assertOK();
403  }
404 
406  void putC(std::string const &key, std::vector<std::string> const &vec, std::string const &comment = "") {
407  _assertVectorNotEmpty(key, vec.size());
408  // to simplify memory management, create the key with the first element and append the rest
409  for (int i = 0, size = vec.size(); i < size; ++i) {
410  if (i == 0) {
411  putC(key, vec[0]);
412  } else {
413  append(key, vec[i]);
414  }
415  }
416  }
417 
419  void putA(std::string const &key, Object const &obj, std::string const &comment = "") {
420  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(obj.getRawPtr()));
421  astMapPut0A(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), rawCopy, comment.c_str());
422  assertOK(rawCopy);
423  }
424 
427  std::string const &comment = "") {
428  _assertVectorNotEmpty(key, vec.size());
429  // to simplify memory management, create the key with the first element and append the rest
430  for (int i = 0, size = vec.size(); i < size; ++i) {
431  if (i == 0) {
432  // initialize the key with the first element
433  putA(key, *vec[0]);
434  } else {
435  append(key, *vec[i]);
436  }
437  }
438  }
439 
446  void putU(std::string const &key, std::string const &comment = "") {
447  astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
448  assertOK();
449  }
450 
452  void append(std::string const &key, double value) {
453  int const i = _getAppendIndex(key);
454  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
455  assertOK();
456  }
457 
459  void append(std::string const &key, float value) {
460  int const i = _getAppendIndex(key);
461  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
462  assertOK();
463  }
464 
466  void append(std::string const &key, int value) {
467  int const i = _getAppendIndex(key);
468  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
469  assertOK();
470  }
471 
473  void append(std::string const &key, short int value) {
474  int const i = _getAppendIndex(key);
475  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
476  assertOK();
477  }
478 
480  void append(std::string const &key, char unsigned value) {
481  int const i = _getAppendIndex(key);
482  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
483  assertOK();
484  }
485 
487  void append(std::string const &key, std::string const &value) {
488  int const i = _getAppendIndex(key);
489  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
490  assertOK();
491  }
492 
494  void append(std::string const &key, Object const &value) {
495  int const i = _getAppendIndex(key);
496  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
497  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
498  assertOK(rawCopy);
499  }
500 
502  void replace(std::string const &key, int i, double value) {
503  _assertReplaceIndexInRange(key, i);
504  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
505  assertOK();
506  }
507 
509  void replace(std::string const &key, int i, float value) {
510  _assertReplaceIndexInRange(key, i);
511  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
512  assertOK();
513  }
514 
516  void replace(std::string const &key, int i, int value) {
517  _assertReplaceIndexInRange(key, i);
518  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
519  assertOK();
520  }
521 
523  void replace(std::string const &key, int i, short int value) {
524  _assertReplaceIndexInRange(key, i);
525  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
526  assertOK();
527  }
528 
530  void replace(std::string const &key, int i, char unsigned value) {
531  _assertReplaceIndexInRange(key, i);
532  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
533  assertOK();
534  }
535 
537  void replace(std::string const &key, int i, std::string const &value) {
538  _assertReplaceIndexInRange(key, i);
539  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
540  assertOK();
541  }
542 
544  void replace(std::string const &key, int i, Object const &value) {
545  _assertReplaceIndexInRange(key, i);
546  AstObject *rawCopy = reinterpret_cast<AstObject *>(astCopy(value.getRawPtr()));
547  astMapPutElemA(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, rawCopy);
548  assertOK(rawCopy);
549  }
550 
556  void remove(std::string const &key) {
557  astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
558  assertOK();
559  }
560 
566  void rename(std::string const &oldKey, std::string const &newKey) {
567  astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
568  assertOK();
569  }
570 
575  int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
576  assertOK();
577  return static_cast<DataType>(retVal);
578  }
579 
580 protected:
581  // Protected implementation of deep-copy.
582  virtual std::shared_ptr<Object> copyPolymorphic() const override {
583  return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
584  }
585 
589  explicit KeyMap(AstKeyMap *rawKeyMap) : Object(reinterpret_cast<AstObject *>(rawKeyMap)) {
590  if (!astIsAKeyMap(getRawPtr())) {
592  os << "this is a " << getClassName() << ", which is not a KeyMap";
593  throw std::invalid_argument(os.str());
594  }
595  assertOK();
596  }
597 
598 private:
599  void _assertVectorNotEmpty(std::string const &key, int size) const {
600  if (size == 0) {
602  os << "vector supplied for key \"" << key << "\" has zero elements";
603  throw std::invalid_argument(os.str());
604  }
605  }
606 
607  // replace silently fails if index out of range, so check it here
608  void _assertReplaceIndexInRange(std::string const &key, int i) const {
609  int const len = length(key);
610  if ((i < 0) || (i >= len)) {
612  os << "i = " << i << " not in range [0, " << len - 1 << "] for key \"" << key << "\"";
613  throw std::invalid_argument(os.str());
614  }
615  }
616 
617  // retrieve the index required to append a value to a key, and make sure the key exists
618  int _getAppendIndex(std::string const &key) const {
619  int const i = length(key);
620  if (i == 0) {
622  os << "key \"" << key << "\" not found";
623  throw std::invalid_argument(os.str());
624  }
625  return i;
626  }
627 };
628 
629 } // namespace ast
630 
631 #endif
void rename(std::string const &oldKey, std::string const &newKey)
Rename the specified entry.
Definition: KeyMap.h:566
void append(std::string const &key, short int value)
Append an element to a vector of short int in a KeyMap.
Definition: KeyMap.h:473
void replace(std::string const &key, int i, int value)
Replace an element of a vector of ints in a KeyMap.
Definition: KeyMap.h:516
void putI(std::string const &key, std::vector< int > const &vec, std::string const &comment="")
Add a vector of ints.
Definition: KeyMap.h:363
KeyMap is used to store a set of values with associated keys which identify the values.
Definition: KeyMap.h:83
int getI(std::string const &key, int ind) const
Get one int value for a given key.
Definition: KeyMap.h:208
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:446
short int getS(std::string const &key, int ind) const
Get one short int value for a given key.
Definition: KeyMap.h:231
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
KeyMap(std::string const &options="")
Construct an empty KeyMap.
Definition: KeyMap.h:93
AST wrapper classes and functions.
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:537
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
Definition: KeyMap.h:582
void putB(std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
Add a vector of chars.
Definition: KeyMap.h:391
std::string getClassName() const
Get Class: the name of the class (e.g.
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:406
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:115
Channel provides input/output of AST objects.
Definition: Channel.h:60
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
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:289
void putI(std::string const &key, int value, std::string const &comment="")
Add an int.
Definition: KeyMap.h:357
double getD(std::string const &key, int ind) const
Get one double value for a given key.
Definition: KeyMap.h:162
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:523
tuple options
Definition: lsstimport.py:47
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:148
int size() const
Get the number of keys.
Definition: KeyMap.h:155
void putF(std::string const &key, std::vector< float > const &vec, std::string const &comment="")
Add a vector of floats.
Definition: KeyMap.h:349
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
Definition: KeyMap.h:195
void append(std::string const &key, float value)
Append an element to a vector of floats in a KeyMap.
Definition: KeyMap.h:459
void replace(std::string const &key, int i, double value)
Replace an element of a vector of doubles in a KeyMap.
Definition: KeyMap.h:502
std::string getC(std::string const &key, int ind) const
Get one std::string value for a given key.
Definition: KeyMap.h:277
std::vector< double > getD(std::string const &key) const
Get all double values for a given key.
Definition: KeyMap.h:172
void replace(std::string const &key, int i, float value)
Replace an element of a vector of floats in a KeyMap.
Definition: KeyMap.h:509
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
Definition: KeyMap.h:241
void append(std::string const &key, int value)
Append an element to a vector of ints in a KeyMap.
Definition: KeyMap.h:466
void putS(std::string const &key, short int value, std::string const &comment="")
Add a short int.
Definition: KeyMap.h:371
STL class.
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:452
void putB(std::string const &key, char unsigned value, std::string const &comment="")
Add a char.
Definition: KeyMap.h:385
T push_back(T... args)
void append(std::string const &key, std::string const &value)
Append an element to a vector of strings in a KeyMap.
Definition: KeyMap.h:487
void append(std::string const &key, char unsigned value)
Append an element to a vector of char in a KeyMap.
Definition: KeyMap.h:480
T data(T... args)
bool hasKey(std::string const &key) const
Does this map contain the specified key?
Definition: KeyMap.h:140
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:530
virtual ~KeyMap()
Definition: KeyMap.h:96
void putD(std::string const &key, std::vector< double > const &vec, std::string const &comment="")
Add a vector of double.
Definition: KeyMap.h:335
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:544
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:377
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
Definition: KeyMap.h:105
void putF(std::string const &key, float value, std::string const &comment="")
Add a float.
Definition: KeyMap.h:343
T str(T... args)
char unsigned getB(std::string const &key, int ind) const
Get one char value for a given key.
Definition: KeyMap.h:254
T static_pointer_cast(T... args)
KeyMap & operator=(KeyMap const &)=delete
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
Definition: KeyMap.h:264
T size(T... args)
STL class.
Key< U > key
Definition: Schema.cc:281
DataType
Data types held by a KeyMap.
Definition: base.h:62
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
float getF(std::string const &key, int ind) const
Get one float value for a given key.
Definition: KeyMap.h:185
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:308
T c_str(T... args)
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:319
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:400
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:419
void append(std::string const &key, Object const &value)
Append an element to a vector of Objects in a KeyMap.
Definition: KeyMap.h:494
KeyMap(AstKeyMap *rawKeyMap)
Construct a KeyMap from a raw AstKeyMap.
Definition: KeyMap.h:589
Abstract base class for all AST objects.
Definition: Object.h:51
DataType type(std::string const &key)
Get the type suffix for a given key.
Definition: KeyMap.h:574
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:426
void putD(std::string const &key, double value, std::string const &comment="")
Add a double value.
Definition: KeyMap.h:329
std::ostream * os
Definition: Schema.cc:746
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
Definition: KeyMap.h:218