示例#1
0
        public string SqlText(BuilkInsert bulkInsertCommand)
        {
            System.Text.StringBuilder Res = null;

            int Line = 0;

            foreach (Insert Cmd in bulkInsertCommand.InsertCommands)
            {
                if (Line == 0)
                {
                    Res = new System.Text.StringBuilder();
                    Res.Append(this.SqlText(Cmd));
                }
                else
                {
                    Res.AppendLine(", ");
                    Res.Append(this.SqlText(Cmd.ColumnValues, ColumnValueFormatStyles.InsertStyleValuesOnly, false, Line));
                }
                ++Line;
            }

            if (bulkInsertCommand.WhereClause != null)
            {
                Res.Append(" WHERE " + this.SqlText(bulkInsertCommand.WhereClause));
            }

            if (Res == null)
            {
                return("");
            }
            else
            {
                return(Res.ToString());
            }
        }
示例#2
0
        public string SqlText(BuilkInsert insertCommand)
        {
            System.Text.StringBuilder Res = null;

            foreach (Insert Cmd in insertCommand.InsertCommands)
            {
                if (Res == null)
                {
                    Res = new System.Text.StringBuilder();
                    Res.AppendLine(this.SqlText(Cmd));
                }
                else
                {
                    Res.Append(", ");
                    Res.AppendLine(this.SqlText(Cmd, true));
                }
            }
            if (Res == null)
            {
                return("");
            }
            else
            {
                return(Res.ToString());
            }
        }
示例#3
0
 public override string ToString()
 {
     System.Text.StringBuilder Res = null;
     foreach (Insert Cmd in this.InsertCommands)
     {
         if (Res == null)
         {
             Res = new System.Text.StringBuilder();
             Res.AppendLine(Cmd.ToString());
         }
         else
         {
             Res.Append(", ");
             Res.AppendLine(Cmd.ToString(true));
         }
     }
     if (Res == null)
     {
         return("");
     }
     else
     {
         return(Res.ToString());
     }
 }
示例#4
0
        private void OutputStruct(Definition.StructDef ss)
        {
            Summary(ss.Summary);
            WriteLine("{1} class {0}", ss.Name, GetAccessLevel(ss.AccessLevel));
            WriteLine("{{");

            IndentDepth++;

            Res.Append(ss.UserCode);

            foreach (var f in ss.Fields)
            {
                OutputField(f);
            }

            foreach (var p in ss.Properties)
            {
                OutputProperty(p);
            }

            foreach (var m in ss.Methods)
            {
                OutputMethod(m);
            }

            // デフォルトコンストラクタ
            {
                var name        = ss.Name;
                var constructor = "public " + name + "() {{}}";
                WriteLine(constructor);
            }

            if (ss.Constructors != null)
            {
                foreach (var c in ss.Constructors)
                {
                    OutputConstructor(ss.Name, c);
                }
            }

            if (ss.Destructors != null)
            {
                foreach (var d in ss.Destructors)
                {
                    WriteLine("@Override");
                    WriteLine("protected void finalize() throws Throwable {{");
                    IndentDepth++;
                    if (ss.BaseTypes != null && ss.BaseTypes.Count > 0)
                    {
                        WriteLine("try {{ super.finalize(); }} finally {{");
                        IndentDepth++;
                    }
                    foreach (var s in d.Body)
                    {
                        OutputStatement(s);
                    }
                    if (ss.BaseTypes != null)
                    {
                        IndentDepth--;
                        WriteLine("}}");
                    }
                    IndentDepth--;
                    WriteLine("}}");
                }
            }

            IndentDepth--;
            WriteLine("}}");
        }
示例#5
0
        private void OutputEnum(Definition.EnumDef es)
        {
            Summary(es.Summary);
            WriteLine("public enum {0} {{", es.Name);
            IndentDepth++;

            int count = 0;

            foreach (var e in es.Members)
            {
                Summary(e.Summary);
                MakeIndent();
                Res.Append(e.Name);
                if (e.Value != null)
                {
                    var expression = GetExpression(e.Value);
                    var suffix     = string.Empty;
                    if (expression.Contains("swig"))
                    {
                        suffix = ".swigValue()";
                    }

                    if (count != es.Members.Count - 1)
                    {
                        Res.AppendFormat("({0}{1}),\r\n", expression, suffix);
                    }
                    else
                    {
                        Res.AppendFormat("({0}{1});\r\n", expression, suffix);
                    }
                }
                else
                {
                    Res.AppendLine(",");
                }

                count++;
            }

            // 定型文
            var idText = @"
	private final int id;
	
	private {0}(final int id)
	{
		this.id = id;
	}
	
	public int swigValue()
	{
		return id;
	}
	
	public static {0} swigToEnum(int id)
	{
		for ({0} e : values() )
		{
			if (e.swigValue() == id)
			{
				return e;
			}
		}
	
		throw new IllegalArgumentException(""Not found : "" + id);
	}
";

            idText = idText.Replace("{0}", es.Name);

            Res.AppendLine("");
            Res.Append(idText);
            Res.AppendLine("");

            IndentDepth--;
            WriteLine("}}");
        }
示例#6
0
        private void OutputClass(Definition.ClassDef cs)
        {
            Summary(cs.Summary);
            MakeIndent();

            List <Definition.TypeSpecifier> bases      = new List <Definition.TypeSpecifier>();
            List <Definition.TypeSpecifier> interfaces = new List <Definition.TypeSpecifier>();

            foreach (var b in cs.BaseTypes)
            {
                var simple = b as Definition.SimpleType;
                var gene   = b as Definition.GenericType;

                if (simple != null)
                {
                    if (simple.TypeKind == Definition.SimpleTypeKind.Interface || simple.TypeKind == Definition.SimpleTypeKind.Other)
                    {
                        interfaces.Add(b);
                    }
                    else
                    {
                        bases.Add(b);
                    }
                }
                else if (gene != null)
                {
                    if (gene.OuterType.TypeKind == Definition.SimpleTypeKind.Interface || gene.OuterType.TypeKind == Definition.SimpleTypeKind.Other)
                    {
                        interfaces.Add(b);
                    }
                    else
                    {
                        bases.Add(b);
                    }
                }
            }

            Func <string> extends = () =>
            {
                if (bases.Count == 0)
                {
                    return(string.Empty);
                }
                return("extends " + string.Join(",", GetTypeSpecifier(bases[0])));
            };

            Func <string> implements = () =>
            {
                if (interfaces.Count == 0)
                {
                    return(string.Empty);
                }
                return("implements " + string.Join(",", interfaces.Select(_ => GetTypeSpecifier(_))));
            };

            Func <string> generics = () =>
            {
                return(GetGenericsTypeParameters(cs.TypeParameters));
            };

            List <string> strs_1 = new List <string>();

            strs_1.Add(GetAccessLevel(cs.AccessLevel));
            strs_1.Add(cs.IsAbstract ? "abstract" : "");
            strs_1.Add("class");
            strs_1.Add(cs.Name);

            List <string> strs_2 = new List <string>();

            strs_2.Add(string.Join(" ", strs_1.Where(_ => !string.IsNullOrEmpty(_)).ToArray()) + generics());
            strs_2.Add(extends());
            strs_2.Add(implements());

            var strs_2_ = string.Join(" ", strs_2.Where(_ => !string.IsNullOrEmpty(_)).ToArray());

            WriteLine(strs_2_);
            WriteLine("{{");

            IndentDepth++;

            Res.Append(cs.UserCode);

            foreach (var f in cs.Fields)
            {
                OutputField(f);
            }

            foreach (var p in cs.Properties)
            {
                OutputProperty(p);
            }

            foreach (var m in cs.Methods)
            {
                OutputMethod(m);
            }

            if (cs.Constructors != null)
            {
                foreach (var c in cs.Constructors)
                {
                    OutputConstructor(cs.Name, c);
                }
            }

            if (cs.Destructors != null)
            {
                foreach (var d in cs.Destructors)
                {
                    WriteLine("@Override");
                    WriteLine("protected void finalize() throws Throwable {{");
                    IndentDepth++;
                    if (cs.BaseTypes != null && cs.BaseTypes.Count > 0)
                    {
                        WriteLine("try {{ super.finalize(); }} finally {{");
                        IndentDepth++;
                    }
                    foreach (var s in d.Body)
                    {
                        OutputStatement(s);
                    }

                    if (cs.BaseTypes != null)
                    {
                        IndentDepth--;
                        WriteLine("}}");
                    }

                    IndentDepth--;
                    WriteLine("}}");
                }
            }

            IndentDepth--;
            WriteLine("}}");
        }