public override void Write(FdbFile writer) { writer.WriteObject(TableCount); writer.WriteObject(TableHeader); TableHeader.Write(writer); }
private static void Main(string[] args) { string path; if (args.Length >= 1) { path = args[0]; } else { Console.Write("Input: "); path = Console.ReadLine(); } Console.WriteLine($"Reading {path} ..."); var fdb = new FdbFile(path); Edit(fdb); fdb.Write(fdb); Console.Write("Output: "); var output = Console.ReadLine(); if (!File.Exists(output)) { File.Create(output).Dispose(); } var bytes = fdb.Complete(); File.WriteAllBytes(output, bytes); Console.WriteLine("Complete!"); }
public override void Write(FdbFile writer) { writer.WriteObject(this); writer.WriteObject(RowCount); writer.WriteObject(RowHeader); RowHeader?.Write(writer); }
public override void Write(FdbFile writer) { writer.WriteObject(this); writer.WriteObject(ColumnCount); writer.WriteObject(Data); Data?.Write(writer); }
public override void Write(FdbFile writer) { writer.WriteObject(this); foreach (var c in Value) { writer.WriteObject((byte)c); } writer.WriteObject((byte)0); }
public override void Write(FdbFile writer) { writer.WriteObject(this); foreach (var rowInfo in RowInfos) { writer.WriteObject(rowInfo); } foreach (var rowInfo in RowInfos) { rowInfo?.Write(writer); } }
public override void Write(FdbFile writer) { writer.WriteObject(this); for (var i = 0; i < Type.Length; i++) { writer.WriteObject((uint)Type[i]); writer.WriteObject(ColumnName[i]); } foreach (var s in ColumnName) { s.Write(writer); } }
public override void Write(FdbFile writer) { writer.WriteObject(this); writer.WriteObject(DataHeader); if (Linked == default) { writer.WriteObject(-1); } else { writer.WriteObject(Linked); } DataHeader?.Write(writer); Linked?.Write(writer); }
public override void Write(FdbFile writer) { writer.WriteObject(this); for (var i = 0; i < ColumnHeaders.Length; i++) { writer.WriteObject(ColumnHeaders[i]); writer.WriteObject(RowTopHeaders[i]); } for (var i = 0; i < ColumnHeaders.Length; i++) { ColumnHeaders[i].Write(writer); RowTopHeaders[i].Write(writer); } }
public override void Write(FdbFile writer) { writer.WriteObject(this); for (var i = 0; i < Types.Length; i++) { writer.WriteObject((uint)Types[i]); writer.WriteObject(Data[i]); } foreach (var o in Data) { if (o is FdbData data) { data.Write(writer); } } }
public FdbTableHeader(BinaryReader reader, FdbFile file) { ColumnHeaders = new FdbColumnHeader[file.TableCount]; RowTopHeaders = new FdbRowBucket[file.TableCount]; for (var i = 0; i < file.TableCount; i++) { using (new FdbScope(reader)) { ColumnHeaders[i] = new FdbColumnHeader(reader); } using (new FdbScope(reader)) { RowTopHeaders[i] = new FdbRowBucket(reader); } } }
public FdbTableHeader(BinaryReader reader, FdbFile file, Action <uint> onTableLoaded) { ColumnHeaders = new FdbColumnHeader[file.TableCount]; RowTopHeaders = new FdbRowBucket[file.TableCount]; for (var i = 0; i < file.TableCount; i++) { using (new FdbScope(reader)) { ColumnHeaders[i] = new FdbColumnHeader(reader); } using (new FdbScope(reader)) { RowTopHeaders[i] = new FdbRowBucket(reader); } onTableLoaded.Invoke((uint)i); } }
public override void Write(FdbFile writer) { writer.WriteObject(this); writer.WriteObject(Value); }
private static void Edit(FdbFile file) { var index = 0; while (true) { Console.Clear(); for (var i = index; i < file.TableCount; i++) { Console.WriteLine($"[{i}] " + $"{file.TableHeader.ColumnHeaders[i].TableName}\t" + $"{file.TableHeader.ColumnHeaders[i].ColumnCount} columns\t" + $"{file.TableHeader.RowTopHeaders[i].RowCount} rows" ); if (i == index + 9) { break; } } Console.WriteLine("<up>/<down>/<index>/<save>/<create>"); var input = Console.ReadLine(); if (input == default) { continue; } switch (input.ToLower()) { case "up": index -= 10; if (index < 0) { index = 0; } continue; case "down": index += 10; if (index > file.TableCount) { index = (int)file.TableCount; } continue; case "save": return; case "create": AddTable(file); break; default: if (int.TryParse(input, out var selected)) { try { var select = ( file.TableHeader.ColumnHeaders[selected], file.TableHeader.RowTopHeaders[selected] ); EditTable(select); } catch { Console.WriteLine("Selected out of range!"); } } break; } } }
private static void AddTable(FdbFile file) { Console.Write("New Table Name: "); var tableName = Console.ReadLine(); var tableInfo = new List <(string, DataType)>(); int columnIndex = default; while (true) { Console.Write($"[{columnIndex}] Column Name: "); var columnName = Console.ReadLine(); while (true) { Console.Write($"[{columnIndex}] Column Type: "); if (Enum.TryParse(typeof(DataType), Console.ReadLine(), out var newType)) { var data = (DataType)newType; tableInfo.Add((columnName, data)); break; } Console.WriteLine("Invalid type"); } Console.Write("Another column? <y>/<>"); switch (Console.ReadLine()?.ToLower()) { case "y": columnIndex++; continue; default: goto Finish; } } Finish: file.TableCount++; var columnHeader = file.TableHeader.ColumnHeaders.ToList(); var rowsHeader = file.TableHeader.RowTopHeaders.ToList(); var header = new FdbColumnHeader { ColumnCount = (uint)tableInfo.Count, TableName = new FdbString(tableName), Data = new FdbColumnData { ColumnName = tableInfo.Select(s => new FdbString(s.Item1)).ToArray(), Type = tableInfo.Select(s => s.Item2).ToArray() } }; var rowHeader = new FdbRowBucket { RowCount = 128, RowHeader = new FdbRowHeader { RowInfos = Enumerable.Repeat <FdbRowInfo>(null, 128).ToArray() } }; columnHeader.Add(header); rowsHeader.Add(rowHeader); file.TableHeader.ColumnHeaders = columnHeader.ToArray(); file.TableHeader.RowTopHeaders = rowsHeader.ToArray(); }