+ contrib/hbgt/tests
+ contrib/hbgt/tests/test.prg
+ contrib/hbmisc/tests/rtfclass.prg
- tests/rtfclass.prg
- tests/test10.prg
- tests/testgt.prg
* tests/ac_test.prg
* tests/alias.prg
* tests/begin.prg
* tests/boxtest.prg
* tests/cdow.prg
* tests/clasinh.prg
* tests/dates.prg
* tests/dates2.prg
* tests/dates3.prg
* tests/dates4.prg
* tests/ddate.prg
* tests/debugtst.prg
* tests/delimtst.prg
* tests/devtest.prg
* tests/disptest.prg
* tests/foreach.prg
* tests/gtstdtst.prg
* tests/ipclnt.prg
* tests/ipsvr.prg
* tests/langapi.prg
* tests/memtst.prg
* tests/memvar.prg
* tests/menutest.prg
* tests/mousetst.prg
* tests/multiarg.prg
* tests/newrdd.prg
* tests/nums.prg
* tests/objarr.prg
* tests/objasign.prg
* tests/objects.prg
* tests/omacro.prg
* tests/onidle.prg
* tests/os.prg
* tests/output.prg
* tests/overload.prg
* tests/parexpr.prg
* tests/passref.prg
* tests/procline.prg
* tests/procname.prg
* tests/recursiv.prg
* tests/returns.prg
* tests/round.prg
* tests/say.prg
* tests/sbartest.prg
* tests/scroll.prg
* tests/sdf_test.prg
* tests/seconds.prg
* tests/server.prg
* tests/set_num.prg
* tests/set_test.prg
* tests/setkeys.prg
* tests/sound.prg
* tests/speed.prg
* tests/statfun.prg
* tests/statics.prg
* tests/statics1.prg
* tests/statics2.prg
* tests/statinit.prg
* tests/strdelim.prg
* tests/stripem.prg
* tests/switch.prg
* tests/symbolt.prg
* tests/t1.prg
* tests/tb1.prg
* tests/testbrdb.prg
* tests/testbrw.prg
* tests/testcdx.prg
* tests/testcls.prg
* tests/testdbf.prg
* tests/testdecl.prg
* tests/testerro.prg
* tests/testfor.prg
* tests/testget.prg
* tests/testhrb.prg
* tests/testhtml.prg
* tests/testidle.prg
* tests/testmem.prg
* tests/testpers.prg
* tests/testtok.prg
* tests/testwarn.prg
* tests/tstalias.prg
* tests/tstasort.prg
* tests/tstblock.prg
* tests/tstdbi.prg
* tests/tstmacro.prg
* tests/varparam.prg
* tests/wvt_fs.prg
* cleaning up tests
111 lines
3.1 KiB
Plaintext
111 lines
3.1 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
//
|
|
// DynObj
|
|
//
|
|
// Implementation of operator overload in Harbour
|
|
//
|
|
// Date : 1999/05/15
|
|
//
|
|
// Written by Eddie Runia <eddie@runia.com>
|
|
// www - http://harbour-project.org
|
|
//
|
|
// Jfl 2001/11/18 command mode added
|
|
//
|
|
// Placed in the public domain
|
|
//
|
|
|
|
#include "hbclass.ch"
|
|
|
|
PROCEDURE Main()
|
|
|
|
LOCAL oString := TString():New( "Hello" )
|
|
|
|
QOut( "Testing TString with Operator Overloading" )
|
|
QOut( oString:cValue )
|
|
QOut( "---" )
|
|
|
|
? ValType( oString )
|
|
|
|
QOut( "Equal........:", oString = "Hello" )
|
|
QOut( "Exactly Equal:", oString == "Hello" )
|
|
QOut( "Not Equal != :", oString != "Hello" )
|
|
QOut( "Not Equal <> :", oString <> "Hello" )
|
|
QOut( "Not Equal # :", oString # "Hello" )
|
|
QOut( "Substring $ :", oString $ "Hello" )
|
|
QOut( "Less than :", oString < "Hello" )
|
|
QOut( "Less than or Equal:", oString <= "Hello" )
|
|
QOut( "Greater than :", oString > "Hello" )
|
|
QOut( "Greater than or Equal:", oString >= "Hello" )
|
|
QOut( "Concatenation + :", oString + "Hello" )
|
|
QOut( "Concatenation - :", oString - "Hello" )
|
|
QOut( "Array index[2] :", oString[2] )
|
|
QOut( "Array index[3] := 'X' :", oString[3] := 'X' )
|
|
QOut( oString:cValue )
|
|
|
|
RETURN nil
|
|
|
|
CREATE CLASS tString
|
|
|
|
VAR cValue
|
|
|
|
METHOD New( cText ) INLINE ::cValue := cText, self
|
|
|
|
OPERATOR "=" ARG cArg INLINE ::cValue = cArg
|
|
OPERATOR "==" ARG cArg INLINE ::cValue == cArg
|
|
OPERATOR "!=" ARG cArg INLINE ::cValue != cArg
|
|
OPERATOR "<" ARG cArg INLINE ::cValue < cArg
|
|
OPERATOR "<=" ARG cArg INLINE ::cValue <= cArg
|
|
OPERATOR ">" ARG cArg INLINE ::cValue > cArg
|
|
OPERATOR ">=" ARG cArg INLINE ::cValue >= cArg
|
|
OPERATOR "+" ARG cArg INLINE ::cValue + cArg
|
|
OPERATOR "-" ARG cArg INLINE ::cValue - cArg
|
|
OPERATOR "$" ARG cArg INLINE ::cValue $ cArg
|
|
OPERATOR "[]" ARG nIndex INLINE iif( PCount() > 2, ;
|
|
::cValue := Stuff( ::cValue, nIndex, 1, hb_PValue( 3 ) ), ;
|
|
SubStr( ::cValue, nIndex, 1 ) )
|
|
|
|
ENDCLASS
|
|
|
|
|
|
/*
|
|
function TString()
|
|
|
|
static oClass
|
|
|
|
if oClass == nil
|
|
oClass = HBClass():New( "TSTRING" ) // starts a new class definition
|
|
|
|
oClass:AddData( "cValue" ) // define this class objects datas
|
|
|
|
oClass:AddMethod( "New", @New() )
|
|
|
|
oClass:AddInline( "==", {| self, cTest | ::cValue == cTest } )
|
|
oClass:AddInline( "!=", {| self, cTest | ::cValue != cTest } )
|
|
oClass:AddInline( "<" , {| self, cTest | ::cValue < cTest } )
|
|
oClass:AddInline( "<=", {| self, cTest | ::cValue <= cTest } )
|
|
oClass:AddInline( ">" , {| self, cTest | ::cValue > cTest } )
|
|
oClass:AddInline( ">=", {| self, cTest | ::cValue >= cTest } )
|
|
oClass:AddInline( "+" , {| self, cTest | ::cValue + cTest } )
|
|
oClass:AddInline( "-" , {| self, cTest | ::cValue - cTest } )
|
|
oClass:AddInline( "$" , {| self, cTest | ::cValue $ cTest } )
|
|
|
|
oClass:AddInline( "HasMsg", {| self, cMsg | __ObjHasMsg( QSelf(), cMsg ) } )
|
|
|
|
oClass:Create() // builds this class
|
|
endif
|
|
|
|
return oClass:Instance() // builds an object of this class
|
|
|
|
static function New( cText )
|
|
|
|
local Self := QSelf()
|
|
|
|
::cValue := cText
|
|
|
|
return Self
|
|
|
|
*/
|