initial setup of thesis repository
[cluster_expansion_thesis.git] / little_helpers / tikz / sketch-0.2.161 / opts.h
blob48707b8d27038dba70213f923ceb56c18528f263
1 /* opts.h
2 Copyright (C) 2005,2006,2007,2008 Eugene K. Ressler, Jr.
4 This file is part of Sketch, a small, simple system for making
5 3d drawings with LaTeX and the PSTricks or TikZ package.
7 Sketch is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 Sketch is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Sketch; see the file COPYING.txt. If not, see
19 http://www.gnu.org/copyleft */
21 #ifndef __OPTS_H
22 #define __OPTS_H
24 #include <stdio.h>
25 #include "dynarray.h"
26 #include "error.h"
28 #define OPT_NONE 0x00
30 // type flags
31 #define OPT_INTERNAL 0x01
32 #define OPT_LINE 0x02
33 #define OPT_POLYGON 0x04
35 // default class flags
36 #define OPT_LINE_STYLE 0x08
37 #define OPT_FILL_STYLE 0x10
38 #define OPT_FILL_COLOR 0x20
39 #define OPT_DEFAULTS (OPT_LINE_STYLE|OPT_FILL_STYLE|OPT_FILL_COLOR)
41 // key doesn't have type information; use val
42 #define OPT_TYPE_IN_VAL 0x40
44 // sufficient to emit value without key
45 #define OPT_EMIT_VAL 0x80
47 // some dynamic array types
48 typedef struct opt_t
50 char *key, *val;
52 OPT;
54 typedef struct opt_list_t
56 DYNAMIC_ARRAY_FIELDS (OPT, elt, n_elts);
58 OPT_LIST;
60 DECLARE_DYNAMIC_ARRAY_PROTOS (OPT_LIST, OPT, opt_list, elt, n_elts)
62 typedef struct opts_t
64 // DEBUG: could cache list data here for speed
65 OPT_LIST list[1];
67 OPTS;
69 void init_opts (OPTS * opts);
70 void setup_opts (OPTS * opts, char *opt_str, SRC_LINE line);
71 OPTS *raw_opts (void);
72 OPTS *new_opts (char *opts_str, SRC_LINE line);
73 void clear_opts (OPTS * opts);
74 char *opt_val (OPTS * opts, char *opt);
75 int bool_opt_p (OPTS * opts, char *opt, int default_p);
76 int opt_type (OPT * opt, int default_type, int lang);
77 void add_no_edges_default_opt (OPTS ** opts_ptr, int lang);
78 void add_solid_white_default_opt (OPTS ** opts_ptr, int lang);
79 // selective copy for splitting option lists by type
80 OPTS *copy_opts (OPTS * opts, int type_mask, int lang);
81 OPTS *cat_opts (OPTS * dst, OPTS * src);
82 // selective copy for splitting out line options and modifying arrows
83 OPTS *copy_line_opts (OPTS * opts, int first_p, int last_p, int lang);
84 void emit_opts_raw (FILE * f, OPTS * opts, int lang);
85 void emit_opts (FILE * f, OPTS * opts, int lang);
86 void emit_opts_with_exceptions (FILE * f, OPTS * opts, char ** exceptions, int lang);
87 void check_opts (OPTS * opts,
88 int allowed, char *allowed_msg, int lang,
89 SRC_LINE line);
91 // slice src into dest using Perl/Python conventions
92 char *str_slice (char *dst, int dst_size, char *src, int beg, int end);
93 #define SLICE_TO_END ((int)(~0u >> 1))
95 // find last occurance of aachar in set in src; return index or -1 if none
96 int str_last_occurance (char *src, char *set);
98 // strtok with a state variable instead of static
99 char *istrtok (int *p, char *s, char sep);
101 #endif