Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

ccp4_parser.h

Go to the documentation of this file.
00001 /*
00002      ccp4_parser.h: Headers for functions to read in and "parse" CCP4 keyworded input.
00003      Copyright (C) 2001  CCLRC, Peter Briggs
00004 
00005      This library is free software and is distributed under the terms and
00006      conditions of the CCP4 licence agreement as `Part 0' (Annex 2)
00007      software, which is version 2.1 of the GNU Lesser General Public
00008      Licence (LGPL) with the following additional clause:
00009 
00010         `You may also combine or link a "work that uses the Library" to
00011         produce a work containing portions of the Library, and distribute
00012         that work under terms of your choice, provided that you give
00013         prominent notice with each copy of the work that the specified
00014         version of the Library is used in it, and that you include or
00015         provide public access to the complete corresponding
00016         machine-readable source code for the Library including whatever
00017         changes were used in the work. (i.e. If you make changes to the
00018         Library you must distribute those, but you do not need to
00019         distribute source or object code to those portions of the work
00020         not covered by this licence.)'
00021 
00022      Note that this clause grants an additional right and does not impose
00023      any additional restriction, and so does not affect compatibility
00024      with the GNU General Public Licence (GPL). If you wish to negotiate
00025      other terms, please contact the maintainer.
00026 
00027      You can redistribute it and/or modify the library under the terms of
00028      the GNU Lesser General Public License as published by the Free Software
00029      Foundation; either version 2.1 of the License, or (at your option) any
00030      later version.
00031 
00032      This library is distributed in the hope that it will be useful, but
00033      WITHOUT ANY WARRANTY; without even the implied warranty of
00034      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00035      Lesser General Public License for more details.
00036 
00037      You should have received a copy of the CCP4 licence and/or GNU
00038      Lesser General Public License along with this library; if not, write
00039      to the CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
00040      The GNU Lesser General Public can also be obtained by writing to the
00041      Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00042      MA 02111-1307 USA
00043 */
00044 
00124 /*------------------------------------------------------------------*/
00125 
00126 /* Macro definitions */
00127 
00128 /*------------------------------------------------------------------*/
00129 
00130 #ifndef __CCP4_Parser__
00131 #define __CCP4_Parser__
00132 
00133 static char rcsidhhh[] = "$Id: ccp4__parser_8h-source.html,v 1.8 2004/07/05 14:36:55 mdw Exp $";
00134 
00135 /* note order: these must be outside CCP4 namespace */
00136 #include <stdio.h>
00137 #include"ccp4_utils.h"
00138 #include"ccp4_spg.h"
00139 
00140 /* Macro to make C functions callable from C++ */
00141 #ifdef  __cplusplus
00142 namespace CCP4 {
00143 extern "C" {
00144 typedef CSym::ccp4_symop ccp4_symop;
00145 #endif
00146 
00147 /*------------------------------------------------------------------*/
00148 
00149 /* Parser String Sizes */
00150 
00151 /*------------------------------------------------------------------*/
00152 
00153 #define CCP4_PARSER_MAXLINELENGTH     200
00154 #define CCP4_PARSER_MAXFILENAMELENGTH 200
00155 
00156 /*------------------------------------------------------------------*/
00157 
00158 /* Structures and typedefs */
00159 
00160 /*------------------------------------------------------------------*/
00161 
00162 /* CCP4 Parser token
00163    Construct to hold the information about a single token */
00164 
00165 typedef struct {
00166   char   *fullstring;   /* Full string containing all of token */
00167   char   word[5];       /* First four characters of token */
00168   double value;         /* Equivalent numerical value */
00169   int    isstring;      /* Flag: true if token is character string */
00170   int    strlength;     /* Number of characters in whole token (strings only) */
00171   int    isnumber;      /* Flag: true if token is number */
00172   int    intdigits;     /* Number of 'digits' preceeding the decimal point
00173                            (numbers only) */
00174   int    frcdigits;     /* Number of 'digits' after the decimal point (numbers
00175                            only) */
00176   int    isquoted;      /* Flag: true if token is contained in quotes */
00177   int    isnull;        /* Flag: true if token is null field */
00178   int    ibeg,iend;     /* Begin and end character positions of token
00179                            in input line */
00180 } CCP4PARSERTOKEN;
00181 
00182 /* CCP4 Parser array
00183    Construct to hold the information about a parsed line */
00184 
00185 typedef struct {
00186   /* "Public" members */
00187   char   keyword[5];      /* Keyword (=token[1].token, uppercased) */
00188   int    ntokens;         /* Number of tokens */
00189   CCP4PARSERTOKEN *token; /* Array of tokens */
00190   /* "Private" members */
00191   FILE   *fp;             /* Pointer to an external command file */
00192   int    maxtokens;       /* Maximum number of tokens allowed */
00193   char   *delim;          /* List of delimiter characters */
00194   char   *nulldelim;      /* List of null delimiter characters */
00195   char   *comment;        /* List of comment characters */
00196   double max_exponent;    /* Largest allowed exponent for numerical tokens */
00197   double min_exponent;    /* Smallest allowed exponent for numerical tokens */
00198 } CCP4PARSERARRAY;     
00199 
00200 /*------------------------------------------------------------------*/
00201 
00202 /* Function Prototypes */
00203 
00204 /*------------------------------------------------------------------*/
00205 
00206 /* Core cparser functions */
00207 
00214 CCP4PARSERARRAY* ccp4_parse_start(const int maxtokens);
00215 
00221 int ccp4_parse_end(CCP4PARSERARRAY *parsePtr);
00222 
00223 int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok);
00224 
00225 int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim,
00226                                   const char *nulldelim);
00227 
00228 int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars);
00229 
00230 int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent,
00231                               const double min_exponent);
00232 
00233 int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr);
00234 
00235 int ccp4_parse(const char *line, CCP4PARSERARRAY *parser);
00236 
00253 int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser,
00254                         const int print);
00255 
00256 /* External utility functions */
00257 
00264 int ccp4_keymatch(const char *keyin1, const char *keyin2);
00265 
00266 /* Internal utility functions */
00267 
00273 char *strtoupper (char *str1, const char *str2);
00274 
00280 char *strtolower (char *str1, const char *str2);
00281 
00282 int strmatch (const char *str1, const char *str2);
00283 
00284 int charmatch(const char character, const char *charlist);
00285 
00286 int doublefromstr(const char *str, const double max_exp, const double min_exp,
00287                           double *valuePtr, double *intvaluePtr, int *intdigitsPtr,
00288                           double *frcvaluePtr, int *frcdigitsPtr,
00289                           double *expvaluePtr, int *expdigitsPtr);
00290 
00297 ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end);
00298 
00308 const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot);
00309 int symop_to_mat4_err(const char *symop);
00310 ccp4_symop mat4_to_rotandtrn(const float rsm[4][4]);
00311 /* This is Charles' version of symtr */
00312 char *rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop);
00313 void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop);
00314 
00324 char *mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
00325 
00335 char *mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
00336 
00337 #ifdef __cplusplus
00338 }
00339 }
00340 #endif
00341 
00342 #endif  /* __CCP4_Parser__ */