| 103 | |
| 104 | |
| 105 | bool 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 | } |
no test coverage detected