object::object(object::data* derived) : _data() { if (derived != buffer()) throw bad_data(); _data = derived; }
long stmtNumData::numStmt(nast_code code) throw (bad_data) { if ( (isStmt(code)) || (isOthrStmt(code)) || (code == CASE_LABEL) ) return counted[code]; else throw bad_data("stmtNumData", "Impossibile get the number of a stmt_n"); }
// --------------------------------------------------------------------------- // CLASS // --------------------------------------------------------------------------- void stmtNumData::addStmt(nast_code code) throw (bad_data) { if ( (isStmt(code)) || (isOthrStmt(code)) || (code == CASE_LABEL) ) counted[code]++; else throw bad_data("stmtNumData", "Impossibile add a new stmt_n"); return; }
node * graphData::nextNode(void) throw (bad_data) { // is there a next node ? if ( graphData::hasNextNode() ) { pNodesL_pos++; pNodesL++; return *pNodesL; } else throw bad_data("graphData::nextNode", "The next node doesn't exsist"); }
node * graphData::firstNode (void) throw (bad_data) { // is the list empty ? if ( nodesL.size() ) { pNodesL_pos = 1; pNodesL = nodesL.begin(); return *pNodesL; } else throw bad_data("graphData::firstNode", "The first node don't exsist"); }
//---- Members void graphData::addNode(int id, char *name, int c) throw (bad_data) { node *n; // a new node // Checks the precondition if (graphData::hasNode(id)) throw bad_data("graphData::addNode", "Duplicate node ! Impossibile add the node " + a2b::long2string(id)); else { n = new node; n->id = id; n->name = name; n->c = c; nodesL.push_back(n); nodesNum++; } return; }
string graphData::getNodeName(int id) throw (bad_data) { string name; // the name of the node list <node *>::iterator p; // browse the list node *n; // a node bool build; // flag for building the name build = false; for (p = nodesL.begin();(p != nodesL.end()) && (!build); p++) { n = *p; if ( build = (n->id == id) ) name = n->name; } if (!build) throw bad_data("graphData::getNodeName", "Can't build the name of a node."); return name; }