Hi,
My main goal is to implement a type of 'interface' class that allows you to monitor/get/set 'primitive' values. I have it working wonderfully with ints, longs, shorts, etc. Even though Blitzmax Strings are objects I would like to be able to monitor string pointers also. Now, I know strings are immutable, and modifying a string is not my goal. I just wish to access it through a pointer for read-only access.
below is some example code implemented with integers.
I want to achieve the same thing with the built-in string class. Any ideas of how to get a 'pointer' to a 'reference' is essentially what I'm trying to do.
..Otherwise I'm going to have to with the String.ToCString() route to be able to access these pointers, which is unfortunate as it's a 'copy' of the string and the user of the class will have to update the string object and the byte-ptr reference (remembering to free memory, etc).
My main goal is to implement a type of 'interface' class that allows you to monitor/get/set 'primitive' values. I have it working wonderfully with ints, longs, shorts, etc. Even though Blitzmax Strings are objects I would like to be able to monitor string pointers also. Now, I know strings are immutable, and modifying a string is not my goal. I just wish to access it through a pointer for read-only access.
below is some example code implemented with integers.
Local myInt:Int = 12345 Local p:Int Ptr = Varptr(myInt) Local pp:Int Ptr Ptr = Varptr(p) Print "double pointer value: " + pp[0][0] ' now if 'p' starts to point to another int my double pointer will see it. Local mySecondInt:Int = 2 p = Varptr(mySecondInt) Print "double pointer value: " + pp[0][0]
I want to achieve the same thing with the built-in string class. Any ideas of how to get a 'pointer' to a 'reference' is essentially what I'm trying to do.
..Otherwise I'm going to have to with the String.ToCString() route to be able to access these pointers, which is unfortunate as it's a 'copy' of the string and the user of the class will have to update the string object and the byte-ptr reference (remembering to free memory, etc).