1 | #ifndef MAD_TABLE_H |
---|
2 | #define MAD_TABLE_H |
---|
3 | |
---|
4 | // types |
---|
5 | |
---|
6 | struct int_array; |
---|
7 | struct char_p_array; |
---|
8 | |
---|
9 | struct node; |
---|
10 | struct in_cmd; |
---|
11 | struct sequence; |
---|
12 | struct name_list; |
---|
13 | struct command_list; |
---|
14 | |
---|
15 | struct table |
---|
16 | { |
---|
17 | char name[NAME_L], |
---|
18 | type[NAME_L]; /* like "twiss", "survey" etc. */ |
---|
19 | int max, /* max. # rows */ |
---|
20 | curr, /* current # rows */ |
---|
21 | num_cols, /* total # columns - fixed */ |
---|
22 | org_cols, /* original # columns from definition */ |
---|
23 | dynamic, /* if != 0, values taken from current row */ |
---|
24 | origin; /* 0 if created in job, 1 if read */ |
---|
25 | struct char_p_array* header; /* extra lines for file header */ |
---|
26 | struct int_array* col_out; /* column no.s to be written (in this order) */ |
---|
27 | struct int_array* row_out; /* flag for row: 1 write, 0 don't */ |
---|
28 | struct char_p_array* node_nm; /* names of nodes at each row */ |
---|
29 | struct char_p_array** l_head; /* extra lines to be put in front of a line */ |
---|
30 | struct node** p_nodes; /* pointers to nodes at each row */ |
---|
31 | char*** s_cols; /* string columns */ |
---|
32 | double** d_cols; /* double precision columns */ |
---|
33 | int stamp; |
---|
34 | struct name_list* columns; /* names + types (in inform): |
---|
35 | 1 double, 3 string */ |
---|
36 | struct sequence* org_sequ; /* pointer to sequence it refers to */ |
---|
37 | }; |
---|
38 | |
---|
39 | struct table_list |
---|
40 | { |
---|
41 | char name[NAME_L]; |
---|
42 | int max, /* max. pointer array size */ |
---|
43 | curr; /* current occupation */ |
---|
44 | struct name_list* names; /* index list of tables */ |
---|
45 | struct table** tables; |
---|
46 | int stamp; |
---|
47 | }; |
---|
48 | |
---|
49 | struct table_list_list |
---|
50 | { |
---|
51 | char name[NAME_L]; |
---|
52 | int max, /* max. pointer array size */ |
---|
53 | curr; /* current occupation */ |
---|
54 | struct table_list** table_lists; |
---|
55 | int stamp; |
---|
56 | }; |
---|
57 | |
---|
58 | // interface |
---|
59 | |
---|
60 | struct table* make_table(char* name, char* type, char** table_cols, int* table_types, int rows); |
---|
61 | struct table* new_table(char* name, char* type, int rows, struct name_list* cols); |
---|
62 | struct table_list* new_table_list(int size); |
---|
63 | struct table_list_list* new_table_list_list(int size); |
---|
64 | struct table* delete_table(struct table*); |
---|
65 | struct table* read_table(struct in_cmd*); |
---|
66 | struct table* read_my_table(struct in_cmd*); |
---|
67 | |
---|
68 | void check_table(char* string); |
---|
69 | void check_tabstring(char* string); |
---|
70 | double table_value(void); |
---|
71 | void add_to_table_list(struct table*, struct table_list*); |
---|
72 | void add_vars_to_table(struct table*); |
---|
73 | void set_vars_from_table(struct table*); |
---|
74 | void double_table(char* table); |
---|
75 | void grow_table(struct table*); /* doubles number of rows */ |
---|
76 | void print_table(struct table*); |
---|
77 | void make_map_table(int* map_table_max_rows); |
---|
78 | int get_table_range(char* range, struct table*, int* rows); |
---|
79 | void out_table(char* tname, struct table*, char* filename); |
---|
80 | void reset_count(char* table); /* resets table counter to zero */ |
---|
81 | void sector_out(char* sector_table_name, double* pos, double* kick, double* rmatrix, double* tmatrix); |
---|
82 | void table_range(char* table, char* range, int* rows); |
---|
83 | |
---|
84 | void augment_count(char* table); |
---|
85 | void augmentcountonly(char* table); |
---|
86 | |
---|
87 | //int str_from_table (const char* table, const char* name, int* row, char* val); |
---|
88 | //int str_from_tablet (struct table *tbl, const char* name, int* row, char* val); |
---|
89 | //int nodename_from_table_row(const char* table, /* no name */ const int* row, char* string); |
---|
90 | |
---|
91 | int table_length(const char* table); |
---|
92 | int table_exists(const char* table); |
---|
93 | int table_column_exists(const char* table, const char* name); |
---|
94 | int table_header_exists(const char* table, const char *name); |
---|
95 | |
---|
96 | int double_from_table_header(const char* table, const char* name, double* val); |
---|
97 | |
---|
98 | int double_from_table_row(const char* table, const char* name, const int* row, double* val); |
---|
99 | int string_from_table_row(const char* table, const char* name, const int* row, char* string); |
---|
100 | |
---|
101 | int double_to_table_row (const char* table, const char* name, const int* row, const double* val); |
---|
102 | int string_to_table_row (const char* table, const char* name, const int* row, const char* string); |
---|
103 | |
---|
104 | int double_to_table_curr (const char* table, const char* name, const double* val); |
---|
105 | int vector_to_table_curr (const char* table, const char* name, const double* vals, const int* nval); |
---|
106 | int string_to_table_curr (const char* table, const char* name, const char* string); |
---|
107 | int comment_to_table_curr(const char* table, const char* comment, const int* length); |
---|
108 | |
---|
109 | double get_table_value(const char* table_s, const char *row_s, const char *col_s); |
---|
110 | void set_table_value(const char* table_s, const char *row_s, const char *col_s, double *val); |
---|
111 | |
---|
112 | struct column_info{ |
---|
113 | void* data; |
---|
114 | int length; |
---|
115 | char datatype; |
---|
116 | char datasize; |
---|
117 | }; |
---|
118 | |
---|
119 | struct column_info table_get_column(char* table_name,char* column_name); |
---|
120 | |
---|
121 | #endif // MAD_TABLE_H |
---|
122 | |
---|