|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * gnc-exp-parser.h -- Interface to expression parsing for GnuCash * 00003 * Copyright (C) 2000 Dave Peticolas <dave@krondo.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License* 00016 * along with this program; if not, write to the Free Software * 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00018 \********************************************************************/ 00019 00020 #ifndef GNC_EXP_PARSER_H 00021 #define GNC_EXP_PARSER_H 00022 00023 #include <glib.h> 00024 00025 #include "qof.h" 00026 00030 typedef enum 00031 { 00032 NO_ERR, 00033 VARIABLE_IN_EXP, 00034 NUM_ERRORS 00035 } GNCParseError; 00036 00037 /* Initialize the expression parser. If this function is not 00038 * called before one of the other parsing routines (other than 00039 * gnc_exp_parser_shutdown), it will be called if needed. 00040 */ 00041 void gnc_exp_parser_init (void); 00042 00050 void gnc_exp_parser_real_init( gboolean addPredefined ); 00051 00052 /* Shutdown the expression parser and free any associated memory in the ParserState. */ 00053 void gnc_exp_parser_shutdown (void); 00054 00055 /* Undefine the variable name if it is already defined. */ 00056 void gnc_exp_parser_remove_variable (const char *variable_name); 00057 00058 /* Set the value of the variable to the given value. If the variable is 00059 * not already defined, it will be after the call. */ 00060 void gnc_exp_parser_set_value (const char * variable_name, 00061 gnc_numeric value); 00062 00063 /* Parse the given expression using the current variable definitions. 00064 * If the parse was successful, return TRUE and, if value_p is 00065 * non-NULL, return the value of the resulting expression in *value_p. 00066 * Otherwise, return FALSE and *value_p is unchanged. If FALSE is 00067 * returned and error_loc_p is non-NULL, *error_loc_p is set to the 00068 * character in expression where parsing aborted. If TRUE is returned 00069 * and error_loc_p is non-NULL, *error_loc_p is set to NULL. */ 00070 gboolean gnc_exp_parser_parse (const char * expression, 00071 gnc_numeric *value_p, 00072 char **error_loc_p ); 00073 00083 gboolean gnc_exp_parser_parse_separate_vars (const char * expression, 00084 gnc_numeric *value_p, 00085 char **error_loc_p, 00086 GHashTable *varHash ); 00087 00088 /* If the last parse returned FALSE, return an error string describing 00089 * the problem. Otherwise, return NULL. */ 00090 const char * gnc_exp_parser_error_string (void); 00091 00092 #endif
1.7.4