/*Helper functions*/ private string writeInputs() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < inputs.getSize(); i++) { Vid_Object obj = inputs.getInput_atIndex(i); if (obj != null) { if (i == 0) { sb.Append(obj.ToString()); if (0 < inputs.getSize()) { sb.AppendLine(","); } } else { sb.Append(TabTool.TabCount() + obj.ToString()); if (i < inputs.getSize() - 1) { sb.AppendLine(","); } } } } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null) { sb.AppendLine("UPDATE error::NoTable SET "); } else { sb.AppendLine("UPDATE " + inputs.getInput_atIndex(0).ToString() + " SET"); if (inputs.getInput_atIndex(1) != null) { TabTool.incromentCount(); sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); TabTool.deccromentCount(); } if (inputs.getInput_atIndex(2) != null) { TabTool.incromentCount(); sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(2).ToString()); TabTool.deccromentCount(); } } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null) { sb.Append("ALTER TABLE error::NoTable SET "); } else { sb.Append("ALTER TABLE " + inputs.getInput_atIndex(0).ToString() + " "); } if (state == AlterState.ADD_COL) { if (inputs.getInput_atIndex(1) != null) { sb.AppendLine("ADD COLUMN "); sb.Append(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); } } else if (inputs.getInput_atIndex(1) != null) { sb.AppendLine("DROP COLUMN "); sb.Append(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); } sb.Append(";"); return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(""); if (inputs.getInput_atIndex(1) == null) { sb.AppendLine("SELECT *"); } else { sb.AppendLine("SELECT " + inputs.getInput_atIndex(1).ToString()); } if (inputs.getInput_atIndex(0) == null) { sb.AppendLine(TabTool.TabCount() + "FROM error:NoT"); } else { sb.AppendLine(TabTool.TabCount() + "FROM " + inputs.getInput_atIndex(0).ToString()); } if (inputs.getInput_atIndex(2) != null) { sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(2).ToString()); } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null || inputs.getInput_atIndex(1) == null) { sb.Append(""); } else { switch (logicType) { case BasicLogic.AND: sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", inputs.getInput_atIndex(0).ToString())); sb.Append(" ADD " + inputs.getInput_atIndex(1).ToString() + " "); break; case BasicLogic.OR: sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", inputs.getInput_atIndex(0).ToString())); sb.Append(" OR " + inputs.getInput_atIndex(1).ToString() + " "); break; default: break; } } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(""); if (inputs.getInput_atIndex(1) == null) { sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "}", "SELECT *")); } else { sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "}", "SELECT " + inputs.getInput_atIndex(1).ToString())); } if (inputs.getInput_atIndex(0) == null) { sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", "FROM error:NoT")); } else { sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", "FROM " + inputs.getInput_atIndex(0).ToString())); } if (inputs.getInput_atIndex(2) != null) { sb.AppendLine(); sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", inputs.getInput_atIndex(2).ToString())); } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null || inputs.getInput_atIndex(1) == null) { sb.Append(""); } else { switch (logicType) { case BasicLogic.AND: sb.AppendLine(inputs.getInput_atIndex(0).ToString()); sb.AppendLine(TabTool.TabCount() + " ADD " + inputs.getInput_atIndex(1).ToString() + " "); break; case BasicLogic.OR: sb.AppendLine(inputs.getInput_atIndex(0).ToString()); sb.AppendLine(TabTool.TabCount() + " OR " + inputs.getInput_atIndex(1).ToString() + " "); break; default: break; } } return(sb.ToString()); }
public SqlFormatVisitor(ConfigEntity entity) { ResultSql = string.Empty; _entity = entity; _tabTool = new TabTool(); _Indents.Push(string.Empty); _LeftIndentSize.Push(0); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", "WHERE ")); if (inputs.getInput_atIndex(0) != null) { if (inputs.getInput_atIndex(0).output_dataType == VidData_Type.DATABASE_COL) { sb.Append(inputs.getInput_atIndex(0).ToString()); if (inFlag) { sb.Append(" IN \n"); } else if (likeFlag) { sb.Append(" LIKE \n"); } } else { sb.Append("( \n"); TabTool.tabindex++; sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", inputs.getInput_atIndex(0).ToString())); TabTool.tabindex--; sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", ") \n")); } } else { if (isEXISTS) { sb.AppendLine("EXISTS"); } else { sb.AppendLine("NOT EXISTS"); } } if (inputs.getInput_atIndex(1) != null) { sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "}", "(")); TabTool.tabindex++; sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "}", inputs.getInput_atIndex(1).ToString())); TabTool.tabindex--; sb.Append(string.Format("{0," + TabTool.numberOfSpaces() + "}", ")")); } return(sb.ToString()); }
// Use this for initialization void Start() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 3; i++) { sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "}", "public void Bob()")); TabTool.tabindex++; sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "} {1,10}", ":1", ":2")); for (int x = 0; x < 3; x++) { sb.AppendLine(string.Format("{0," + TabTool.numberOfSpaces() + "} {1,10}", ":1", ":2")); } TabTool.tabindex--; } t.text = sb.ToString(); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null) { sb.AppendLine("DELETE FROM error::NoTable "); } else { sb.AppendLine("DELETE FROM " + inputs.getInput_atIndex(0).ToString() + " "); } if (inputs.getInput_atIndex(1) != null) { sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); } sb.Append(";"); return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("WHERE "); if (inputs.getInput_atIndex(0) != null) { sb.AppendLine("("); TabTool.incromentCount(); sb.Append(TabTool.TabCount() + inputs.getInput_atIndex(0).ToString()); TabTool.deccromentCount(); sb.AppendLine(TabTool.TabCount() + ")"); } if (inputs.getInput_atIndex(1) != null) { TabTool.incromentCount(); sb.Append(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); TabTool.deccromentCount(); } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (inputs.getInput_atIndex(0) == null) { sb.Append("INSERT INTO error::NoTable SET "); } else { sb.AppendLine("INSERT INTO " + inputs.getInput_atIndex(0).ToString() + " VALUES"); } if (inputs.getInput_atIndex(1) != null) { sb.AppendLine("("); TabTool.incromentCount(); sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); TabTool.deccromentCount(); sb.AppendLine(")"); } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); Vid_Object obj = inputs.getInput_atIndex(0); if (obj == null || inputs.getInput_atIndex(1) == null) { sb.Append(""); } else { switch (conditionType) { case WhereStatment_Type.LESS: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" < " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.LESS_EQU: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" <= " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.GREATER: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" > " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.GREATER_EQU: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" >= " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.EQU: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" = " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.NOT_EQU: sb.Append(" " + inputs.getInput_atIndex(0).ToString()); sb.Append(" <> " + inputs.getInput_atIndex(1).ToString() + " "); break; case WhereStatment_Type.IN: sb.Append(inputs.getInput_atIndex(0).ToString()); sb.Append(" IN "); sb.AppendLine(TabTool.TabCount() + "("); TabTool.incromentCount(); sb.AppendLine(TabTool.TabCount() + inputs.getInput_atIndex(1).ToString()); TabTool.deccromentCount(); sb.AppendLine(TabTool.TabCount() + ")"); break; case WhereStatment_Type.EXISTS: if (obj.output_dataType != VidData_Type.DATABASE_COL) { sb.AppendLine("EXISTS"); sb.Append("( " + inputs.getInput_atIndex(1).ToString() + " )"); } break; case WhereStatment_Type.NOT_EXISTS: if (obj.output_dataType != VidData_Type.DATABASE_COL) { sb.AppendLine("NOT EXISTS"); sb.Append("( " + inputs.getInput_atIndex(1).ToString() + " )"); } break; case WhereStatment_Type.LIKE: sb.Append(inputs.getInput_atIndex(0).ToString()); sb.Append(" LIKE"); sb.AppendLine(" " + inputs.getInput_atIndex(1).ToString() + " "); break; default: break; } } return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); Vid_DB_Col col = (Vid_DB_Col)inputs.getInput_atIndex(0); if (col != null) { switch (col.type) { case MySql_colTypes.MYSQL_INT: sb.Append(TabTool.TabCount() + col.ToString() + " int "); if (notNull) { sb.Append("NOT NULL "); } if (defaultValue) { sb.Append("DEFAULT "); if (inputs.getInput_atIndex(1) != null) { sb.Append(inputs.getInput_atIndex(1).ToString()); } } else if (doAutoIncrement) { sb.Append("AUTO_INCREMENT "); } break; case MySql_colTypes.MYSQL_FLOAT: sb.Append(TabTool.TabCount() + col.ToString() + " float "); if (notNull) { sb.Append("NOT NULL "); } if (defaultValue) { sb.Append("DEFAULT "); if (inputs.getInput_atIndex(1) != null) { sb.Append(inputs.getInput_atIndex(1).ToString()); } } else if (doAutoIncrement) { sb.Append("AUTO_INCREMENT "); } break; case MySql_colTypes.MYSQL_DOUBLE: sb.Append(TabTool.TabCount() + col.ToString() + " double "); if (notNull) { sb.Append("NOT NULL "); } if (defaultValue) { sb.Append("DEFAULT "); if (inputs.getInput_atIndex(1) != null) { sb.Append(inputs.getInput_atIndex(1).ToString()); } } else if (doAutoIncrement) { sb.Append("AUTO_INCREMENT "); } break; case MySql_colTypes.MYSQL_VARCHAR: sb.Append(TabTool.TabCount() + col.ToString() + " varchar(255) "); if (notNull) { sb.Append("NOT NULL "); } if (defaultValue) { sb.Append("DEFAULT "); } break; case MySql_colTypes.MYSQL_BLOB: sb.Append(TabTool.TabCount() + col.ToString() + " BLOB "); break; case MySql_colTypes.MYSQL_TIMESTAMP: sb.Append(TabTool.TabCount() + col.ToString() + " timestamp "); break; } } return(sb.ToString()); }