📄 dtclass.hhf
字号:
#if( ! @defined( dtClass_hhf ))?dtClass_hhf := true;#includeOnce( "hla.hhf" )#includeOnce( "datetime.hhf" )namespace dtClass; // The following macro allows us to turn a class function // into either a method or a procedure based on the // presence of "funcName" within a list of method names // passed to the class generating macro. #macro function( funcName ); #if( @index( methods, 0, @string:funcName) = -1 ) procedure funcName #else method funcName #endif #endmacro type // make_timeClass - // // This macro is used to create a base time class. // The first parameter is the name of the class to create. // The second parameter is a string listing the 'function' // names that you want converted to a class method (if not // present, it will be a class procedure). #macro make_timeClass( className, methods ); className: class var theTime :time.timerec; timeFmt :time.OutputFormat; procedure create; @external( @uppercase( @string( className ), 0) + "_CREATE" ); dtClass.function( curTime ); @external( "TIMECLASS_CURTIME" ); dtClass.function( utcTime ); @external( "TIMECLASS_UTCTIME" ); dtClass.function( addSecs )( seconds:uns32 ); @external( "TIMECLASS_ADDSECS" ); dtClass.function( addMins )( minutes:uns32 ); @external( "TIMECLASS_ADDMINS" ); dtClass.function( addHours )( hours:uns32 ); @external( "TIMECLASS_ADDHOURS" ); dtClass.function( subSecs )( seconds:uns32 ); @external( "TIMECLASS_SUBSECS" ); dtClass.function( subMins )( minutes:uns32 ); @external( "TIMECLASS_SUBMINS" ); dtClass.function( subHours )( hours:uns32 ); @external( "TIMECLASS_SUBHOURS" ); dtClass.function( fromSecs )( seconds:uns32 ); @external( "TIMECLASS_FROMSECS" ); dtClass.function( toSecs ); @returns( "eax" ); @external( "TIMECLASS_TOSECS" ); dtClass.function( isValid ); @returns( "al" ); @external( "TIMECLASS_ISVALID" ); dtClass.function( validate ); @external( "TIMECLASS_VALIDATE" ); dtClass.function( difference )( var time2:className ); @returns( "eax" ); @external( "TIMECLASS_DIFFERENCE" ); dtClass.function( secsBetweenTimes )( time2:time.timerec ); @returns( "eax" ); @external( "TIMECLASS_SECSBETWEENTIMES" ); dtClass.function( toString )( dest:string ); @external( "TIMECLASS_TOSTRING" ); dtClass.function( a_toString ); @external( "TIMECLASS_A_TOSTRING" ); endclass; #endmacro #macro make_dateClass( className, methods ); className: class var theDate: date.daterec; OutFmt: date.OutputFormat; Separator: char; procedure create; @external( @uppercase( @string( className ), 0) + "_CREATE" ); dtClass.function( today ); @external( "DATECLASS_TODAY"); dtClass.function( utc ); @external( "DATECLASS_UTC"); dtClass.function( isLeapYear ); @returns( "al" ); @external( "DATECLASS_ISLEAPYEAR"); dtClass.function( isValid ); @returns( "al" ); @external( "DATECLASS_ISVALID"); dtClass.function( validate ); @returns( "al" ); @external( "DATECLASS_VALIDATE"); dtClass.function( a_toString ); @returns( "eax" ); @external( "DATECLASS_A_TOSTRING"); dtClass.function( toString )( dest:string ); @external( "DATECLASS_TOSTRING"); dtClass.function( setSeparator )( c:char ); @external( "DATECLASS_SETSEPARATOR"); dtClass.function( setFormat )( f:date.OutputFormat ); @external( "DATECLASS_SETFORMAT"); dtClass.function( addDays )( days:uns32 ); @external( "DATECLASS_ADDDAYS"); dtClass.function( subDays )( days:uns32 ); @external( "DATECLASS_SUBDAYS"); dtClass.function( addMonths )( months:uns32 ); @external( "DATECLASS_ADDMONTHS"); dtClass.function( subMonths )( days:uns32 ); @external( "DATECLASS_SUBMONTHS"); dtClass.function( addYears )( years:uns32 ); @external( "DATECLASS_ADDYEARS"); dtClass.function( subYears )( days:uns32 ); @external( "DATECLASS_SUBYEARS"); dtClass.function( fromJulian )( Julian:uns32 ); @external( "DATECLASS_FROMJULIAN"); dtClass.function( toJulian ); @returns( "eax" ); @external( "DATECLASS_TOJULIAN"); dtClass.function( dayOfWeek ); @returns( "eax" ); @external( "DATECLASS_DAYOFWEEK"); dtClass.function( dayNumber ); @returns( "eax" ); @external( "DATECLASS_DAYNUMBER"); dtClass.function( daysLeft ); @returns( "eax" ); @external( "DATECLASS_DAYSLEFT"); dtClass.function( daysBetween ) ( otherDate:date.daterec ); @returns( "eax" ); @external( "DATECLASS_DAYSBETWEEN"); dtClass.function( difference ) ( var otherDate:className in eax ); @returns( "eax" ); @external( "DATECLASS_DIFFERENCE"); endclass #endmacro end dtClass;// Deprecated types:const dateClass :text := "dateClass_t"; timeClass :text := "timeClass_t"; virtualDateClass :text := "virtualDateClass_t"; virtualTimeClass :text := "virtualTimeClass_t"; type // Create the standard date class with all // functions being procedures: dtClass.make_dateClass( dateClass_t, " " ); // Create a dateClass with all the functions // being methods: dtClass.make_dateClass ( virtualDateClass_t, "today" "isLeapYear" "isValid" "a_toString" "toString" "setSeparator" "setFormat" "addDays" "subDays" "addMonths" "subMonths" "addYears" "subYears" "fromJulian" "toJulian" "dayOfWeek" "dayNumber" "daysLeft" "daysBetween" "difference" ); // Create the standard time class with all functions // being static class procedures: dtClass.make_timeClass( timeClass_t, "" ); // Create a timeClass with all virtual methods: dtClass.make_timeClass ( virtualTimeClass_t, "curTime " "utcTime " "addSecs " "addMins " "addHours " "subSecs " "subMins " "subHours " "fromSecs " "toSecs " "isValid " "validate " "difference " "secsBetweenTimes " "toString " "a_toString " ); #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -