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
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
ast::KeyMap Class Reference

KeyMap is used to store a set of values with associated keys which identify the values. More...

#include <KeyMap.h>

Inheritance diagram for ast::KeyMap:
ast::Object

Public Types

using ObjectPtr = std::unique_ptr< AstObject, Deleter >
 unique pointer holding an AST raw pointer More...
 

Public Member Functions

 KeyMap (std::string const &options="")
 Construct an empty KeyMap. More...
 
virtual ~KeyMap ()
 
 KeyMap (KeyMap const &)=default
 Copy constructor: make a deep copy. More...
 
 KeyMap (KeyMap &&)=default
 
KeyMapoperator= (KeyMap const &)=delete
 
KeyMapoperator= (KeyMap &&)=default
 
std::shared_ptr< KeyMapcopy () const
 Return a deep copy of this object. More...
 
bool defined (std::string const &key) const
 Does this map contain the specified key, and if so, does it have a defined value? More...
 
std::string key (int ind) const
 Get the key at the specified index. More...
 
bool hasKey (std::string const &key) const
 Does this map contain the specified key? More...
 
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. More...
 
int size () const
 Get the number of keys. More...
 
double getD (std::string const &key, int ind) const
 Get one double value for a given key. More...
 
std::vector< double > getD (std::string const &key) const
 Get all double values for a given key. More...
 
float getF (std::string const &key, int ind) const
 Get one float value for a given key. More...
 
std::vector< float > getF (std::string const &key) const
 Get all float values for a given key. More...
 
int getI (std::string const &key, int ind) const
 Get one int value for a given key. More...
 
std::vector< int > getI (std::string const &key) const
 Get all int values for a given key. More...
 
short int getS (std::string const &key, int ind) const
 Get one short int value for a given key. More...
 
std::vector< short int > getS (std::string const &key) const
 Get all short int values for a given key. More...
 
char unsigned getB (std::string const &key, int ind) const
 Get one char value for a given key. More...
 
std::vector< char unsigned > getB (std::string const &key) const
 Get all char values for a given key. More...
 
std::string getC (std::string const &key, int ind) const
 Get one std::string value for a given key. More...
 
std::vector< std::stringgetC (std::string const &key) const
 Get all std::string values for a given key. More...
 
std::shared_ptr< ObjectgetA (std::string const &key, int ind) const
 Get one Object for a given key; the object is deep copied. More...
 
std::vector< std::shared_ptr< Object > > getA (std::string const &key) const
 Get all Objects for a given key; each object is deep copied. More...
 
void putD (std::string const &key, double value, std::string const &comment="")
 Add a double value. More...
 
void putD (std::string const &key, std::vector< double > const &vec, std::string const &comment="")
 Add a vector of double. More...
 
void putF (std::string const &key, float value, std::string const &comment="")
 Add a float. More...
 
void putF (std::string const &key, std::vector< float > const &vec, std::string const &comment="")
 Add a vector of floats. More...
 
void putI (std::string const &key, int value, std::string const &comment="")
 Add an int. More...
 
void putI (std::string const &key, std::vector< int > const &vec, std::string const &comment="")
 Add a vector of ints. More...
 
void putS (std::string const &key, short int value, std::string const &comment="")
 Add a short int. More...
 
void putS (std::string const &key, std::vector< short int > const &vec, std::string const &comment="")
 Add a vector of short int. More...
 
void putB (std::string const &key, char unsigned value, std::string const &comment="")
 Add a char. More...
 
void putB (std::string const &key, std::vector< char unsigned > const &vec, std::string const &comment="")
 Add a vector of chars. More...
 
void putC (std::string const &key, std::string const &value, std::string const &comment="")
 Add a string. More...
 
void putC (std::string const &key, std::vector< std::string > const &vec, std::string const &comment="")
 Add a vector of strings. More...
 
void putA (std::string const &key, Object const &obj, std::string const &comment="")
 Add an Object, which is deep copied. More...
 
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. More...
 
void putU (std::string const &key, std::string const &comment="")
 Add a new entry, but no value is stored with the entry. More...
 
void append (std::string const &key, double value)
 Append an element to a vector of doubles in a KeyMap. More...
 
void append (std::string const &key, float value)
 Append an element to a vector of floats in a KeyMap. More...
 
void append (std::string const &key, int value)
 Append an element to a vector of ints in a KeyMap. More...
 
void append (std::string const &key, short int value)
 Append an element to a vector of short int in a KeyMap. More...
 
void append (std::string const &key, char unsigned value)
 Append an element to a vector of char in a KeyMap. More...
 
void append (std::string const &key, std::string const &value)
 Append an element to a vector of strings in a KeyMap. More...
 
void append (std::string const &key, Object const &value)
 Append an element to a vector of Objects in a KeyMap. More...
 
void replace (std::string const &key, int i, double value)
 Replace an element of a vector of doubles in a KeyMap. More...
 
void replace (std::string const &key, int i, float value)
 Replace an element of a vector of floats in a KeyMap. More...
 
void replace (std::string const &key, int i, int value)
 Replace an element of a vector of ints in a KeyMap. More...
 
void replace (std::string const &key, int i, short int value)
 Replace an element of a vector of short int in a KeyMap. More...
 
