28#include <unordered_map>
79extern "C" void sinkToOstream(
const char *text) {
80 auto osptr =
reinterpret_cast<std::ostream *
>(astChannelData);
87 auto thisStr = this->
show(
false);
88 auto rhsStr = rhs.
show(
false);
89 return rhsStr == thisStr;
131 auto name_caster = ClassCasterMap.find(className);
132 if (name_caster == ClassCasterMap.end()) {
134 throw std::runtime_error(
"Class " + className +
" not supported");
136 return name_caster->second(rawObj);
139template <
typename Class>
141 AstObject *rawObjCopy = rawObj;
143 rawObjCopy =
reinterpret_cast<AstObject *
>(astCopy(rawObj));
149 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
153 os <<
"The component is of type " << retObject->getClassName()
154 <<
", which could not be cast to the desired type " <<
typeid(Class).name();
161 Stream stream(
nullptr, &os);
162 Channel ch(stream, showComments ?
"" :
"Comment=0");
169 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)