If people are going to say something is C++, they should actually make use of some of the abstraction features of C++ to make the code actually easier to work with. If you're not using any features of C++, you're using C, period. You could pretty easily create a class which acts just like values in GM do (being able to assign strings to them and switch them to doubles later and have them automatically convert themselves into doubles or strings when retrieving values). C++ has some very powerful abstraction features and I'm disappointed that people who "use" C++ don't actually use the best of its features.
There you go X-tra Fear...
If you change your struct to an actual Class, you can overload the/a few assignment operator(s) (Though can you define operators whitout the need to define a class?) I'm a straight C guy myself so I cant help much on that when it come to the C++ tricks.. But I know you can set it up the way I mentioned
so you can have
GMVariable a = 1.5;
or
GMVariable a = "Hello"
and
GMVariable func(GMVariable arg1)
that can be called like so
double ret = func("Hello");
or
char *ret2 = func2(4.5);
I think I understand a bit what you're trying to say, but at the same time, I don't.
Just give me a little code example to show what you mean... oh wait, like if you put:
Yourself would be very much more qualified to show you how to setup your class so it works as I decribed in my prior post... All you need is about 10 extra lines of code in your gmhelper h file and your c++ file...
also, I think you can shortcut a few things
GMVariable gm_ds_find_value(GMVariable l,GMVariable ind)
{
GMVariable args[2];
args[0] = l;
args[1] = ind;
return GMProcCall(pds_find_value, 1, args);
}
is possibly the same as
GMVariable gm_ds_find_value(GMVariable l,GMVariable ind)
{
GMVariable args[] = {l,ind };
return GMProcCall(pds_find_value, 2, args);
}
and possibly
GMVariable gm_ds_find_value(GMVariable l,GMVariable ind)
{
return GMProcCall(pds_find_value, 2, {l,ind });
}
You can make GMProcCall take multiple arguments using some method I forgot... Just like sprintf takes multiple arguments
double l = GMProcCall(pds_ds_list_create);
GMProcCall(pds_add_value,l,"hello#how#are#you");
GMProcCall(pds_add_value,l,1.4);
double t = GMProcCall(pds_find_value,l,1);
char *s = GMProcCall(pds_find_value,l,0);
char *fs = GMProcCall(pstring_replace_all,s,"#","\r\n");
Edited by icuurd12b42, 23 February 2009 - 02:36 AM.