[14777] | 1 | namespace HeuristicLab.BenchmarkSuite.Views {
|
---|
[14952] | 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Globalization;
|
---|
[14909] | 5 | using System.Linq;
|
---|
| 6 |
|
---|
[14777] | 7 | public static class ViewHelper {
|
---|
[15032] | 8 | public static string StringifyInput(ExampleArgumentType type, int offset, string floatFormat, Example example, string valueSeparator) {
|
---|
[14777] | 9 | switch (type) {
|
---|
[14952] | 10 | case ExampleArgumentType.Integer: return example.InputInteger[offset].ToString();
|
---|
| 11 | case ExampleArgumentType.IntegerVector: return "[" + string.Join(", ", example.InputIntegerVector[offset]) + "]";
|
---|
[14777] | 12 |
|
---|
[15032] | 13 | case ExampleArgumentType.Float: return example.InputFloat[offset].ToString(floatFormat, CultureInfo.CurrentUICulture);
|
---|
| 14 | case ExampleArgumentType.FloatVector: return "[" + string.Join(", ", example.InputFloatVector[offset].Select(x => x.ToString(floatFormat, CultureInfo.InvariantCulture))) + "]";
|
---|
[14777] | 15 |
|
---|
[14952] | 16 | case ExampleArgumentType.Boolean: return example.InputBoolean[offset].ToString();
|
---|
| 17 | case ExampleArgumentType.Char: return example.InputChar[offset].ToString();
|
---|
[14777] | 18 |
|
---|
[14952] | 19 | case ExampleArgumentType.String: return example.InputString[offset];
|
---|
| 20 | case ExampleArgumentType.StringVector: return "[" + string.Join(", ", example.InputStringVector[offset]) + "]";
|
---|
| 21 |
|
---|
[14777] | 22 | default: return string.Empty;
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[15032] | 26 | public static string StringifyOutput(ExampleArgumentType type, int offset, string floatFormat, Example example, string valueSeparator) {
|
---|
[14777] | 27 | switch (type) {
|
---|
[14952] | 28 | case ExampleArgumentType.Integer: return example.OutputInteger[offset].ToString();
|
---|
| 29 | case ExampleArgumentType.IntegerVector: return "[" + string.Join(", ", example.OutputIntegerVector[offset]) + "]";
|
---|
[14777] | 30 |
|
---|
[15032] | 31 | case ExampleArgumentType.Float: return example.OutputFloat[offset].ToString(floatFormat, CultureInfo.InvariantCulture);
|
---|
| 32 | case ExampleArgumentType.FloatVector: return "[" + string.Join(", ", example.OutputFloatVector[offset].Select(x => x.ToString(floatFormat, CultureInfo.InvariantCulture))) + "]";
|
---|
[14777] | 33 |
|
---|
[14952] | 34 | case ExampleArgumentType.Boolean: return example.OutputBoolean[offset].ToString();
|
---|
| 35 | case ExampleArgumentType.Char: return example.OutputChar[offset].ToString();
|
---|
[14777] | 36 |
|
---|
[14952] | 37 | case ExampleArgumentType.String: return example.OutputString[offset];
|
---|
| 38 | case ExampleArgumentType.Print: return example.OutputPrint;
|
---|
| 39 | case ExampleArgumentType.StringVector: return "[" + string.Join(", ", example.OutputStringVector[offset]) + "]";
|
---|
[14909] | 40 |
|
---|
[14777] | 41 | default: return string.Empty;
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | private const string IntegerColumnHeader = "int";
|
---|
| 46 | private const string IntegersColumnHeader = "int[]";
|
---|
[14834] | 47 | private const string DoubleColumnHeader = "float";
|
---|
| 48 | private const string DoublesColumnHeader = "float[]";
|
---|
[14777] | 49 | private const string BooleanColumnHeader = "bool";
|
---|
| 50 | private const string CharColumnHeader = "char";
|
---|
| 51 | private const string StringColumnHeader = "string";
|
---|
[14909] | 52 | private const string PrintColumnHeader = "print";
|
---|
[14777] | 53 | private const string StringsColumnHeader = "string[]";
|
---|
| 54 | public static string GetHeaderTypeName(ExampleArgumentType type) {
|
---|
| 55 | switch (type) {
|
---|
| 56 | case ExampleArgumentType.Integer: return IntegerColumnHeader;
|
---|
| 57 | case ExampleArgumentType.Float: return DoubleColumnHeader;
|
---|
[14875] | 58 | case ExampleArgumentType.Boolean: return BooleanColumnHeader;
|
---|
[14777] | 59 | case ExampleArgumentType.Char: return CharColumnHeader;
|
---|
| 60 | case ExampleArgumentType.String: return StringColumnHeader;
|
---|
[14909] | 61 | case ExampleArgumentType.Print: return PrintColumnHeader;
|
---|
[14875] | 62 | case ExampleArgumentType.IntegerVector: return IntegersColumnHeader;
|
---|
| 63 | case ExampleArgumentType.FloatVector: return DoublesColumnHeader;
|
---|
| 64 | case ExampleArgumentType.StringVector: return StringsColumnHeader;
|
---|
[14777] | 65 | default: return string.Empty;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
[14952] | 68 |
|
---|
| 69 | public static Dictionary<ExampleArgumentType, int> CreateArgumentCountDict() {
|
---|
| 70 | return Enum.GetValues(typeof(ExampleArgumentType)).Cast<ExampleArgumentType>().ToDictionary(type => type, _ => 0);
|
---|
| 71 | }
|
---|
[14777] | 72 | }
|
---|
| 73 | }
|
---|