Debian Codegraph @

terps/tads/tads3/tccmdutl.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2002 by Michael J. Roberts. All Rights Reserved.
3 *
4 * Please see the accompanying license file, LICENSE.TXT, for information
5 * on using and copying this software.
6 */
7 /*
8 Name
9 tccmdutl.cpp - TADS 3 Compiler command-line parsing utilities
10 Function
11 Defines some utility functions for command-line parsing.
12 Notes
13
14 Modified
15 04/03/02 MJRoberts - Creation
16 */
17
18 #ifndef TCCMDUTL_H
19 #define TCCMDUTL_H
20
21 #include <stdlib.h>
22
23
24 /*
25 * Command utilities class. We use a class to group these functions into
26 * a class namespace
27 */
28 class CTcCommandUtil
29 {
30 public:
31 /* get an option argument */
32 static char *get_opt_arg(int argc, char **argv, int *curarg, int optlen);
33
34 /* parse an options file */
35 static int parse_opt_file(osfildef *fp, char **argv,
36 class CTcOptFileHelper *helper);
37 };
38
39 /*
40 * Helper interface for parse_opt_file helper. An implementation of this
41 * interface must be provided to parse_opt_file().
42 */
43 class CTcOptFileHelper
44 {
45 public:
46 /*
47 * Allocate an option string. Allocates the given number of bytes of
48 * memory. Strings allocated with this must be freed with
49 * free_opt_file_str().
50 */
51 virtual char *alloc_opt_file_str(size_t len) = 0;
52
53 /* free a string allocated with alloc_opt_file_str() */
54 virtual void free_opt_file_str(char *str) = 0;
55
56 /*
57 * Process a comment line. We call this for each line that we find
58 * starting with "#" and for each blank line.
59 */
60 virtual void process_comment_line(const char *str) = 0;
61
62 /* process a non-comment line */
63 virtual void process_non_comment_line(const char *str) = 0;
64
65 /*
66 * Process a configuration line. Once we see a configuration flag (a
67 * line reading "[Config:xxx]"), we'll process all subsequent text in
68 * the file through this function.
69 *
70 * 'config_id' is the 'xxx' value in the [Config:xxx] configuration
71 * flag line that started the section. 'is_id_line' is true if we're
72 * processing the "[Config:xxx]" line itself, false if it's any other
73 * line within the [Config:xxx] section.
74 *
75 * Note that this routine receives ALL lines within a configuration
76 * section, including comment lines. Once we're inside a configuration
77 * block, the entire contents are opaque to the generic processor,
78 * since even the comment format is up to the configuration section's
79 * owner to define.
80 */
81 virtual void process_config_line(const char *config_id,
82 const char *str,
83 int is_id_line) = 0;
84 };
85
86 #endif /* TCCMDUTL_H */
87