Orbiter 2022
Combinatorial Objects
data_file.cpp
Go to the documentation of this file.
1// data_file.cpp
2//
3// Anton Betten
4//
5//
6// October 13, 2011
7//
8//
9//
10//
11//
12
13#include "foundations.h"
14
15using namespace std;
16
17
18namespace orbiter {
19namespace layer1_foundations {
20namespace data_structures {
21
22
24{
25 null();
26}
27
29{
30 freeself();
31}
32
34{
35 nb_cases = -1;
36 set_sizes = NULL;
37 sets = NULL;
38 casenumbers = NULL;
39 Ago_ascii = NULL;
40 Aut_ascii = NULL;
42 nb_candidates = NULL;
43 candidates = NULL;
44}
45
47{
48 int i;
49
50 cout << "data_file::freeself" << endl;
51 if (nb_cases >= 0) {
52 for (i = 0; i < nb_cases; i++) {
53 FREE_lint(sets[i]);
56 }
62 if (f_has_candidates) {
64 for (i = 0; i < nb_cases; i++) {
66 }
68 }
69 }
70 null();
71 cout << "data_file::freeself done" << endl;
72}
73
74void data_file::read(std::string &fname,
75 int f_casenumbers, int verbose_level)
76{
77 int f_v = (verbose_level >= 1);
79
80 if (f_v) {
81 cout << "data_file::read trying to read file "
82 << fname << " of size " << Fio.file_size(fname) << endl;
83 cout << "f_casenumbers=" << f_casenumbers << endl;
84 }
85 data_file::fname.assign(fname);
86
88 f_casenumbers,
89 nb_cases,
92 verbose_level);
93 if (f_v) {
94 cout << "data_file::read finished" << endl;
95 }
96}
97
98void data_file::read_candidates(std::string &candidates_fname,
99 int verbose_level)
100{
101 int f_v = (verbose_level >= 1);
102 int i, cnt, a, b;
104
105 if (f_v) {
106 cout << "data_file::read_candidates trying to read "
107 "candidates file " << candidates_fname << " of size "
108 << Fio.file_size(candidates_fname) << endl;
109 }
110
113 {
114 ifstream fp(candidates_fname);
115 cnt = 0;
116 while (TRUE) {
117 fp >> a;
118 if (a == -1) {
119 break;
120 }
121 for (i = 0; i < a; i++) {
122 fp >> b;
123 }
124 fp >> b;
125 if (b != -1) {
126 cout << "data_file::read_candidates b != -1" << endl;
127 exit(1);
128 }
129 fp >> nb_candidates[cnt];
130 candidates[cnt] = NEW_int(nb_candidates[cnt]);
131 for (i = 0; i < nb_candidates[cnt]; i++) {
132 fp >> candidates[cnt][i];
133 }
134 fp >> b; // read final -1
135 cnt++;
136 if (cnt > nb_cases) {
137 cout << "data_file::read_candidates cnt > nb_cases" << endl;
138 exit(1);
139 }
140 }
141 if (cnt != nb_cases) {
142 cout << "data_file::read_candidates cnt != nb_cases" << endl;
143 exit(1);
144 }
145 }
147 if (f_v) {
148 cout << "data_file::read_candidates finished" << endl;
149 }
150}
151
152}}}
153
154
void read_candidates(std::string &candidates_fname, int verbose_level)
Definition: data_file.cpp:98
void read(std::string &fname, int f_casenumbers, int verbose_level)
Definition: data_file.cpp:74
void read_and_parse_data_file_fancy(std::string &fname, int f_casenumbers, int &nb_cases, int *&Set_sizes, long int **&Sets, char **&Ago_ascii, char **&Aut_ascii, int *&Casenumbers, int verbose_level)
Definition: file_io.cpp:2304
#define FREE_pchar(p)
Definition: foundations.h:648
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_pint(n)
Definition: foundations.h:627
#define FREE_plint(p)
Definition: foundations.h:643
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_char(p)
Definition: foundations.h:646
#define FREE_lint(p)
Definition: foundations.h:642
#define FREE_pint(p)
Definition: foundations.h:641
the orbiter library for the classification of combinatorial objects