71 bool end_of_file = !_source.CanTake;
72 if (!success && (!end_of_file || _leftOver ==
null))
75 string decoded = _leftOver;
79 int row_count = _rowSplitter.SafeSplit(decoded, RowSeparators, StringSplitOptions.RemoveEmptyEntries);
80 string[] rows = _rowSplitter.buffer;
82 _leftOver = end_of_file ? null : rows[row_count - 1];
84 if (decoded[decoded.Length - 1] ==
'\n' && !end_of_file)
86 if (!end_of_file) row_count -= 1;
89 next.Bytes =
new byte[row_count * 32];
90 int byte_offset = 0, rows_skipped = 0, i = 0;
94 for (i = 0; i < row_count; i++)
96 if (rows[i].Length == 0)
101 _binarySplitter.Split(rows[i],
',');
102 string[] items = _binarySplitter.buffer;
105 UInt64.Parse(items[1], IntParseStyle, _parseCulture),
106 UInt64.Parse(items[0], IntParseStyle, _parseCulture),
107 Double.Parse(items[2], DoubleParseStyle, _parseCulture),
108 Double.Parse(items[3], DoubleParseStyle, _parseCulture));
113 throw new ArgumentException(
"There was an error parsing the contents of " +
114 "the YELT row " + (i + 1) +
" containing \"" + rows[i] +
115 "\". Expected \"UInt64,UInt64,Double,Double\". Error: " + ex.Message, ex);
118 next.LengthFilled = next.Bytes.Length - (rows_skipped * 32);
130 public static void CopyAsBytes(
byte[] destination, ref
int offset, ulong trialId, ulong eventId,
131 double sequence,
double loss)
133 BitConverter.GetBytes(trialId).CopyTo(destination, offset);
135 BitConverter.GetBytes(eventId).CopyTo(destination, offset);
137 BitConverter.GetBytes(sequence).CopyTo(destination, offset);
139 BitConverter.GetBytes(loss).CopyTo(destination, offset);