gpp4  1.3.1
ccp4_parser.h
Go to the documentation of this file.
1 /*
2  ccp4_parser.h: Headers for functions to read in and "parse" CCP4
3  keyworded input.
4  Copyright (C) 2001 CCLRC, Peter Briggs
5 
6  This library is free software: you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation, either
9  version 3 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with This library. If not, see
18  <http://www.gnu.org/licenses/>.
19 
20 */
21 
93 /* Macro definitions */
94 
95 
96 #ifndef __CCP4_Parser__
97 #define __CCP4_Parser__
98 
99 
100 /* note order: these must be outside CCP4 namespace */
101 #include <stdio.h>
102 #include"ccp4_utils.h"
103 #include"ccp4_spg.h"
104 
105 /* Macro to make C functions callable from C++ */
106 #ifdef __cplusplus
107 namespace CCP4 {
108 extern "C" {
110 #endif
111 
112 
113 /* Parser String Sizes */
114 
115 #define CCP4_PARSER_MAXLINELENGTH 200
116 #define CCP4_PARSER_MAXFILENAMELENGTH 200
119 /* Structures and typedefs */
120 
121 
127 typedef struct {
128  char *fullstring;
129  char word[5];
130  double value;
131  int isstring;
132  int strlength;
133  int isnumber;
134  int intdigits;
136  int frcdigits;
138  int isquoted;
139  int isnull;
140  int ibeg;
141  int iend;
142 } CCP4PARSERTOKEN;
149 typedef struct {
150  /* "Public" members */
151  char keyword[5];
152  int ntokens;
154  /* "Private" members */
155  FILE *fp;
156  int maxtokens;
157  char *delim;
158  char *nulldelim;
159  char *comment;
160  double max_exponent;
161  double min_exponent;
162 } CCP4PARSERARRAY;
165 /* Function Prototypes */
166 
167 
168 /* Core cparser functions */
169 
176 CCP4PARSERARRAY* ccp4_parse_start(const int maxtokens);
177 
183 int ccp4_parse_end(CCP4PARSERARRAY *parsePtr);
184 
185 int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok);
186 
187 int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim,
188  const char *nulldelim);
189 int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars);
190 
191 int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent,
192  const double min_exponent);
193 int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr);
194 
195 int ccp4_parse(const char *line, CCP4PARSERARRAY *parser);
196 
213 int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser,
214  const int print);
215 
216 /* External utility functions */
217 
224 int ccp4_keymatch(const char *keyin1, const char *keyin2);
225 
226 /* Internal utility functions */
227 
233 char *strtoupper (char *str1, const char *str2);
234 
235 char *strtolower (char *str1, const char *str2);
236 
237 int strmatch (const char *str1, const char *str2);
238 
239 int charmatch(const char character, const char *charlist);
240 
241 int doublefromstr(const char *str, const double max_exp, const double min_exp,
242  double *valuePtr, double *intvaluePtr, int *intdigitsPtr,
243  double *frcvaluePtr, int *frcdigitsPtr,
244  double *expvaluePtr, int *expdigitsPtr);
245 
252 ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end);
253 
263 const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot);
264 
265  /*
266 int symop_to_mat4_err(const char *symop);
267  */
268 
269 ccp4_symop mat4_to_rotandtrn(const float rsm[4][4]);
270 
271 /* This is Charles' version of symtr */
272 char *rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop);
273 
274 void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop);
275 
285 char *mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
286 
296 char *mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4]);
297 
298 #ifdef __cplusplus
299 }
300 }
301 #endif
302 
303 #endif /* __CCP4_Parser__ */
304 
305 /*
306  Local variables:
307  mode: font-lock
308  End:
309 */
double min_exponent
Definition: ccp4_parser.h:161
int isquoted
Definition: ccp4_parser.h:138
int ccp4_keymatch(const char *keyin1, const char *keyin2)
Definition: ccp4_parser.c:1012
int ntokens
Definition: ccp4_parser.h:152
double max_exponent
Definition: ccp4_parser.h:160
int isnull
Definition: ccp4_parser.h:139
int charmatch(const char character, const char *charlist)
Definition: ccp4_parser.c:1124
int strmatch(const char *str1, const char *str2)
Definition: ccp4_parser.c:1094
char * delim
Definition: ccp4_parser.h:157
char * strtolower(char *str1, const char *str2)
Definition: ccp4_parser.c:1076
char * strtoupper(char *str1, const char *str2)
Definition: ccp4_parser.c:1056
char * nulldelim
Definition: ccp4_parser.h:158
int ccp4_parse_delimiters(CCP4PARSERARRAY *parsePtr, const char *delim, const char *nulldelim)
Definition: ccp4_parser.c:241
int intdigits
Definition: ccp4_parser.h:134
char * mat4_to_recip_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1737
int ccp4_parse_maxmin(CCP4PARSERARRAY *parsePtr, const double max_exponent, const double min_exponent)
Definition: ccp4_parser.c:363
CCP4PARSERARRAY * ccp4_parse_start(const int maxtokens)
Definition: ccp4_parser.c:71
double value
Definition: ccp4_parser.h:130
int doublefromstr(const char *str, const double max_exp, const double min_exp, double *valuePtr, double *intvaluePtr, int *intdigitsPtr, double *frcvaluePtr, int *frcdigitsPtr, double *expvaluePtr, int *expdigitsPtr)
Definition: ccp4_parser.c:1174
Data structure for symmetry information.
ccp4_symop symop_to_rotandtrn(const char *symchs_begin, const char *symchs_end)
Definition: ccp4_parser.c:1356
CCP4PARSERTOKEN * token
Definition: ccp4_parser.h:153
int ccp4_parse(const char *line, CCP4PARSERARRAY *parser)
Definition: ccp4_parser.c:411
char * rotandtrn_to_symop(char *symchs_begin, char *symchs_end, const ccp4_symop symop)
Definition: ccp4_parser.c:1587
int frcdigits
Definition: ccp4_parser.h:136
char * fullstring
Definition: ccp4_parser.h:128
int iend
Definition: ccp4_parser.h:141
void rotandtrn_to_mat4(float rsm[4][4], const ccp4_symop symop)
Definition: ccp4_parser.c:1599
int isnumber
Definition: ccp4_parser.h:133
CCP4 Parser array Construct to hold the information about a parsed line.
Definition: ccp4_parser.h:149
struct ccp4_symop_ ccp4_symop
int ccp4_parse_init_token(const CCP4PARSERARRAY *parsePtr, const int itok)
Definition: ccp4_parser.c:175
char * comment
Definition: ccp4_parser.h:159
char * mat4_to_symop(char *symchs_begin, char *symchs_end, const float rsm[4][4])
Definition: ccp4_parser.c:1625
int isstring
Definition: ccp4_parser.h:131
int maxtokens
Definition: ccp4_parser.h:156
ccp4_symop mat4_to_rotandtrn(const float rsm[4][4])
Definition: ccp4_parser.c:1564
int ibeg
Definition: ccp4_parser.h:140
CCP4 Parser token Construct to hold the information about a single token.
Definition: ccp4_parser.h:127
int ccp4_parser(char *line, const int n, CCP4PARSERARRAY *parser, const int print)
Definition: ccp4_parser.c:742
int ccp4_parse_comments(CCP4PARSERARRAY *parsePtr, const char *comment_chars)
Definition: ccp4_parser.c:315
FILE * fp
Definition: ccp4_parser.h:155
int ccp4_parse_end(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:143
int ccp4_parse_reset(CCP4PARSERARRAY *parsePtr)
Definition: ccp4_parser.c:214
const char * symop_to_mat4(const char *symchs_begin, const char *symchs_end, float *rot)
Definition: ccp4_parser.c:1398
int strlength
Definition: ccp4_parser.h:132
Utility functions.