|
|
#ifndef OM_ERROR_NODE_H #define OM_ERROR_NODE_H /** * The error node structure. * * This class provides a specialization of OmNode to implement the Error node construction. * This corresponds to a symbol S applying to its arguments E[0..n]. * This is encoded as <OME> S E0 ... En </OME> * The list of children must represent the enclosed sequence of <S, E0, ..., En>. */ class OmErrorNode : public OmNode { public: /** * Default constructor. */ OmErrorNode() {} protected: /** * Copy constructor. */ OmErrorNode(const OmErrorNode & other_in) : OmNode(other_in) {} /** * Destructor. */ virtual ~OmErrorNode() {} /** * Implement access to the concrete type. */ virtual OmType typeImp() const { return OmErrorType; } /** * Implement the deep cloning. */ virtual OmNode * cloneImp() const { return new OmErrorNode(*this); } /** * Implement the writing to an output device. */ virtual void writeImp(OmOutputDevice & output_in) const { OmException::checkMalformedNode(count()<1, "OmErrorNode must have at least 1 argument (a symbol)"); OmException::checkMalformedNode(iterate().get()->type()!=OmSymbolType, "The first argument of OmErrorNode must be a symbol"); output_in.writeError(); for (ConstIterator it=iterate(); !it.done(); it.next()) { hibernate(output_in, it.get()); } output_in.writeEndError(); } /** * Implement the reading from an input device. */ virtual void readImp(OmInputDevice & input_in) { OmCommentCollector cc; input_in.readError(); cc.collect(input_in); OmType type; input_in.readType(type); OmException::checkMalformedNode(type==OmEndErrorType, "OmErrorNode must have at least 1 argument (a symbol)"); OmNode * symbol = OmNode::resurrect(input_in); OmException::checkMalformedNode(symbol->type()!=OmSymbolType, "The first argument of OmErrorNode must be a symbol"); append(cc.uncollect(symbol)); cc.collect(input_in); input_in.readType(type); while (type!=OmEndErrorType) { append(cc.uncollect(OmNode::resurrect(input_in))); cc.collect(input_in); input_in.readType(type); } input_in.readEndError(); } }; #endif // OM_ERROR_NODE_H
Generated by: root@localhost.localdomain on Tue Oct 12 21:02:30 199. |