| 16 | |
| 17 | |
| 18 | bool cDataManager_Base::PrintRow(Avida::Output::File& data_file, cString row_entries, char sep) |
| 19 | { |
| 20 | bool result = true; |
| 21 | |
| 22 | row_entries.CompressWhitespace(); |
| 23 | |
| 24 | // If we haven't output the header for this file yet, do so. |
| 25 | if ( data_file.HeaderDone() == false ) { |
| 26 | // Setup the format string for the top... |
| 27 | cString format(row_entries); |
| 28 | cString out_filetype(filetype); |
| 29 | |
| 30 | // Make sure its space seperated... |
| 31 | if (sep != ' ') { |
| 32 | int pos = -1; |
| 33 | while ( (pos = format.Find(sep)) != -1 ) format[pos] = ' '; |
| 34 | } |
| 35 | |
| 36 | // Write out the filetype and format strip |
| 37 | out_filetype.Insert("#filetype "); |
| 38 | format.Insert("#format "); |
| 39 | data_file.WriteRawComment(out_filetype); |
| 40 | data_file.WriteRawComment(format); |
| 41 | |
| 42 | // Setup the human-readable description... |
| 43 | cString header_entries(row_entries); |
| 44 | cString cur_desc; |
| 45 | data_file.WriteComment(" "); |
| 46 | data_file.WriteComment("Legend:"); |
| 47 | while (header_entries.GetSize() > 0) { |
| 48 | cString cur_entry( header_entries.Pop(sep) ); |
| 49 | if ( GetDesc(cur_entry, cur_desc) == false ) { |
| 50 | result = false; |
| 51 | continue; |
| 52 | } |
| 53 | data_file.WriteColumnDesc(cur_desc); |
| 54 | } |
| 55 | data_file.Endl(); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | ofstream& fp = data_file.OFStream(); |
| 60 | while (row_entries.GetSize() > 0) { |
| 61 | cString cur_entry( row_entries.Pop(sep) ); |
| 62 | if ( Print(cur_entry, fp) == false ) { |
| 63 | cerr << "Data manager unable to find entry '" |
| 64 | << cur_entry << "'" << endl; |
| 65 | result = false; |
| 66 | continue; |
| 67 | } |
| 68 | fp << " "; |
| 69 | } |
| 70 | fp << endl; |
| 71 | |
| 72 | return result; |
| 73 | } |
| 74 |
no test coverage detected