00001 /* 00002 * File: cw_options_recorder.cc 00003 * $Id: cw_options_recorder.cc,v 1.4 2002/06/26 20:46:15 alec Exp $ 00004 * 00005 * Author: Alec Panoviciu (alecu@email.com) 00006 * 00007 * Comments: 00008 * 00009 * Revision history: 00010 * 00011 * $Log: cw_options_recorder.cc,v $ 00012 * Revision 1.4 2002/06/26 20:46:15 alec 00013 * g++ 3.x happy 00014 * 00015 * Revision 1.3 2002/06/23 23:33:55 alec 00016 * string option bugfix 00017 * 00018 * Revision 1.2 2002/04/29 09:34:10 alec 00019 * scanner ptree building compiles 00020 * 00021 */ 00022 00023 /* 00024 Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com) 00025 00026 This program is free software; you can redistribute it and/or modify 00027 it under the terms of the GNU General Public License as published by 00028 the Free Software Foundation; either version 2 of the License, or 00029 (at your option) any later version. 00030 00031 This program is distributed in the hope that it will be useful, 00032 but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00034 GNU General Public License for more details. 00035 00036 You should have received a copy of the GNU General Public License 00037 along with this program; if not, write to the Free Software 00038 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00039 00040 */ 00041 00042 #include <string> 00043 #include <cstdio> 00044 #include <cstdlib> 00045 using namespace std; 00046 00047 #include "debug.h" 00048 #include "parse_util.hh" 00049 #include "options_recorder.hh" 00050 #include "cw_options_recorder.h" 00051 00052 OptionsRecorder *cw_optionsRecorder = NULL; 00053 00054 /* seems like this one is haunting me.... */ 00055 extern int yylineno; 00056 00057 extern "C" void OptionsRecorder_setStringOption (char *key, char *value) 00058 { 00059 try { 00060 value[strlen(value)-1]='\0'; 00061 cw_optionsRecorder->setOption(string(key), string(value+1)); 00062 } catch (ParseException &ex) { 00063 die(formatError(Position(yylineno), ex)); 00064 } 00065 free(key); 00066 free(value); 00067 } 00068 00069 00070 extern "C" void OptionsRecorder_setBoolOption (char *key, int value) 00071 { 00072 try { 00073 cw_optionsRecorder->setOption(string(key), value != 0); 00074 } catch (ParseException &ex) { 00075 die(formatError(Position(yylineno), ex)); 00076 } 00077 free(key); 00078 } 00079 00080 00081 extern "C" void OptionsRecorder_setIntOption (char *key, int value) 00082 { 00083 try { 00084 cw_optionsRecorder->setOption(string(key), value); 00085 } catch (ParseException &ex) { 00086 die(formatError(Position(yylineno), ex)); 00087 } 00088 free(key); 00089 } 00090 00091 00092 #ifdef DEBUG 00093 00094 extern "C" void OptionsRecorder_dumpOptions () 00095 { 00096 fflush(stderr); 00097 cw_optionsRecorder->dumpRegistry(); 00098 cerr.flush(); 00099 } 00100 00101 #endif