//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : cStructHandlerCreater.pkg // $ProjectName : The Hammer 2.0 // $Authors : Wil van Antwerpen, Michael Kurz, Sergey V. Natarov, Bernhard Ponemayr // $Created : 01.25.2014 01:08 // $Type : LGPL // // Contents: // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd Class cStructHandlerCreater Is a Array //Insert your Properties here. Procedure Construct_Object Forward Send Construct_Object Object oSrcLineParser Is a cSrcLineParser End_Object // Name of the type Property String psName Public "" End_Procedure // Add a Line to the Converter. Procedure AddItem String sLine Set value Item (Item_Count(Self)) To sLine End_Procedure // A little helper for formatting purposes. Function PadEx String sStr Returns String Integer iL Move 60 To iL If (Length(sStr)) Gt iL Function_Return sStr Else Function_Return (Pad(sStr,iL)) End_Function // Creates the code and returns it. Function CreateCode Returns String Integer iC hoID iField iInType String sLine sCR sTab sTab2 String sConstants sPut sGet sVar String sProcTo sProcFrom sRet sCls Append sCR (Character(13)) (Character(10)) Append sTab " " Append sTab2 sTab sTab Move (oSrcLineParser(Self)) To hoID Move 0 To iField For iC From 0 To (Item_Count(Self)-1) Get value Item iC To sLine // Get the value of the Line Move (LTrim(sLine)) To sLine // Trim it Send ParseLine To hoID sLine // Parses the line. If (Uppercase(Value(hoID,0))) Eq "END_TYPE" Move 0 To iInType If iInType If (Uppercase(Value(hoID,0))) Eq "FIELD" Begin // 1st create a constant If sConstants Eq "" Append sConstants sTab "/" "/ Constants for Handling the " (psName(Self)) " type" sCR Append sConstants "Define C_" (PadEx(Self,Value(hoID,1))) " for " iField sCR Move "Put" To sPut Move "GetBuff" To sGet If (Uppercase(Value(hoID,3))) Eq "CHAR" Begin Move "Put_String" To sPut Move "GetBuff_String" To sGet End Move "s" To sVar Append sVar (psName(Self)) // 2nd add a entry to the sProcTo If sProcTo Eq "" Begin Append sProcTo sTab2 "/" "/ Shall fill the values of a " (psName(Self)) " into an Array" sCR Append sProcTo sTab "Procedure " (psName(Self)) "ToArray integer hoArray" sCR Append sProcTo sTab2 "Local String sTmp" sCR Append sProcTo sTab2 "Local String " sVar sCR sCR Append sProcTo sTab2 "/" "/ Fill " sVar " here..." sCR sCR End Append sProcTo (PadEx(Self,(sTab2+sGet+" from "+sVar+" at "+Value(hoID,1)))+" to sTmp"+sCR) Append sProcTo (PadEx(Self,(sTab2+ "Set Value of hoArray item "+String(iField)))+" to sTmp"+sCR) // 3d add an entry tp the sProcFrom If sProcFrom Eq "" Begin Append sProcFrom sTab2 "/" "/ Shall fill a " (psName(Self)) "string with the values from an Array" sCR Append sProcFrom sTab "Procedure " (psName(Self)) "FromArray integer hoArray" sCR Append sProcFrom sTab2 "Local String " sVar sCR sCR Append sProcFrom sTab2 "Zerotype " (psName(Self)) " to " sVar sCR End Append sProcFrom sTab2 sPut " (Value(hoArray," iField ")) to " sVar " at " (PadEx(Self,Value(hoID,1))) sCR Increment iField End If (Uppercase(Value(hoID,0))) Eq "TYPE" Begin Set psName To (Value(hoID,1)) Move 1 To iInType End End Append sCls "Class c" (psName(Self)) "Handler is a cTypeHandler" sCR Append sCls sTab2 "/" "/ Adding Properties here..." sCR Append sCls sTab "Procedure Construct_Object" sCR Append sCls sTab2 "Forward send Construct_Object" sCR sCR Append sCls sTab2 "/" "/Property String ps" (psName(Self)) " Public " (Character(34)) (Character(34)) sCR Append sCls sTab2 "Set piFieldCount to " iField sCR Append sCls sTab "End_Procedure" sCR If sProcTo Ne "" Append sProcTo sTab "End_Procedure" sCR If sProcFrom Ne "" Begin Append sProcFrom sCR sTab2 "/" "/ Use " sVar " here..." sCR sCR Append sProcFrom sTab "End_Procedure" sCR End Append sRet sConstants sCR sCls sProcTo sProcFrom "End_Class" sCR Function_Return sRet End_Function //Finish object construction Procedure End_Construct_Object Forward Send End_Construct_Object End_Procedure // Add a Line to the Converter. Procedure AddItem String sLine Set value Item (Item_Count(Self)) To sLine End_Procedure End_Class