LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
22 #ifndef ASTSHIM_KEYMAP_H
23 #define ASTSHIM_KEYMAP_H
41 os <<
"Key \"" <<
key <<
"\" not found or has an undefined value";
94 :
Object(reinterpret_cast<AstObject *>(astKeyMap(
"%s", options.c_str()))) {
118 bool ret =
static_cast<bool>(
126 int const len =
size();
127 if ((ind < 0) || (ind >= len)) {
129 os <<
"ind = " << ind <<
" not in range [0, " << len - 1 <<
"]";
132 const char *rawKey = astMapKey(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()), ind);
143 bool ret =
static_cast<bool>(
151 int len = astMapLength(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str());
158 int const size = astMapSize(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()));
166 if (!astMapGetElemD(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &retVal)) {
167 throwKeyNotFound(
key);
189 if (!astMapGetElemF(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &retVal)) {
190 throwKeyNotFound(
key);
212 if (!astMapGetElemI(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &retVal)) {
213 throwKeyNotFound(
key);
235 if (!astMapGetElemS(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &retVal)) {
236 throwKeyNotFound(
key);
257 char unsigned retVal;
258 if (!astMapGetElemB(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &retVal)) {
259 throwKeyNotFound(
key);
280 int const maxChar = 1 + astMapLenC(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str());
282 if (!astMapGetElemC(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), maxChar, ind,
284 throwKeyNotFound(
key);
296 int const eltLen = 1 + astMapLenC(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str());
301 for (
int i = 0; i <
size; ++i) {
313 if (!astMapGetElemA(
reinterpret_cast<AstKeyMap
const *
>(
getRawPtr()),
key.
c_str(), ind, &rawObj)) {
314 throwKeyNotFound(
key);
317 return Object::fromAstObject<Object>(rawObj,
true);
324 for (
int i = 0; i <
size; ++i) {
332 astMapPut0D(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), value, comment.c_str());
338 _assertVectorNotEmpty(
key, vec.
size());
346 astMapPut0F(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), value, comment.c_str());
352 _assertVectorNotEmpty(
key, vec.
size());
360 astMapPut0I(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), value, comment.c_str());
366 _assertVectorNotEmpty(
key, vec.
size());
374 astMapPut0S(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), value, comment.c_str());
380 _assertVectorNotEmpty(
key, vec.
size());
388 astMapPut0B(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), value, comment.c_str());
395 _assertVectorNotEmpty(
key, vec.
size());
409 _assertVectorNotEmpty(
key, vec.
size());
422 AstObject *rawCopy =
reinterpret_cast<AstObject *
>(astCopy(obj.
getRawPtr()));
423 astMapPut0A(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), rawCopy, comment.c_str());
430 _assertVectorNotEmpty(
key, vec.
size());
432 for (
int i = 0,
size = vec.size(); i <
size; ++i) {
449 astMapPutU(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), comment.c_str());
455 int const i = _getAppendIndex(
key);
456 astMapPutElemD(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
462 int const i = _getAppendIndex(
key);
463 astMapPutElemF(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
469 int const i = _getAppendIndex(
key);
470 astMapPutElemI(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
476 int const i = _getAppendIndex(
key);
477 astMapPutElemS(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
483 int const i = _getAppendIndex(
key);
484 astMapPutElemB(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
490 int const i = _getAppendIndex(
key);
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);
505 _assertReplaceIndexInRange(
key, i);
506 astMapPutElemD(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
512 _assertReplaceIndexInRange(
key, i);
513 astMapPutElemF(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
519 _assertReplaceIndexInRange(
key, i);
520 astMapPutElemI(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
526 _assertReplaceIndexInRange(
key, i);
527 astMapPutElemS(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
533 _assertReplaceIndexInRange(
key, i);
534 astMapPutElemB(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, value);
540 _assertReplaceIndexInRange(
key, i);
547 _assertReplaceIndexInRange(
key, i);
548 AstObject *rawCopy =
reinterpret_cast<AstObject *
>(astCopy(value.
getRawPtr()));
549 astMapPutElemA(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str(), i, rawCopy);
577 int retVal = astMapType(
reinterpret_cast<AstKeyMap *
>(
getRawPtr()),
key.
c_str());
579 return static_cast<DataType>(retVal);
585 return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
591 explicit KeyMap(AstKeyMap *rawKeyMap) :
Object(reinterpret_cast<AstObject *>(rawKeyMap)) {
594 os <<
"this is a " <<
getClassName() <<
", which is not a KeyMap";
604 os <<
"vector supplied for key \"" <<
key <<
"\" has zero elements";
610 void _assertReplaceIndexInRange(
std::string const &
key,
int i)
const {
612 if ((i < 0) || (i >= len)) {
614 os <<
"i = " << i <<
" not in range [0, " << len - 1 <<
"] for key \"" <<
key <<
"\"";
624 os <<
"key \"" <<
key <<
"\" not found";
void remove(std::string const &key)
Remove the specified entry.
std::vector< char unsigned > getB(std::string const &key) const
Get all char values for a given key.
KeyMap(KeyMap &&)=default
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
void append(std::string const &key, short int value)
Append an element to a vector of short int in a KeyMap.
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
char unsigned getB(std::string const &key, int ind) const
Get one char value for a given key.
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.
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.
void putD(std::string const &key, double value, std::string const &comment="")
Add a double value.
bool defined(std::string const &key) const
Does this map contain the specified key, and if so, does it have a defined value?
Abstract base class for all AST objects.
KeyMap & operator=(KeyMap &&)=default
int getI(std::string const &key, int ind) const
Get one int value for a given key.
void putD(std::string const &key, std::vector< double > const &vec, std::string const &comment="")
Add a vector of double.
void putF(std::string const &key, std::vector< float > const &vec, std::string const &comment="")
Add a vector of floats.
DataType type(std::string const &key)
Get the type suffix for a given key.
Channel provides input/output of AST objects.
std::string getClassName() const
Get Class: the name of the class (e.g.
std::string key(int ind) const
Get the key at the specified index.
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
void replace(std::string const &key, int i, float value)
Replace an element of a vector of floats in a KeyMap.
void replace(std::string const &key, int i, char unsigned value)
Replace an element of a vector of char in a KeyMap.
std::vector< std::string > getC(std::string const &key) const
Get all std::string values for a given key.
std::string getC(std::string const &key, int ind) const
Get one std::string value for a given key.
void putI(std::string const &key, int value, std::string const &comment="")
Add an int.
KeyMap(std::string const &options="")
Construct an empty KeyMap.
void rename(std::string const &oldKey, std::string const &newKey)
Rename the specified entry.
void append(std::string const &key, Object const &value)
Append an element to a vector of Objects in a KeyMap.
void putF(std::string const &key, float value, std::string const &comment="")
Add a float.
void putB(std::string const &key, char unsigned value, std::string const &comment="")
Add a char.
void append(std::string const &key, float value)
Append an element to a vector of floats in a KeyMap.
void append(std::string const &key, std::string const &value)
Append an element to a vector of strings in a KeyMap.
void replace(std::string const &key, int i, double value)
Replace an element of a vector of doubles in a KeyMap.
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
void putC(std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
Add a vector of strings.
void replace(std::string const &key, int i, std::string const &value)
Replace an element of a vector of strings in a KeyMap.
AST wrapper classes and functions.
void replace(std::string const &key, int i, short int value)
Replace an element of a vector of short int in a KeyMap.
void append(std::string const &key, int value)
Append an element to a vector of ints in a KeyMap.
float getF(std::string const &key, int ind) const
Get one float value for a given key.
std::shared_ptr< Object > getA(std::string const &key, int ind) const
Get one Object for a given key; the object is deep copied.
KeyMap(KeyMap const &)=default
Copy constructor: make a deep copy.
short int getS(std::string const &key, int ind) const
Get one short int value for a given key.
void putI(std::string const &key, std::vector< int > const &vec, std::string const &comment="")
Add a vector of ints.
void putS(std::string const &key, std::vector< short int > const &vec, std::string const &comment="")
Add a vector of short int.
void putB(std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
Add a vector of chars.
void replace(std::string const &key, int i, Object const &value)
Replace an element of a vector of Objects in a KeyMap.
DataType
Data types held by a KeyMap.
std::shared_ptr< KeyMap > copy() const
Return a deep copy of this object.
AstObject const * getRawPtr() const
Get the raw AST pointer.
void putU(std::string const &key, std::string const &comment="")
Add a new entry, but no value is stored with the entry.
void append(std::string const &key, char unsigned value)
Append an element to a vector of char in a KeyMap.
std::vector< std::shared_ptr< Object > > getA(std::string const &key) const
Get all Objects for a given key; each object is deep copied.
bool hasKey(std::string const &key) const
Does this map contain the specified key?
double getD(std::string const &key, int ind) const
Get one double value for a given key.
KeyMap(AstKeyMap *rawKeyMap)
Construct a KeyMap from a raw AstKeyMap.
void replace(std::string const &key, int i, int value)
Replace an element of a vector of ints in a KeyMap.
std::vector< float > getF(std::string const &key) const
Get all float values for a given key.
int size() const
Get the number of keys.
std::vector< double > getD(std::string const &key) const
Get all double values for a given key.
std::vector< int > getI(std::string const &key) const
Get all int values for a given key.
void putS(std::string const &key, short int value, std::string const &comment="")
Add a short int.
std::vector< short int > getS(std::string const &key) const
Get all short int values for a given key.
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
KeyMap & operator=(KeyMap const &)=delete
KeyMap is used to store a set of values with associated keys which identify the values.