/* FIXME! FIXME! FIXME! FIXME! FIXME! FIXME! FIXME! FIXME! FIXME! * * 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("@(#) ParseTrace.cc (Gunther Schadow) 12/19/96"); #pragma implementation #include "ParseTrace.h" #include "strstream.h" #include "logfile.h" ParseTrace parseTrace; void ParseTrace::reset(int level) { switch(level) { case 0: message = UniMesIdCode::not_present; group_depth = 0; case 1: place[group_depth] = -1; if(group_depth > 0) seg_of_msg[group_depth] = seg_of_msg[group_depth - 1]; else seg_of_msg[group_depth] = 0; case 2: s_repetition[group_depth] = -1; case 3: segment = SegTypeCode::not_present; case 4: field = -1; case 5: field_name = NULL; case 6: f_repetition = -1; case 7: component_depth = 0; case 8: data_type[component_depth] = DataTypeCode::not_present; case 9: component[component_depth] = -1; } } void record_parse_error(const char *msg, ...) { va_list pvar; va_start(pvar, msg); (*parseTrace.record_function)("ERROR", msg, pvar); va_end(pvar); } void record_parse_warning(const char *msg, ...) { va_list pvar; va_start(pvar, msg); (*parseTrace.record_function)("WARNING", msg, pvar); va_end(pvar); } /* * output a parse trace in a textual form: * * { '.' '[' ']' } * '.' '[' ']' '"' '"' * { '<' '>' [ '[' ']' ] } * */ void ParseTrace::output(ostream &os) { UniMesIdCode umid(message); if(umid.ispresent()) os << (const char*)UniMesIdCode(message); for(int i = 0; i <= group_depth; i++) { if(place[i] > -1) os << '.' << place[i] + 1; if(s_repetition[i] > -1) os << '[' << s_repetition[i] + 1 << ']'; } if(segment != SegTypeCode::not_present) { os << '.' << (const char*)SegTypeCode(segment); if(field > -1) { os << '[' << field + 1 << ']'; if(field_name != NULL) os << "(\"" << field_name << "\")"; if(f_repetition > -1) os << '[' << f_repetition + 1 << ']'; for(int i = 0; i <= component_depth; i++) { if(data_type[i] != DataTypeCode::not_present) os << '<' << (const char *)DataTypeCode(data_type[i]) << '>'; if(component[i] > -1) os << '[' << component[i] + 1 << ']'; } } } } void ParseTrace::log(const char *loc) { strstream s; s << loc << ": "; output(s); s << '\0'; LOGDEBUG(" T %s", s.str()); s.freeze(0); } void null_record(const char *, const char *, va_list) { }