MCPcopy Create free account
hub / github.com/dds-bridge/dds / read_file

Function read_file

library/tests/parse.cpp:105–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104
105bool read_file(
106 const string& fname,
107 int& number,
108 bool& GIBmode,
109 int ** dealer_list,
110 int ** vul_list,
111 DealPBN ** deal_list,
112 FutureTricks ** fut_list,
113 DdTableResults ** table_list,
114 ParResults ** par_list,
115 ParResultsDealer ** dealerpar_list,
116 PlayTracePBN ** play_list,
117 SolvedPlay ** trace_list)
118{
119 ifstream fin;
120 fin.open(fname);
121
122 string line;
123 if (! getline(fin, line))
124 {
125 cout << "First line bad: '" << line << "'" << endl;
126 return false;
127 }
128
129 vector<string> list;
130 list.clear();
131 splitIntoWords(line, list);
132
133 if (list.size() == 2 && get_head_element(list[0], "NUMBER"))
134 {
135 // Hopefully a txt-style file.
136 if (! str2int(list[1], number))
137 {
138 cout << "Not a number of hands: '" << list[1] << "'" << endl;
139 return false;
140 }
141 else if (number <= 0 || number > 100000)
142 {
143 cout << "Suspect number of hands: " << number << endl;
144 return false;
145 }
146 }
147 else if (! parseable_GIB(line))
148 {
149 cout << "Not a GIB-style start: '" << line << "'" << endl;
150 return false;
151 }
152 else
153 {
154 // Count the lines, then start over.
155 GIBmode = 1;
156 number = 1;
157 while (1)
158 {
159 if (! getline(fin, line))
160 break;
161 number++;
162 }

Callers 1

real_mainFunction · 0.85

Calls 13

splitIntoWordsFunction · 0.85
get_head_elementFunction · 0.85
str2intFunction · 0.85
parseable_GIBFunction · 0.85
parse_GIBFunction · 0.85
get_any_lineFunction · 0.85
parse_PBNFunction · 0.85
parse_FUTFunction · 0.85
parse_TABLEFunction · 0.85
parse_PARFunction · 0.85
parse_DEALERPARFunction · 0.85
parse_PLAYFunction · 0.85

Tested by

no test coverage detected