uo_keyvaluecollection.sru 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. $PBExportHeader$uo_keyvaluecollection.sru
  2. forward
  3. global type uo_keyvaluecollection from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_keyvaluecollection from nonvisualobject
  7. end type
  8. global uo_keyvaluecollection uo_keyvaluecollection
  9. type variables
  10. Private:
  11. String keys[]
  12. String Values[]
  13. end variables
  14. forward prototypes
  15. public subroutine uf_add (string arg_key, string arg_value)
  16. public function boolean uf_haskey (string arg_key)
  17. public function string uf_getvalue (string arg_key)
  18. public subroutine uf_clear ()
  19. public function boolean uf_include (uo_keyvaluecollection arg_sub)
  20. public subroutine uf_getkeys (ref string arg_keys[])
  21. public subroutine uf_getvalues (ref string arg_values[])
  22. end prototypes
  23. public subroutine uf_add (string arg_key, string arg_value);Long i
  24. FOR i = 1 To UpperBound(keys)
  25. IF keys[i] = arg_key THEN EXIT
  26. NEXT
  27. IF i > UpperBound(keys) THEN
  28. keys[i] = arg_key
  29. Values[i] = arg_value
  30. ELSE
  31. Values[i] += ',' + arg_value
  32. END IF
  33. end subroutine
  34. public function boolean uf_haskey (string arg_key);Long i
  35. FOR i = 1 To UpperBound(keys)
  36. IF keys[i] = arg_key THEN RETURN True
  37. NEXT
  38. RETURN False
  39. end function
  40. public function string uf_getvalue (string arg_key);Long i
  41. FOR i = 1 To UpperBound(keys)
  42. IF keys[i] = arg_key THEN RETURN Values[i]
  43. NEXT
  44. String ls_null
  45. SetNull(ls_null)
  46. RETURN ls_null
  47. end function
  48. public subroutine uf_clear ();String empty_arr[]
  49. keys = empty_arr
  50. Values = empty_arr
  51. end subroutine
  52. public function boolean uf_include (uo_keyvaluecollection arg_sub);IF UpperBound(arg_sub.keys) <= 0 THEN RETURN False
  53. Long i
  54. FOR i = 1 To UpperBound(arg_sub.keys)
  55. IF Not This.uf_haskey(arg_sub.keys[i]) THEN RETURN False
  56. IF This.uf_getvalue(arg_sub.keys[i]) <> arg_sub.Values[i] THEN RETURN False
  57. NEXT
  58. RETURN True
  59. end function
  60. public subroutine uf_getkeys (ref string arg_keys[]);arg_keys = keys
  61. end subroutine
  62. public subroutine uf_getvalues (ref string arg_values[]);arg_values = values
  63. end subroutine
  64. on uo_keyvaluecollection.create
  65. call super::create
  66. TriggerEvent( this, "constructor" )
  67. end on
  68. on uo_keyvaluecollection.destroy
  69. TriggerEvent( this, "destructor" )
  70. call super::destroy
  71. end on