![]() |
ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
|
00001 /* 00002 Copyright (C) 2010,2012,2013 The ESPResSo project 00003 Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 00004 Max-Planck-Institute for Polymer Research, Theory Group 00005 00006 This file is part of ESPResSo. 00007 00008 ESPResSo is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 ESPResSo is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 #ifndef _PARSER_H 00022 #define _PARSER_H 00023 /** \file parser.h 00024 This file contains macros for parsing the parameters to the 00025 'inter' command. 00026 */ 00027 00028 #include "utils.h" 00029 #include <string.h> 00030 #include <tcl.h> 00031 00032 /** parse an integer list 00033 @param interp for conversion of backslash stuff 00034 @param list the string containing the list 00035 @param il where to store the results 00036 */ 00037 int parse_int_list(Tcl_Interp *interp, char *list, IntList *il); 00038 00039 /** parse an double list 00040 @param interp for conversion of backslash stuff 00041 @param list the string containing the list 00042 @param dl where to store the results 00043 */ 00044 int parse_double_list(Tcl_Interp *interp, char *list, DoubleList *dl); 00045 00046 /** gather all error messages from all nodes and set the interpreter result 00047 to these error messages. This should be called only on the master node. 00048 00049 The errors are append to the result, if ret_state == TCL_ERROR, 00050 otherwise the result is overwritten, in case an error occurs. 00051 Therefore you should end any Tcl command handler by return 00052 gather_runtime_errors(<return_value>). This code uses 00053 asynchronous communication. 00054 00055 @param ret_state return value of the procedure 00056 @param interp where to put the errors 00057 @return new return value after the background errors, if any, have been handled 00058 */ 00059 int gather_runtime_errors(Tcl_Interp *interp, int ret_state); 00060 00061 00062 #define ARG_IS_S(no, str) !strncasecmp(argv[(no)], (str), strlen(argv[(no)])) 00063 #define ARG0_IS_S(str) ARG_IS_S(0, (str)) 00064 #define ARG1_IS_S(str) ARG_IS_S(1, (str)) 00065 #define ARG_IS_S_EXACT(no, str) !strcmp(argv[(no)], (str)) 00066 #define ARG0_IS_S_EXACT(str) ARG_IS_S_EXACT(0, (str)) 00067 #define ARG1_IS_S_EXACT(str) ARG_IS_S_EXACT(1, (str)) 00068 00069 #define ARG_IS_I(no, dest) (!(Tcl_GetInt(interp, argv[(no)], &(dest)) == TCL_ERROR)) 00070 #define ARG0_IS_I(dest) ARG_IS_I(0, (dest)) 00071 #define ARG1_IS_I(dest) ARG_IS_I(1, (dest)) 00072 00073 #define ARG_IS_D(no, dest) (!(Tcl_GetDouble(interp, argv[(no)], &(dest)) == TCL_ERROR)) 00074 #define ARG0_IS_D(dest) ARG_IS_D(0, (dest)) 00075 #define ARG1_IS_D(dest) ARG_IS_D(1, (dest)) 00076 00077 #define ARG_IS_INTLIST(no, il) (parse_int_list(interp, argv[(no)], &(il))) 00078 #define ARG0_IS_INTLIST(il) ARG_IS_INTLIST(0, (il)) 00079 #define ARG1_IS_INTLIST(il) ARG_IS_INTLIST(1, (il)) 00080 00081 #define ARG_IS_DOUBLELIST(no, il) (parse_double_list(interp, argv[(no)], &(il))) 00082 #define ARG0_IS_DOUBLELIST(il) ARG_IS_DOUBLELIST(0, (il)) 00083 #define ARG1_IS_DOUBLELIST(il) ARG_IS_DOUBLELIST(1, (il)) 00084 00085 #define CHECK_VALUE(func, errmsg) \ 00086 if (func == ES_ERROR) { \ 00087 Tcl_AppendResult(interp, errmsg, (char *)NULL); \ 00088 return TCL_ERROR; \ 00089 } \ 00090 return TCL_OK; 00091 #endif
1.7.5.1