28#include <unordered_map>
78extern "C" void sinkToOstream(
const char *text) {
79 auto osptr =
reinterpret_cast<std::ostream *
>(astChannelData);
86 auto thisStr = this->
show(
false);
87 auto rhsStr = rhs.
show(
false);
88 return rhsStr == thisStr;
129 auto name_caster = ClassCasterMap.find(className);
130 if (name_caster == ClassCasterMap.end()) {
132 throw std::runtime_error(
"Class " + className +
" not supported");
134 return name_caster->second(rawObj);
137template <
typename Class>
139 AstObject *rawObjCopy = rawObj;
141 rawObjCopy =
reinterpret_cast<AstObject *
>(astCopy(rawObj));
147 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
151 os <<
"The component is of type " << retObject->getClassName()
152 <<
", which could not be cast to the desired type " <<
typeid(Class).name();
159 Stream stream(
nullptr, &os);
160 Channel ch(stream, showComments ?
"" :
"Comment=0");
167 show(os, showComments);
Channel provides input/output of AST objects.
int write(Object const &object)
Write an object to a channel.
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.
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
static std::shared_ptr< ShimT > makeShim(AstObject *p)
Functor to make an astshim instance from a raw AST pointer of the corresponding type.
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Object(Object const &object)
Copy constructor: make a deep copy.
AstObject const * getRawPtr() const
Get the raw AST pointer.
bool operator==(Object const &rhs) const
Return True if this and rhs are the equal.
A stream for ast::Channel.
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
AST wrapper classes and functions.
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
T dynamic_pointer_cast(T... args)