/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pg_config.h" IDENT("@(#) RepStrucBase.cc (Gunther Schadow) 12/19/96"); #pragma implementation #include "RepStrucBase.h" #include "exception.h" #include "logfile.h" #include "misc.h" #include "xios.h" #include "ParseTrace.h" void RepStrucBase::output(ostream& os) const { const RepStrucBase *p; if(ishl7er(os) || isastmer(os)) { LOGDEBUG("hl7/astm"); for(p = this; p->_car != NULL; p=(RepStrucBase*)p->_cdr) p->_car->output(os); } else { LOGDEBUG("debug"); os << DSBGR0 "RepStrucBase" << DSBGR1; if(_car != NULL) { os << DSFRST; _car->output(os); for(p = (RepStrucBase*)_cdr; p->_car != NULL; p = (RepStrucBase*)p->_cdr) { os << DSSEPR; p->_car->output(os); } } else os << DSNOPS; os << DSEGRP; } LOGDEBUG("end"); } result RepStrucBase::input(istream& is) { RepStrucTracer tracer; if(isdebug(is)) FATAL("can't read from debug stream"); LOGDEBUG("hl7/astm"); RepStrucBase *q= this; while(TRUE) { tracer++; if(q->_car == NULL) q->_car = q->ctora(); if(q->_car->input(is) != SUCCESS) break; if(q->_cdr == NULL) q->_cdr = q->ctord(); q = (RepStrucBase*)q->_cdr; } // Cut off the rest if(q->_car != NULL) { delete q->_car; q->_car=NULL; } if(q->_cdr != NULL) { delete q->_cdr; q->_cdr=NULL; } if(q != this) return SUCCESS; else return FAIL; }