public ColumnIndexOutOfBoundsException(TextualDatabase database, TextualTable table, int index) { TextualDatabase = database; TextualTable = table; message = string.Format(MESSAGE_FORMAT, table.Name, index); }
private TextualRow parseRow(TextualTable table) { TextualRow row = new TextualRow(table); // | "val1" | 2 | "val3" | expectToken(TokenType.Pipe); while (!matchToken(TokenType.Dash)) { if (matchToken(TokenType.Number)) { row.SetValueOrdered(Convert.ToDouble(expectToken(TokenType.Number).Value)); } else { row.SetValueOrdered(expectToken(TokenType.String).Value); } expectToken(TokenType.Pipe); } // ------------- while (acceptToken(TokenType.Dash)) { ; } return(row); }
public IncorrectValueFormatException(TextualOperation operation, TextualTable table) { TextualOperation = operation; TextualTable = table; message = MESSAGE_FORMAT; }
public ColumnAlreadyExistsException(TextualDatabase database, TextualTable table, string column) { TextualDatabase = database; TextualTable = table; message = string.Format(MESSAGE_FORMAT, table.Name, column); }
private TextualTable parseTable(TextualDatabase db) { // name: string name = expectToken(TokenType.Identifier).Value; expectToken(TokenType.Colon); TextualTable table = new TextualTable(db, name); // | column1 | column2 | column3 | expectToken(TokenType.Pipe); while (!matchToken(TokenType.Dash)) { table.Columns.Add(expectToken(TokenType.Identifier).Value); expectToken(TokenType.Pipe); } // ------------- while (acceptToken(TokenType.Dash)) { ; } // Rows while (!matchToken(TokenType.Question)) { table.AddRow(parseRow(table)); } // ? expectToken(TokenType.Question); return(table); }
private TextualTable parseShowTables() { var result = new TextualTable(database, database.Name); result.AddColumn("table"); result.AddColumn("columns"); result.AddColumn("rowCount"); foreach (var pair in database.Tables) { var row = new TextualRow(result); row.SetValueOrdered(pair.Key); var sb = new StringBuilder(); foreach (var column in pair.Value.Columns) { sb.AppendFormat("{0} ", column); } row.SetValueOrdered(sb.ToString()); row.SetValueOrdered(pair.Value.Rows.Count); result.AddRow(row); } return(result); }
public TextualDeleteRowOperation(TextualTable table) { this.table = table; mirroredSourceRows = new List <TextualRow>(); Result = table; }
public RowNotFoundException(TextualDatabase database, TextualTable table, TextualRow row) { TextualDatabase = database; TextualTable = table; TextualRow = row; message = string.Format(MESSAGE_FORMAT, table.Name); }
public TextualSelectOperation(TextualTable table, params string[] columns) { Result = new TextualTable(table.ParentDatabase, table.Name); this.table = table; if (columns.Length == 0) { columns = table.Columns.ToArray(); } foreach (var column in columns) { Result.AddColumn(column); } foreach (var srcRow in table.Rows) { Result.AddRow(srcRow); } }
private TextualTable parseShowColumns() { // IN table expectToken(TokenType.Identifier, "IN"); string table = expectToken(TokenType.Identifier).Value; var result = new TextualTable(database, table); result.AddColumn("column"); foreach (var column in database.GetTable(table).Columns) { var row = new TextualRow(result); row.SetValueOrdered(column); result.AddRow(row); } return(result); }
public TextualUpdateOperation(TextualTable table, string[] columns, object[] values) { this.table = table; this.columns = columns; this.values = values; mirroredSourceRows = new List <TextualRow>(); foreach (var srcRow in table.Rows) { mirroredSourceRows.Add(srcRow); } if (columns.Length != values.Length) { throw new ColumnValueCountMismatchException(this, columns.Length, values.Length); } Result = table; }
private void handleResult(TextualTable table) { if (table == null) { return; } if (table.Rows.Count > 15) { Console.WriteLine("Result table has more than 15 values. Display (y/N)? "); string res = Console.ReadLine(); if (res.ToUpper() == "Y" || res.ToUpper() == "YES") { Console.WriteLine(table); } } else { Console.WriteLine(table); } }
public TextualInsertOperation(TextualTable table) { this.table = table; }
public TextualCreateColumnOperation(TextualTable table) { this.table = table; }
public TextualRenameTableOperation(TextualTable table) { this.table = table; Result = table; }
public TextualCreateTableOperation(TextualDatabase database, string name) { Result = new TextualTable(database, name); }