LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
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
33namespace ast {
34
35namespace {
36
37void 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
83class KeyMap : public Object {
84 friend class Object;
85 friend class Channel;
86
87public:
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);
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
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
582protected:
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
600private:
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
std::ostream * os
Definition: Schema.cc:557
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
double getD(std::string const &key, int ind) const
Get one double value for a given key.
Definition: KeyMap.h:164
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
Definition: KeyMap.h:197
std::vector< std::string > getC(std::string const &key) const
Get all std::string values for a given key.
Definition: KeyMap.h:291
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
int getI(std::string const &key, int ind) const
Get one int value for a given key.
Definition: KeyMap.h:210
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
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
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
Definition: KeyMap.h:584
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 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
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
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
Definition: KeyMap.h:220
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
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
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
Definition: KeyMap.h:243
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< double > getD(std::string const &key) const
Get all double values for a given key.
Definition: KeyMap.h:174
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
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
Definition: KeyMap.h:266
virtual ~KeyMap()
Definition: KeyMap.h:98
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
KeyMap & operator=(KeyMap const &)=delete
void rename(std::string const &oldKey, std::string const &newKey)
Rename the specified entry.
Definition: KeyMap.h:568
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
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
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
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
Definition: KeyMap.h:107
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
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)