void replace (std::string const &key, int i, char unsigned value)
 Replace an element of a vector of char in a KeyMap. More...
 
void replace (std::string const &key, int i, std::string const &value)
 Replace an element of a vector of strings in a KeyMap. More...
 
void replace (std::string const &key, int i, Object const &value)
 Replace an element of a vector of Objects in a KeyMap. More...
 
void remove (std::string const &key)
 Remove the specified entry. More...
 
void rename (std::string const &oldKey, std::string const &newKey)
 Rename the specified entry. More...
 
DataType type (std::string const &key)
 Get the type suffix for a given key. More...
 
bool operator== (Object const &rhs) const
 Return True if this and rhs are the equal. More...
 
bool operator!= (Object const &rhs) const
 Return True if this and rhs are not equal. More...
 
void clear (std::string const &attrib)
 Clear the values of a specified set of attributes for an Object. More...
 
bool hasAttribute (std::string const &attrib) const
 Does this object have an attribute with the specified name? More...
 
std::string getClassName () const
 Get Class: the name of the class (e.g. More...
 
std::string getID () const
 Get ID: object identification string that is not copied. More...
 
std::string getIdent () const
 Get Ident: object identification string that is copied. More...
 
int getNObject () const
 Get NObject: number of AST objects in existence of the same type as the underlying AST class. More...
 
int getObjSize () const
 Get ObjSize: the in-memory size of the AST object in bytes. More...
 
int getRefCount () const
 Get RefCount: number of active pointers to the underlying AST object. More...
 
bool getUseDefs () const
 Get UseDefs: allow use of default values for Object attributes? More...
 
void lock (bool wait)
 Lock this object for exclusive use by the calling thread. More...
 
bool same (Object const &other) const
 Does this contain the same AST object as another? More...
 
void setID (std::string const &id)
 Set ID: object identification string that is not copied. More...
 
void setIdent (std::string const &ident)
 Set Ident: object identification string that is copied. More...
 
void setUseDefs (bool usedefs)
 Set UseDefs: allow use of default values for Object attributes? More...
 
void show (std::ostream &os, bool showComments=true) const
 Print a textual description the object to an ostream. More...
 
std::string show (bool showComments=true) const
 Return a textual description the object as a string. More...
 
bool test (std::string const &attrib) const
 Has this attribute been explicitly set (and not subsequently cleared)? More...
 
void unlock (bool report=false)
 Unlock this object previously locked using lock, so that other threads can use this object. More...
 
AstObject const * getRawPtr () const
 Get the raw AST pointer. More...
 
AstObject * getRawPtr ()
 Get the raw AST pointer. More...
 

Static Public Member Functions

static std::shared_ptr< ObjectfromString (std::string const &str)
 Construct an Object from a string, using astFromString. More...
 
template<typename Class >
static std::shared_ptr< Class > fromAstObject (AstObject *rawObj, bool copy)
 Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type. More...
 

Protected Member Functions

virtual std::shared_ptr< ObjectcopyPolymorphic () const override
 Return a deep copy of this object. More...
 
 KeyMap (AstKeyMap *rawKeyMap)
 Construct a KeyMap from a raw AstKeyMap. More...
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 Implementation of deep copy. More...
 
long int getL (std::string const &attrib) const
 Get the value of an attribute as a long int. More...
 
void set (std::string const &setting)
 Assign a set of attribute values, over-riding any previous values. More...
 
void setB (std::string const &attrib, bool value)
 Set the value of an attribute as a bool. More...
 
void setC (std::string const &attrib, std::string const &value)
 Set the value of an attribute as a string. More...
 
void setD (std::string const &attrib, double value)
 Set the value of an attribute as a double. More...
 
void setF (std::string const &attrib, float value)
 Set the value of an attribute as a float. More...
 
void setI (std::string const &attrib, int value)
 Set the value of an attribute as an int. More...
 
void setL (std::string const &attrib, long int value)
 Set the value of an attribute as a long int. More...
 

Static Protected Member Functions

template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > makeShim (AstObject *p)
 Functor to make an astshim instance from a raw AST pointer of the corresponding type. More...
 

Friends

class Object
 
class Channel
 

Detailed Description

KeyMap is used to store a set of values with associated keys which identify the values.

The keys are strings. These may be case sensitive or insensitive as selected by the KeyCase attribute, and trailing spaces are ignored. Each key is associated a vector of values of a particular type, which is one of the following, where the single letter is the suffix for the associated setter or getter, such as getD, putD or replaceD:

Despite the name, KeyMap is not a Mapping.

The getters will attempt to cast the data into the requested form. The setters come in three forms:

Attributes

KeyMap has the following attributes, in addition to those inherited from Object

Definition at line 83 of file KeyMap.h.

Member Typedef Documentation

◆ ObjectPtr

using ast::Object::ObjectPtr = std::unique_ptr<AstObject, Deleter>
inherited

unique pointer holding an AST raw pointer

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ KeyMap() [1/4]

ast::KeyMap::KeyMap ( std::string const &  options = "")
inlineexplicit

Construct an empty KeyMap.

Parameters
[in]optionsComma-separated list of attribute assignments.

Definition at line 93 of file KeyMap.h.

94  : Object(reinterpret_cast<AstObject *>(astKeyMap("%s", options.c_str()))) {}
tuple options
Definition: lsstimport.py:47
friend class Object
Definition: KeyMap.h:84

◆ ~KeyMap()

virtual ast::KeyMap::~KeyMap ( )
inlinevirtual

Definition at line 96 of file KeyMap.h.

96 {};

◆ KeyMap() [2/4]

ast::KeyMap::KeyMap ( KeyMap const &  )
default

Copy constructor: make a deep copy.

◆ KeyMap() [3/4]

ast::KeyMap::KeyMap ( KeyMap &&  )
default

◆ KeyMap() [4/4]

ast::KeyMap::KeyMap ( AstKeyMap *  rawKeyMap)
inlineexplicitprotected

Construct a KeyMap from a raw AstKeyMap.

Definition at line 589 of file KeyMap.h.

589  : 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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
std::string getClassName() const
Get Class: the name of the class (e.g.
Definition: Object.h:138
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T str(T... args)
friend class Object
Definition: KeyMap.h:84
std::ostream * os
Definition: Schema.cc:746

Member Function Documentation

◆ append() [1/7]

void ast::KeyMap::append ( std::string const &  key,
double  value 
)
inline

Append an element to a vector of doubles in a KeyMap.

Definition at line 452 of file KeyMap.h.

452  {
453  int const i = _getAppendIndex(key);
454  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
455  assertOK();
456  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [2/7]

void ast::KeyMap::append ( std::string const &  key,
float  value 
)
inline

Append an element to a vector of floats in a KeyMap.

Definition at line 459 of file KeyMap.h.

459  {
460  int const i = _getAppendIndex(key);
461  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
462  assertOK();
463  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [3/7]

void ast::KeyMap::append ( std::string const &  key,
int  value 
)
inline

Append an element to a vector of ints in a KeyMap.

Definition at line 466 of file KeyMap.h.

466  {
467  int const i = _getAppendIndex(key);
468  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
469  assertOK();
470  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [4/7]

void ast::KeyMap::append ( std::string const &  key,
short int  value 
)
inline

Append an element to a vector of short int in a KeyMap.

Definition at line 473 of file KeyMap.h.

473  {
474  int const i = _getAppendIndex(key);
475  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
476  assertOK();
477  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [5/7]

void ast::KeyMap::append ( std::string const &  key,
char unsigned  value 
)
inline

Append an element to a vector of char in a KeyMap.

Definition at line 480 of file KeyMap.h.

480  {
481  int const i = _getAppendIndex(key);
482  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
483  assertOK();
484  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [6/7]

void ast::KeyMap::append ( std::string const &  key,
std::string const &  value 
)
inline

Append an element to a vector of strings in a KeyMap.

Definition at line 487 of file KeyMap.h.

487  {
488  int const i = _getAppendIndex(key);
489  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
490  assertOK();
491  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ append() [7/7]

void ast::KeyMap::append ( std::string const &  key,
Object const &  value 
)
inline

Append an element to a vector of Objects in a KeyMap.

Definition at line 494 of file KeyMap.h.

494  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ clear()

void ast::Object::clear ( std::string const &  attrib)
inlineinherited

Clear the values of a specified set of attributes for an Object.

Clearing an attribute cancels any value that has previously been explicitly set for it, so that the standard default attribute value will subsequently be used instead. This also causes the astTest function to return the value zero for the attribute, indicating that no value has been set.

Definition at line 118 of file Object.h.

118  {
119  astClear(getRawPtr(), attrib.c_str());
120  assertOK();
121  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ copy()

std::shared_ptr<KeyMap> ast::KeyMap::copy ( ) const
inline

Return a deep copy of this object.

Definition at line 105 of file KeyMap.h.

105  {
107  assertOK();
108  }
KeyMap(std::string const &options="")
Construct an empty KeyMap.
Definition: KeyMap.h:93
virtual std::shared_ptr< Object > copyPolymorphic() const override
Return a deep copy of this object.
Definition: KeyMap.h:582
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T static_pointer_cast(T... args)

◆ copyImpl()

template<typename T , typename AstT >
std::shared_ptr<T> ast::Object::copyImpl ( ) const
inlineprotectedinherited

Implementation of deep copy.

Should be called to implement copyPolymorphic by all derived classes.

Definition at line 319 of file Object.h.

319  {
320  auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
321  auto retptr = std::shared_ptr<T>(new T(rawptr));
322  assertOK();
323  return retptr;
324  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ copyPolymorphic()

virtual std::shared_ptr<Object> ast::KeyMap::copyPolymorphic ( ) const
inlineoverrideprotectedvirtual

Return a deep copy of this object.

This is called by copy.

Each subclass must override this method. The standard implementation is:

return copyImpl<astshim_class, ast_class>();

for example Frame implements this as:

return copyImpl<Frame, AstFrame>();

Implements ast::Object.

Definition at line 582 of file KeyMap.h.

582  {
583  return std::static_pointer_cast<KeyMap>(copyImpl<KeyMap, AstKeyMap>());
584  }
KeyMap(std::string const &options="")
Construct an empty KeyMap.
Definition: KeyMap.h:93
T static_pointer_cast(T... args)

◆ defined()

bool ast::KeyMap::defined ( std::string const &  key) const
inline

Does this map contain the specified key, and if so, does it have a defined value?

See also hasKey, which does not check if the value is defined

Definition at line 115 of file KeyMap.h.

115  {
116  bool ret = static_cast<bool>(
117  astMapDefined(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
118  assertOK();
119  return ret;
120  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ fromAstObject()

template<typename Class >
template std::shared_ptr< Object > ast::Object::fromAstObject< Object > ( AstObject *  rawObj,
bool  copy 
)
staticinherited

Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.

The returned object takes ownership of the pointer. This is almost always what you want, for instance astDecompose returns shallow copies of the internal pointers.

Template Parameters
ClassThe class of the returned shared pointer. (The actual class will be the correct class of rawPtr.)
Parameters
[in]rawObjA bare AST object pointer
[in]copyIf True then make a deep copy of the pointer (and free the original)

Definition at line 132 of file Object.cc.

132  {
133  AstObject *rawObjCopy = rawObj;
134  if (copy) {
135  rawObjCopy = reinterpret_cast<AstObject *>(astCopy(rawObj));
136  astAnnul(rawObj);
137  }
138  assertOK(rawObjCopy);
139 
140  // Make the appropriate ast shim object and dynamically cast to the desired output type
141  auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
142  auto retObject = std::dynamic_pointer_cast<Class>(retObjectBeforeCast);
143  if (!retObject) {
145  os << "The component is of type " << retObject->getClassName()
146  << ", which could not be cast to the desired type " << typeid(Class).name();
147  throw std::runtime_error(os.str());
148  }
149  return retObject;
150 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
Definition: Object.h:108
T str(T... args)
T dynamic_pointer_cast(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ fromString()

static std::shared_ptr<Object> ast::Object::fromString ( std::string const &  str)
inlinestaticinherited

Construct an Object from a string, using astFromString.

Definition at line 88 of file Object.h.

88  {
89  auto *rawPtr = reinterpret_cast<AstObject *>(astFromString(str.c_str()));
90  return Object::_basicFromAstObject(rawPtr);
91  }

◆ getA() [1/2]

std::shared_ptr<Object> ast::KeyMap::getA ( std::string const &  key,
int  ind 
) const
inline

Get one Object for a given key; the object is deep copied.

Definition at line 308 of file KeyMap.h.

308  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getA() [2/2]

std::vector<std::shared_ptr<Object> > ast::KeyMap::getA ( std::string const &  key) const
inline

Get all Objects for a given key; each object is deep copied.

Definition at line 319 of file KeyMap.h.

319  {
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  }
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
T push_back(T... args)
STL class.
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
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

◆ getB() [1/2]

char unsigned ast::KeyMap::getB ( std::string const &  key,
int  ind 
) const
inline

Get one char value for a given key.

Definition at line 254 of file KeyMap.h.

254  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getB() [2/2]

std::vector<char unsigned> ast::KeyMap::getB ( std::string const &  key) const
inline

Get all char values for a given key.

Definition at line 264 of file KeyMap.h.

264  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
STL class.
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getC() [1/2]

std::string ast::KeyMap::getC ( std::string const &  key,
int  ind 
) const
inline

Get one std::string value for a given key.

Definition at line 277 of file KeyMap.h.

277  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
STL class.
STL class.
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getC() [2/2]

std::vector<std::string> ast::KeyMap::getC ( std::string const &  key) const
inline

Get all std::string values for a given key.

Definition at line 289 of file KeyMap.h.

289  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
STL class.
T push_back(T... args)
STL class.
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getClassName()

std::string ast::Object::getClassName ( ) const
inlineinherited

Get Class: the name of the class (e.g.

ZoomMap)

Note: if AST returns "CmpMap" then the name will be changed to "SeriesMap" or "ParallelMap", as appropriate.

Definition at line 138 of file Object.h.

138 { return detail::getClassName(getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
Definition: utils.cc:37

◆ getD() [1/2]

double ast::KeyMap::getD ( std::string const &  key,
int  ind 
) const
inline

Get one double value for a given key.

Definition at line 162 of file KeyMap.h.

162  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getD() [2/2]

std::vector<double> ast::KeyMap::getD ( std::string const &  key) const
inline

Get all double values for a given key.

Definition at line 172 of file KeyMap.h.

172  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getF() [1/2]

float ast::KeyMap::getF ( std::string const &  key,
int  ind 
) const
inline

Get one float value for a given key.

Definition at line 185 of file KeyMap.h.

185  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getF() [2/2]

std::vector<float> ast::KeyMap::getF ( std::string const &  key) const
inline

Get all float values for a given key.

Definition at line 195 of file KeyMap.h.

195  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getI() [1/2]

int ast::KeyMap::getI ( std::string const &  key,
int  ind 
) const
inline

Get one int value for a given key.

Definition at line 208 of file KeyMap.h.

208  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getI() [2/2]

std::vector<int> ast::KeyMap::getI ( std::string const &  key) const
inline

Get all int values for a given key.

Definition at line 218 of file KeyMap.h.

218  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getID()

std::string ast::Object::getID ( ) const
inlineinherited

Get ID: object identification string that is not copied.

Definition at line 141 of file Object.h.

141 { return getC("ID"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:360

◆ getIdent()

std::string ast::Object::getIdent ( ) const
inlineinherited

Get Ident: object identification string that is copied.

Definition at line 144 of file Object.h.

144 { return getC("Ident"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition: Object.h:360

◆ getL()

long int ast::Object::getL ( std::string const &  attrib) const
inlineprotectedinherited

Get the value of an attribute as a long int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 412 of file Object.h.

412  {
413  long int val = astGetL(getRawPtr(), attrib.c_str());
414  assertOK();
415  return val;
416  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
ImageT val
Definition: CR.cc:146

◆ getNObject()

int ast::Object::getNObject ( ) const
inlineinherited

Get NObject: number of AST objects in existence of the same type as the underlying AST class.

Warning
Intended only for debugging astshim.

Definition at line 152 of file Object.h.

152 { return getI("NObject"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getObjSize()

int ast::Object::getObjSize ( ) const
inlineinherited

Get ObjSize: the in-memory size of the AST object in bytes.

Definition at line 155 of file Object.h.

155 { return getI("ObjSize"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getRawPtr() [1/2]

AstObject const* ast::Object::getRawPtr ( ) const
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 291 of file Object.h.

291 { return &*_objPtr; };

◆ getRawPtr() [2/2]

AstObject* ast::Object::getRawPtr ( )
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 293 of file Object.h.

293 { return &*_objPtr; };

◆ getRefCount()

int ast::Object::getRefCount ( ) const
inlineinherited

Get RefCount: number of active pointers to the underlying AST object.

Warning
Intended only for debugging astshim.

Definition at line 162 of file Object.h.

162 { return getI("RefCount"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition: Object.h:399

◆ getS() [1/2]

short int ast::KeyMap::getS ( std::string const &  key,
int  ind 
) const
inline

Get one short int value for a given key.

Definition at line 231 of file KeyMap.h.

231  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getS() [2/2]

std::vector<short int> ast::KeyMap::getS ( std::string const &  key) const
inline

Get all short int values for a given key.

Definition at line 241 of file KeyMap.h.

241  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
STL class.
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ getUseDefs()

bool ast::Object::getUseDefs ( ) const
inlineinherited

Get UseDefs: allow use of default values for Object attributes?

Definition at line 165 of file Object.h.

165 { return getB("UseDefs"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition: Object.h:347

◆ hasAttribute()

bool ast::Object::hasAttribute ( std::string const &  attrib) const
inlineinherited

Does this object have an attribute with the specified name?

Definition at line 126 of file Object.h.

126  {
127  bool ret = astHasAttribute(getRawPtr(), attrib.c_str());
128  assertOK();
129  return ret;
130  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ hasKey()

bool ast::KeyMap::hasKey ( std::string const &  key) const
inline

Does this map contain the specified key?

See also defined, which also checks that the value is defined

Definition at line 140 of file KeyMap.h.

140  {
141  bool ret = static_cast<bool>(
142  astMapHasKey(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str()));
143  assertOK();
144  return ret;
145  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ key()

std::string ast::KeyMap::key ( int  ind) const
inline

Get the key at the specified index.

Definition at line 123 of file KeyMap.h.

123  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
int size() const
Get the number of keys.
Definition: KeyMap.h:155
STL class.
T str(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ length()

int ast::KeyMap::length ( std::string const &  key) const
inline

Get the size of the vector for the specified key; return 0 if key not found or value is undefined.

Definition at line 148 of file KeyMap.h.

148  {
149  int len = astMapLength(reinterpret_cast<AstKeyMap const *>(getRawPtr()), key.c_str());
150  assertOK();
151  return len;
152  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ lock()

void ast::Object::lock ( bool  wait)
inlineinherited

Lock this object for exclusive use by the calling thread.

The thread-safe public interface to AST is designed so that an error is reported if any thread attempts to use an Object that it has not previously locked for its own exclusive use using this function. When an Object is created, it is initially locked by the thread that creates it, so newly created objects do not need to be explicitly locked. However, if an Object pointer is passed to another thread, the original thread must first unlock it (using astUnlock) and the new thread must then lock it (using astLock) before the new thread can use the Object.

Parameters
[in]waitIf the Object is curently locked by another thread then this function will either report an error or block. If a non-zero value is supplied for "wait", the calling thread waits until the object is available for it to use. Otherwise, an error is reported and the function returns immediately without locking the Object.

Notes

  • The Locked object will belong to the current AST context.
  • This function returns without action if the Object is already locked by the calling thread.
  • If simultaneous use of the same object is required by two or more threads, Object::copy should be used to to produce a deep copy of the Object for each thread. Each copy should then be unlocked by the parent thread (i.e. the thread that created the copy), and then locked by the child thread (i.e. the thread that wants to use the copy).
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 201 of file Object.h.

201  {
202  astLock(getRawPtr(), static_cast<int>(wait));
203  assertOK();
204  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ makeShim()

template<typename ShimT , typename AstT >
static std::shared_ptr<ShimT> ast::Object::makeShim ( AstObject *  p)
inlinestaticprotectedinherited

Functor to make an astshim instance from a raw AST pointer of the corresponding type.

Template Parameters
ShimTOutput astshim class
AstTOutput AST class

Definition at line 309 of file Object.h.

309  {
310  return std::shared_ptr<ShimT>(new ShimT(reinterpret_cast<AstT *>(p)));
311  }

◆ operator!=()

bool ast::Object::operator!= ( Object const &  rhs) const
inlineinherited

Return True if this and rhs are not equal.

See operator== for details

Definition at line 82 of file Object.h.

82  {
83  return !(*this == rhs); };

◆ operator=() [1/2]

KeyMap& ast::KeyMap::operator= ( KeyMap const &  )
delete

◆ operator=() [2/2]

KeyMap& ast::KeyMap::operator= ( KeyMap &&  )
default

◆ operator==()

bool ast::Object::operator== ( Object const &  rhs) const
inherited

Return True if this and rhs are the equal.

For two objects be equal, they both must have the same attributes and all contained objects must be equal.

Definition at line 82 of file Object.cc.

82  {
83  auto thisStr = this->show(false);
84  auto rhsStr = rhs.show(false);
85  return rhsStr == thisStr;
86 }
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152

◆ putA() [1/2]

void ast::KeyMap::putA ( std::string const &  key,
Object const &  obj,
std::string const &  comment = "" 
)
inline

Add an Object, which is deep copied.

Definition at line 419 of file KeyMap.h.

419  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putA() [2/2]

void ast::KeyMap::putA ( std::string const &  key,
std::vector< std::shared_ptr< Object const >> const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of shared pointer to Object; the objects are deep copied.

Definition at line 426 of file KeyMap.h.

427  {
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  }
int size() const
Get the number of keys.
Definition: KeyMap.h:155
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:452
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
void putA(std::string const &key, Object const &obj, std::string const &comment="")
Add an Object, which is deep copied.
Definition: KeyMap.h:419

◆ putB() [1/2]

void ast::KeyMap::putB ( std::string const &  key,
char unsigned  value,
std::string const &  comment = "" 
)
inline

Add a char.

Definition at line 385 of file KeyMap.h.

385  {
386  astMapPut0B(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
387  assertOK();
388  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putB() [2/2]

void ast::KeyMap::putB ( std::string const &  key,
std::vector< char unsigned > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of chars.

Definition at line 391 of file KeyMap.h.

392  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T data(T... args)
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putC() [1/2]

void ast::KeyMap::putC ( std::string const &  key,
std::string const &  value,
std::string const &  comment = "" 
)
inline

Add a string.

Definition at line 400 of file KeyMap.h.

400  {
401  astMapPut0C(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value.c_str(), comment.c_str());
402  assertOK();
403  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putC() [2/2]

void ast::KeyMap::putC ( std::string const &  key,
std::vector< std::string > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of strings.

Definition at line 406 of file KeyMap.h.

406  {
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  }
int size() const
Get the number of keys.
Definition: KeyMap.h:155
void append(std::string const &key, double value)
Append an element to a vector of doubles in a KeyMap.
Definition: KeyMap.h:452
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
void putC(std::string const &key, std::string const &value, std::string const &comment="")
Add a string.
Definition: KeyMap.h:400

◆ putD() [1/2]

void ast::KeyMap::putD ( std::string const &  key,
double  value,
std::string const &  comment = "" 
)
inline

Add a double value.

Definition at line 329 of file KeyMap.h.

329  {
330  astMapPut0D(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
331  assertOK();
332  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putD() [2/2]

void ast::KeyMap::putD ( std::string const &  key,
std::vector< double > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of double.

Definition at line 335 of file KeyMap.h.

335  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T data(T... args)
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putF() [1/2]

void ast::KeyMap::putF ( std::string const &  key,
float  value,
std::string const &  comment = "" 
)
inline

Add a float.

Definition at line 343 of file KeyMap.h.

343  {
344  astMapPut0F(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
345  assertOK();
346  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putF() [2/2]

void ast::KeyMap::putF ( std::string const &  key,
std::vector< float > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of floats.

Definition at line 349 of file KeyMap.h.

349  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T data(T... args)
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putI() [1/2]

void ast::KeyMap::putI ( std::string const &  key,
int  value,
std::string const &  comment = "" 
)
inline

Add an int.

Definition at line 357 of file KeyMap.h.

357  {
358  astMapPut0I(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
359  assertOK();
360  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putI() [2/2]

void ast::KeyMap::putI ( std::string const &  key,
std::vector< int > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of ints.

Definition at line 363 of file KeyMap.h.

363  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T data(T... args)
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putS() [1/2]

void ast::KeyMap::putS ( std::string const &  key,
short int  value,
std::string const &  comment = "" 
)
inline

Add a short int.

Definition at line 371 of file KeyMap.h.

371  {
372  astMapPut0S(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), value, comment.c_str());
373  assertOK();
374  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putS() [2/2]

void ast::KeyMap::putS ( std::string const &  key,
std::vector< short int > const &  vec,
std::string const &  comment = "" 
)
inline

Add a vector of short int.

Definition at line 377 of file KeyMap.h.

377  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
T data(T... args)
T size(T... args)
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ putU()

void ast::KeyMap::putU ( std::string const &  key,
std::string const &  comment = "" 
)
inline

Add a new entry, but no value is stored with the entry.

The entry has a special data type represented by symbolic constant AST__UNDEFTYPE. Such entries can act as placeholders for values that can be added to the KeyMap later.

Definition at line 446 of file KeyMap.h.

446  {
447  astMapPutU(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), comment.c_str());
448  assertOK();
449  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ remove()

void ast::KeyMap::remove ( std::string const &  key)
inline

Remove the specified entry.

Silently do nothing if this KeyMap does not contain the specified key.

Definition at line 556 of file KeyMap.h.

556  {
557  astMapRemove(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
558  assertOK();
559  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ rename()

void ast::KeyMap::rename ( std::string const &  oldKey,
std::string const &  newKey 
)
inline

Rename the specified entry.

Silently do nothing if this KeyMap does not contain the old key.

Definition at line 566 of file KeyMap.h.

566  {
567  astMapRename(reinterpret_cast<AstKeyMap *>(getRawPtr()), oldKey.c_str(), newKey.c_str());
568  assertOK();
569  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ replace() [1/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
double  value 
)
inline

Replace an element of a vector of doubles in a KeyMap.

Definition at line 502 of file KeyMap.h.

502  {
503  _assertReplaceIndexInRange(key, i);
504  astMapPutElemD(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
505  assertOK();
506  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [2/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
float  value 
)
inline

Replace an element of a vector of floats in a KeyMap.

Definition at line 509 of file KeyMap.h.

509  {
510  _assertReplaceIndexInRange(key, i);
511  astMapPutElemF(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
512  assertOK();
513  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [3/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
int  value 
)
inline

Replace an element of a vector of ints in a KeyMap.

Definition at line 516 of file KeyMap.h.

516  {
517  _assertReplaceIndexInRange(key, i);
518  astMapPutElemI(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
519  assertOK();
520  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [4/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
short int  value 
)
inline

Replace an element of a vector of short int in a KeyMap.

Definition at line 523 of file KeyMap.h.

523  {
524  _assertReplaceIndexInRange(key, i);
525  astMapPutElemS(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
526  assertOK();
527  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [5/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
char unsigned  value 
)
inline

Replace an element of a vector of char in a KeyMap.

Definition at line 530 of file KeyMap.h.

530  {
531  _assertReplaceIndexInRange(key, i);
532  astMapPutElemB(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value);
533  assertOK();
534  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [6/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
std::string const &  value 
)
inline

Replace an element of a vector of strings in a KeyMap.

Definition at line 537 of file KeyMap.h.

537  {
538  _assertReplaceIndexInRange(key, i);
539  astMapPutElemC(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str(), i, value.c_str());
540  assertOK();
541  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ replace() [7/7]

void ast::KeyMap::replace ( std::string const &  key,
int  i,
Object const &  value 
)
inline

Replace an element of a vector of Objects in a KeyMap.

Definition at line 544 of file KeyMap.h.

544  {
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  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
std::string key(int ind) const
Get the key at the specified index.
Definition: KeyMap.h:123
T c_str(T... args)

◆ same()

bool ast::Object::same ( Object const &  other) const
inlineinherited

Does this contain the same AST object as another?

This is a test of identity, not of equality.

Definition at line 211 of file Object.h.

211 { return astSame(getRawPtr(), other.getRawPtr()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
ItemVariant const * other
Definition: Schema.cc:56

◆ set()

void ast::Object::set ( std::string const &  setting)
inlineprotectedinherited

Assign a set of attribute values, over-riding any previous values.

The attributes and their new values are specified via a character string, which should contain a comma-separated list of the form: "attribute_1 = value_1, attribute_2 = value_2, ... " where "attribute_n" specifies an attribute name, and the value to the right of each " =" sign should be a suitable textual representation of the value to be assigned. This value will be interpreted according to the attribute's data type.

Notes

  • Attribute names are not case sensitive and may be surrounded by white space
  • Attribute names are not case sensitive and may be surrounded by white space.
  • White space may also surround attribute values, where it will generally be ignored (except for string-valued attributes where it is significant and forms part of the value to be assigned).
  • To include a literal comma or percent sign in the value assigned to an attribute, the whole attribute value should be enclosed in quotation markes.
Exceptions
std::runtime_errorif the attribute is read-only

Definition at line 439 of file Object.h.

439 { astSet(getRawPtr(), "%s", setting.c_str()); }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291

◆ setB()

void ast::Object::setB ( std::string const &  attrib,
bool  value 
)
inlineprotectedinherited

Set the value of an attribute as a bool.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 448 of file Object.h.

448  {
449  astSetI(getRawPtr(), attrib.c_str(), value);
450  assertOK();
451  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setC()

void ast::Object::setC ( std::string const &  attrib,
std::string const &  value 
)
inlineprotectedinherited

Set the value of an attribute as a string.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 460 of file Object.h.

460  {
461  astSetC(getRawPtr(), attrib.c_str(), value.c_str());
462  assertOK();
463  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setD()

void ast::Object::setD ( std::string const &  attrib,
double  value 
)
inlineprotectedinherited

Set the value of an attribute as a double.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 472 of file Object.h.

472  {
473  astSetD(getRawPtr(), attrib.c_str(), value);
474  assertOK();
475  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setF()

void ast::Object::setF ( std::string const &  attrib,
float  value 
)
inlineprotectedinherited

Set the value of an attribute as a float.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 484 of file Object.h.

484  {
485  astSetF(getRawPtr(), attrib.c_str(), value);
486  assertOK();
487  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setI()

void ast::Object::setI ( std::string const &  attrib,
int  value 
)
inlineprotectedinherited

Set the value of an attribute as an int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 496 of file Object.h.

496  {
497  astSetI(getRawPtr(), attrib.c_str(), value);
498  assertOK();
499  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setID()

void ast::Object::setID ( std::string const &  id)
inlineinherited

Set ID: object identification string that is not copied.

Definition at line 214 of file Object.h.

214 { setC("ID", id); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:460

◆ setIdent()

void ast::Object::setIdent ( std::string const &  ident)
inlineinherited

Set Ident: object identification string that is copied.

Definition at line 217 of file Object.h.

217 { setC("Ident", ident); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition: Object.h:460

◆ setL()

void ast::Object::setL ( std::string const &  attrib,
long int  value 
)
inlineprotectedinherited

Set the value of an attribute as a long int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 508 of file Object.h.

508  {
509  astSetL(getRawPtr(), attrib.c_str(), value);
510  assertOK();
511  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ setUseDefs()

void ast::Object::setUseDefs ( bool  usedefs)
inlineinherited

Set UseDefs: allow use of default values for Object attributes?

Definition at line 220 of file Object.h.

220 { setB("UseDefs", usedefs); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition: Object.h:448

◆ show() [1/2]

void ast::Object::show ( std::ostream os,
bool  showComments = true 
) const
inherited

Print a textual description the object to an ostream.

Parameters
[in,out]osThe stream to which to write the string representation.
[in]showCommentsShow comments?

Definition at line 152 of file Object.cc.

152  {
153  Stream stream(nullptr, &os);
154  Channel ch(stream, showComments ? "" : "Comment=0");
155  ch.write(*this);
156  assertOK();
157 }
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ show() [2/2]

std::string ast::Object::show ( bool  showComments = true) const
inherited

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

Definition at line 159 of file Object.cc.

159  {
161  show(os, showComments);
162  return os.str();
163 }
T str(T... args)
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition: Object.cc:152
std::ostream * os
Definition: Schema.cc:746

◆ size()

int ast::KeyMap::size ( ) const
inline

Get the number of keys.

Definition at line 155 of file KeyMap.h.

155  {
156  int const size = astMapSize(reinterpret_cast<AstKeyMap const *>(getRawPtr()));
157  assertOK();
158  return size;
159  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
int size() const
Get the number of keys.
Definition: KeyMap.h:155

◆ test()

bool ast::Object::test ( std::string const &  attrib) const
inlineinherited

Has this attribute been explicitly set (and not subsequently cleared)?

Warning
Unlike the underlying astTest function, throws an exception if an error results

Notes

  • Attribute names are not case sensitive and may be surrounded by white space.
  • As you might expect, the returned value for a read-only attribute is always false.
Exceptions
std::runtime_errorif an error results.

Definition at line 249 of file Object.h.

249  {
250  bool res = astTest(getRawPtr(), attrib.c_str());
251  assertOK();
252  return res;
253  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

◆ type()

DataType ast::KeyMap::type ( std::string const &  key)
inline

Get the type suffix for a given key.

Definition at line 574 of file KeyMap.h.

574  {
575  int retVal = astMapType(reinterpret_cast<AstKeyMap *>(getRawPtr()), key.c_str());
576  assertOK();
577  return static_cast<DataType>(retVal);
578  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49
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
T c_str(T... args)

◆ unlock()

void ast::Object::unlock ( bool  report = false)
inlineinherited

Unlock this object previously locked using lock, so that other threads can use this object.

See lock for further details.

Parameters
[in]reportIf true, an error will be reported if the supplied Object, or any Object contained within the supplied Object, is not currently locked by the running thread. If false, such Objects will be left unchanged, and no error will be reported.

Notes

  • This function attempts to execute even if AST's global error status is set, but no further error report will be made if it subsequently fails under these circumstances.
  • All unlocked Objects are excluded from AST context handling until they are re-locked using astLock.
  • This function returns without action if the Object is not currently locked by any thread. If it is locked by the running thread, it is unlocked. If it is locked by another thread, an error will be reported if "error" is non-zero.
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 279 of file Object.h.

279  {
280  astUnlock(getRawPtr(), static_cast<int>(report));
281  assertOK();
282  }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition: Object.h:291
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST&#39;s state is bad.
Definition: base.cc:49

Friends And Related Function Documentation

◆ Channel

friend class Channel
friend

Definition at line 85 of file KeyMap.h.

◆ Object

friend class Object
friend

Definition at line 84 of file KeyMap.h.


The documentation for this class was generated from the following file: