/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("using System;\r\nusing System.IO;\r\n\r\nnamespace "); #line 9 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.Namespace))); #line default #line hidden this.Write("\r\n{\r\n public static partial class GameServer\r\n {\r\n private static "); #line 13 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameState))); #line default #line hidden this.Write(" ReadTurn()\r\n {\r\n Console.WriteLine(\"EOT\");\r\n string" + " line = Console.ReadLine();\r\n if (line.StartsWith(\"EOT\"))\r\n " + " return null;\r\n Parser parser = new Parser(line);\r\n "); #line 20 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameState))); #line default #line hidden this.Write(" turn = new "); #line 20 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameState))); #line default #line hidden this.Write("();\r\n parser.Deserialize(turn);\r\n return turn;\r\n }\r\n" + " \r\n private static Tuple<"); #line 25 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write(", "); #line 25 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.PlayerSetup))); #line default #line hidden this.Write(@"> ReadSetup() { string line = Console.ReadLine(); Parser parser = new Parser(line); int playerId = parser.ReadNextInt(); line = Console.ReadLine(); parser = new Parser(line); "); #line 32 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write(" data = new "); #line 32 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write("();\r\n parser.Deserialize(data);\r\n return Tuple.Create(data," + " data.Player[playerId]);\r\n }\r\n\r\n private class Parser\r\n {\r\n" + " private string Line;\r\n private int Index = 0;\r\n\r\n " + " public Parser(string line)\r\n {\r\n Line = line;\r\n " + " }\r\n\r\n public long ReadNextLong()\r\n {\r\n " + " long data = 0;\r\n bool negative = false;\r\n if " + "(Index < Line.Length && Line[Index] == \'-\')\r\n {\r\n " + " negative = true;\r\n ++Index;\r\n }\r\n\r\n " + " while (Index < Line.Length && Line[Index] >= \'0\' && Line[Index] <= \'9\')" + "\r\n {\r\n data *= 10;\r\n data +" + "= (long)(Line[Index] - \'0\');\r\n ++Index;\r\n }\r\n " + " ++Index;\r\n return negative ? -data : data;\r\n " + " }\r\n \r\n public ulong ReadNextUlong()\r\n {\r\n" + " ulong data = 0;\r\n\r\n while (Index < Line.Length &&" + " Line[Index] >= \'0\' && Line[Index] <= \'9\')\r\n {\r\n " + " data *= 10;\r\n data += (ulong)(Line[Index] - \'0\');\r\n " + " ++Index;\r\n }\r\n ++Index;\r\n " + " return data;\r\n }\r\n \r\n public int ReadNextIn" + "t()\r\n {\r\n return (int)ReadNextLong();\r\n }\r\n" + " \r\n public short ReadNextShort()\r\n {\r\n " + " return (short)ReadNextLong();\r\n }\r\n \r\n p" + "ublic sbyte ReadNextSbyte()\r\n {\r\n return (sbyte)ReadNe" + "xtLong();\r\n }\r\n \r\n public uint ReadNextUint()\r\n" + " {\r\n return (uint)ReadNextUlong();\r\n }\r\n " + " \r\n public ushort ReadNextUshort()\r\n {\r\n " + " return (ushort)ReadNextUlong();\r\n }\r\n \r\n " + "public byte ReadNextByte()\r\n {\r\n return (byte)ReadNext" + "Ulong();\r\n }\r\n \r\n public char ReadNextChar()\r\n " + " {\r\n return (char)ReadNextUlong();\r\n }\r\n " + " \r\n public bool ReadNextBool()\r\n {\r\n " + " return ReadNextLong() != 0;\r\n }"); #line 119 "D:\ugly\CodeGenerator\cs\CsImpl.tt" foreach (GameClass c in CsHelper.Definition.Class.Values) { #line default #line hidden this.Write("\r\n\r\n public void Deserialize("); #line 126 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write(" data)\r\n {"); #line 127 "D:\ugly\CodeGenerator\cs\CsImpl.tt" foreach (ClassMember m in c.Member) { #line default #line hidden this.Write("\r\n {"); #line 133 "D:\ugly\CodeGenerator\cs\CsImpl.tt" BasicType type = CsHelper.Definition.GetBasicType(m.Type); if (m.Array == 0) { if (type.IsBasic()) { #line default #line hidden this.Write("\r\n data."); #line 142 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write(" = ReadNext"); #line 142 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.GetBasicTypeName(type)))); #line default #line hidden this.Write("();"); #line 142 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } else if (type == BasicType.Class) { #line default #line hidden this.Write("\r\n Deserialize(data."); #line 148 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write(");"); #line 148 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } else // Enum { #line default #line hidden this.Write("\r\n data."); #line 154 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write(" = ("); #line 154 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden this.Write(")ReadNextInt();"); #line 154 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } } else { for (int i = 0; i < m.Array; ++i) { #line default #line hidden this.Write("\r\n int size"); #line 163 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write(" = ReadNextInt();"); #line 163 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("\r\n data."); #line 166 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write(" = new "); #line 166 "D:\ugly\CodeGenerator\cs\CsImpl.tt" if (type.IsBasic()) { #line default #line hidden #line 169 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CsHelper.GetBasicTypeName(type))); #line default #line hidden #line 169 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } else { #line default #line hidden #line 173 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden #line 173 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("["); #line 175 "D:\ugly\CodeGenerator\cs\CsImpl.tt" for (int i = 0; i < m.Array; ++i) { if (i != 0) { #line default #line hidden this.Write(", "); #line 180 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("size"); #line 182 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden #line 182 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("];"); #line 184 "D:\ugly\CodeGenerator\cs\CsImpl.tt" for (int i = 0; i < m.Array; ++i) { #line default #line hidden this.Write("\r\n for (int idx"); #line 190 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write(" = 0; idx"); #line 190 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write(" < size"); #line 190 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write("; ++idx"); #line 190 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden this.Write(")\r\n {"); #line 191 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.PushIndent(" "); } if (type == BasicType.Class) { #line default #line hidden this.Write("\r\n "); #line 197 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden this.Write(" element = new "); #line 197 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden this.Write("();\r\n Deserialize(element);"); #line 198 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("\r\n data."); #line 201 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write("[idx0"); #line 201 "D:\ugly\CodeGenerator\cs\CsImpl.tt" for (int i = 1; i < m.Array; ++i) { #line default #line hidden this.Write(", idx"); #line 204 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(i)); #line default #line hidden #line 204 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("] = "); #line 206 "D:\ugly\CodeGenerator\cs\CsImpl.tt" if (type == BasicType.Class) { #line default #line hidden this.Write("element"); #line 209 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } else { #line default #line hidden this.Write("ReadNext"); #line 213 "D:\ugly\CodeGenerator\cs\CsImpl.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.GetBasicTypeName(type)))); #line default #line hidden this.Write("()"); #line 213 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write(";"); #line 215 "D:\ugly\CodeGenerator\cs\CsImpl.tt" for (int i = 0; i < m.Array; ++i) { this.PopIndent(); #line default #line hidden this.Write("\r\n }"); #line 222 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } } #line default #line hidden this.Write("\r\n }"); #line 227 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write(" \r\n }"); #line 232 "D:\ugly\CodeGenerator\cs\CsImpl.tt" } #line default #line hidden this.Write("\r\n }\r\n }\r\n}"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("#pragma once\r\n#include <vector>\r\n#include <cstdint>"); #line 8 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" foreach (string d in CxxHelper.CurrentFile.Dependency) { #line default #line hidden this.Write("\r\n#include \""); #line 13 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(d))); #line default #line hidden this.Write(".h\""); #line 13 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } if (CxxHelper.Server) { #line default #line hidden this.Write("\r\n\r\nnamespace ugly\r\n{"); #line 21 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.PushIndent(" "); } #line default #line hidden this.Write("\r\nnamespace "); #line 26 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.Namespace))); #line default #line hidden this.Write("\r\n{"); #line 27 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" foreach (GameEnum e in CxxHelper.CurrentFile.Enum) { #line default #line hidden this.Write("\r\n \r\n enum class "); #line 33 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(e.Name))); #line default #line hidden this.Write("\r\n {"); #line 34 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" foreach (KeyValuePair <string, int> kvp in e.Value) { #line default #line hidden this.Write(" \r\n "); #line 39 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(kvp.Key))); #line default #line hidden this.Write(" = "); #line 39 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Value)); #line default #line hidden this.Write(","); #line 39 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write("\r\n };"); #line 43 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } foreach (GameClass c in CxxHelper.CurrentFile.Class) { #line default #line hidden this.Write("\r\n\r\n struct "); #line 51 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("\r\n {"); #line 52 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" foreach (ClassMember m in c.Member) { #line default #line hidden this.Write("\r\n "); #line 57 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" for (int i = 0; i < m.Array; ++i) { #line default #line hidden this.Write("std::vector<"); #line 60 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } BasicType type = CxxHelper.Definition.GetBasicType(m.Type); if (type.IsBasic()) { #line default #line hidden #line 65 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CxxHelper.GetBasicTypeName(type))); #line default #line hidden #line 65 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } else { #line default #line hidden #line 69 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden #line 69 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } for (int i = 0; i < m.Array; ++i) { #line default #line hidden this.Write(">"); #line 73 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write(" "); #line 75 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(m.Name))); #line default #line hidden this.Write(";"); #line 75 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write("\r\n\r\n "); #line 80 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("();\r\n "); #line 81 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" foreach (ClassMethod m in c.Method) { if (CxxHelper.Server) { #line default #line hidden this.Write("\r\n bool"); #line 88 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } else { #line default #line hidden this.Write("\r\n void"); #line 94 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write(" "); #line 96 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write("("); #line 96 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" if (CxxHelper.Server) { #line default #line hidden this.Write("struct "); #line 99 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write("& gameSetup, struct "); #line 99 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerSetup))); #line default #line hidden this.Write("& playerSetup, struct "); #line 99 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameState))); #line default #line hidden this.Write("& gameState, struct "); #line 99 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerState))); #line default #line hidden this.Write("& playerState, "); #line 99 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } for (int idxParam = 0; idxParam < m.Param.Count; ++idxParam) { MethodParam a = m.Param[idxParam]; BasicType type = CxxHelper.Definition.GetBasicType(a.Type); if (idxParam != 0) { #line default #line hidden this.Write(", "); #line 107 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } if (type == BasicType.Class) { #line default #line hidden this.Write("const "); #line 111 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } if (type.IsBasic()) { #line default #line hidden #line 115 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CxxHelper.GetBasicTypeName(type))); #line default #line hidden #line 115 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } else { #line default #line hidden #line 119 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(a.Type))); #line default #line hidden #line 119 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } if (type == BasicType.Class) { #line default #line hidden this.Write("&"); #line 123 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write(" "); #line 125 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 125 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write(");"); #line 127 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } if (CxxHelper.Server) { if (c.ConditionMethod.Any()) { #line default #line hidden this.Write("\r\n"); #line 135 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } foreach (string m in c.ConditionMethod) { #line default #line hidden this.Write("\r\n bool "); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m))); #line default #line hidden this.Write("(struct "); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write("& gameSetup, struct "); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerSetup))); #line default #line hidden this.Write("& playerSetup, struct "); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameState))); #line default #line hidden this.Write("& gameState, struct "); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerState))); #line default #line hidden this.Write("& playerState);"); #line 141 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } } #line default #line hidden this.Write("\r\n };"); #line 146 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden this.Write("\r\n}"); #line 150 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" if (CxxHelper.Server) { this.PopIndent(); #line default #line hidden this.Write("\r\n}"); #line 156 "D:\ugly\CodeGenerator\cxx\CxxHeader.tt" } #line default #line hidden return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("#include \""); #line 6 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.CurrentFile.Name))); #line default #line hidden this.Write(".h\"\r\n#include <cstdio>"); #line 7 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (CxxHelper.Server) { #line default #line hidden this.Write("\r\n\r\nnamespace ugly\r\n{"); #line 14 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.PushIndent(" "); } #line default #line hidden this.Write("\r\nnamespace "); #line 19 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.Namespace))); #line default #line hidden this.Write("\r\n{"); #line 20 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" foreach (GameClass c in CxxHelper.CurrentFile.Class) { #line default #line hidden this.Write("\r\n "); #line 25 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("::"); #line 25 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("()"); #line 25 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" for (int i = 0; i < c.Member.Count; ++i) { #line default #line hidden this.Write("\r\n "); #line 30 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (i == 0) { #line default #line hidden this.Write(":"); #line 33 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else { #line default #line hidden this.Write(","); #line 37 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write(" "); #line 39 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(c.Member[i].Name))); #line default #line hidden this.Write("()"); #line 39 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write("\r\n { }\r\n "); #line 44 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" foreach (ClassMethod m in c.Method) { #line default #line hidden this.Write("\r\n "); #line 49 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (CxxHelper.Server) { #line default #line hidden this.Write("bool"); #line 52 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else { #line default #line hidden this.Write("void"); #line 56 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write(" "); #line 58 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("::"); #line 58 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write("("); #line 58 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (CxxHelper.Server) { #line default #line hidden this.Write("struct "); #line 61 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write("& gameSetup, struct "); #line 61 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerSetup))); #line default #line hidden this.Write("& playerSetup, struct "); #line 61 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameState))); #line default #line hidden this.Write("& gameState, struct "); #line 61 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerState))); #line default #line hidden this.Write("& playerState, "); #line 61 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } for (int idxParam = 0; idxParam < m.Param.Count; ++idxParam) { MethodParam a = m.Param[idxParam]; BasicType type = CxxHelper.Definition.GetBasicType(a.Type); if (idxParam != 0) { #line default #line hidden this.Write(", "); #line 69 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } if (type == BasicType.Class) { #line default #line hidden this.Write("const "); #line 73 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } if (type.IsBasic()) { #line default #line hidden #line 77 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CxxHelper.GetBasicTypeName(type))); #line default #line hidden #line 77 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else { #line default #line hidden #line 81 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(a.Type))); #line default #line hidden #line 81 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } if (type == BasicType.Class) { #line default #line hidden this.Write("&"); #line 85 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write(" "); #line 87 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 87 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write(")\r\n {"); #line 90 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (CxxHelper.Server) { #line default #line hidden this.Write("\r\n return false;"); #line 95 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else { #line default #line hidden this.Write(" std::printf(\""); #line 100 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(m.MethodId)); #line default #line hidden #line 100 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" foreach (MethodParam a in m.Param) { BasicType type = CxxHelper.Definition.GetBasicType(a.Type); if (type == BasicType.Class) { type = CxxHelper.Definition.GetBasicType(CxxHelper.Definition.Class[a.Type].IdMember.Type); } #line default #line hidden this.Write(" %"); #line 106 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CxxHelper.GetBasicTypePrinter(type))); #line default #line hidden #line 106 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write("\\n\""); #line 108 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" foreach (MethodParam a in m.Param) { BasicType type = CxxHelper.Definition.GetBasicType(a.Type); if (type == BasicType.Class) { BasicType realType = CxxHelper.Definition.GetBasicType(CxxHelper.Definition.Class[a.Type].IdMember.Type); #line default #line hidden this.Write(", "); #line 115 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (realType == BasicType.Enum) { #line default #line hidden this.Write("(int)"); #line 118 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden #line 120 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden this.Write("."); #line 120 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(CxxHelper.Definition.Class[a.Type].IdMember.Name))); #line default #line hidden #line 120 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else if (type == BasicType.Enum) { #line default #line hidden this.Write(", (int)"); #line 124 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 124 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } else { #line default #line hidden this.Write(", "); #line 128 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 128 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } } #line default #line hidden this.Write(");"); #line 131 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden this.Write("\r\n }"); #line 134 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } if (CxxHelper.Server) { foreach (string m in c.ConditionMethod) { #line default #line hidden this.Write("\r\n\r\n bool "); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("::"); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m))); #line default #line hidden this.Write("(struct "); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameSetup))); #line default #line hidden this.Write("& gameSetup, struct "); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerSetup))); #line default #line hidden this.Write("& playerSetup, struct "); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.GameState))); #line default #line hidden this.Write("& gameState, struct "); #line 143 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CxxHelper.Definition.Config.PlayerState))); #line default #line hidden this.Write("& playerState)\r\n {\r\n return true;\r\n }"); #line 146 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } } } #line default #line hidden this.Write("\r\n}"); #line 152 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" if (CxxHelper.Server) { this.PopIndent(); #line default #line hidden this.Write("\r\n}"); #line 158 "D:\ugly\CodeGenerator\cxx\CxxCode.tt" } #line default #line hidden return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("using System;\r\n\r\nnamespace "); #line 8 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Config.Namespace))); #line default #line hidden this.Write("\r\n{"); #line 9 "D:\ugly\CodeGenerator\cs\CsHeader.tt" foreach (GameEnum e in CsHelper.CurrentFile.Enum) { #line default #line hidden this.Write("\r\n \r\n public enum "); #line 15 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(e.Name))); #line default #line hidden this.Write("\r\n {"); #line 16 "D:\ugly\CodeGenerator\cs\CsHeader.tt" foreach (KeyValuePair <string, int> kvp in e.Value) { #line default #line hidden this.Write(" \r\n "); #line 21 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(kvp.Key))); #line default #line hidden this.Write(" = "); #line 21 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(kvp.Value)); #line default #line hidden this.Write(","); #line 21 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("\r\n }"); #line 25 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } foreach (GameClass c in CsHelper.CurrentFile.Class) { #line default #line hidden this.Write("\r\n\r\n public class "); #line 33 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(c.Name))); #line default #line hidden this.Write("\r\n {"); #line 34 "D:\ugly\CodeGenerator\cs\CsHeader.tt" foreach (ClassMember m in c.Member) { #line default #line hidden this.Write("\r\n public "); #line 39 "D:\ugly\CodeGenerator\cs\CsHeader.tt" BasicType type = CsHelper.Definition.GetBasicType(m.Type); if (type.IsBasic()) { #line default #line hidden #line 43 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CsHelper.GetBasicTypeName(type))); #line default #line hidden #line 43 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } else { #line default #line hidden #line 47 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Type))); #line default #line hidden #line 47 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } if (m.Array != 0) { #line default #line hidden this.Write("["); #line 51 "D:\ugly\CodeGenerator\cs\CsHeader.tt" for (int i = 1; i < m.Array; ++i) { #line default #line hidden this.Write(","); #line 54 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("]"); #line 56 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write(" "); #line 58 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write(";"); #line 58 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("\r\n "); #line 62 "D:\ugly\CodeGenerator\cs\CsHeader.tt" foreach (ClassMethod m in c.Method) { #line default #line hidden this.Write("\r\n public void "); #line 67 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(m.Name))); #line default #line hidden this.Write("("); #line 67 "D:\ugly\CodeGenerator\cs\CsHeader.tt" for (int idxParam = 0; idxParam < m.Param.Count; ++idxParam) { MethodParam a = m.Param[idxParam]; BasicType type = CsHelper.Definition.GetBasicType(a.Type); if (idxParam != 0) { #line default #line hidden this.Write(", "); #line 74 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } if (type.IsBasic()) { #line default #line hidden #line 78 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CsHelper.GetBasicTypeName(type))); #line default #line hidden #line 78 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } else { #line default #line hidden #line 82 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(a.Type))); #line default #line hidden #line 82 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write(" "); #line 84 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 84 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write(")\r\n {\r\n Console.WriteLine(\""); #line 88 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(m.MethodId)); #line default #line hidden #line 88 "D:\ugly\CodeGenerator\cs\CsHeader.tt" for (int idxParam = 0; idxParam < m.Param.Count; ++idxParam) { #line default #line hidden this.Write(" {"); #line 91 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(idxParam)); #line default #line hidden this.Write("}"); #line 91 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("\""); #line 93 "D:\ugly\CodeGenerator\cs\CsHeader.tt" foreach (MethodParam a in m.Param) { #line default #line hidden this.Write(", "); #line 96 "D:\ugly\CodeGenerator\cs\CsHeader.tt" BasicType type = CsHelper.Definition.GetBasicType(a.Type); switch (type) { case BasicType.Bool: #line default #line hidden #line 101 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden this.Write(" ? 1 : 0"); #line 101 "D:\ugly\CodeGenerator\cs\CsHeader.tt" break; case BasicType.Char: case BasicType.Enum: #line default #line hidden this.Write("(int)"); #line 105 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 105 "D:\ugly\CodeGenerator\cs\CsHeader.tt" break; case BasicType.Class: #line default #line hidden #line 108 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden this.Write("."); #line 108 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.CamelCase.Convert(CsHelper.Definition.Class[a.Type].IdMember.Name))); #line default #line hidden #line 108 "D:\ugly\CodeGenerator\cs\CsHeader.tt" break; default: #line default #line hidden #line 111 "D:\ugly\CodeGenerator\cs\CsHeader.tt" this.Write(this.ToStringHelper.ToStringWithCulture(Case.LowerCamelCase.Convert(a.Name))); #line default #line hidden #line 111 "D:\ugly\CodeGenerator\cs\CsHeader.tt" break; } } #line default #line hidden this.Write(");\r\n }"); #line 116 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("\r\n }"); #line 120 "D:\ugly\CodeGenerator\cs\CsHeader.tt" } #line default #line hidden this.Write("\r\n}"); return(this.GenerationEnvironment.ToString()); }