Well progress is being made in my knowledge of AS, yet I've run into a road block! This might be related to my still no 100% complete knowledge of C++ though, so I apologize if so!
I want to create a helper method only availble to the scripts called String. This method will take any type and atempt to cast it to a std::string using boost::lexical_cast(...);
My question is:
1. What type do I need when registering with AS? RegisterGlbFn works and just registers a global function with AS.
m_script.RegisterGblFn("string String(any inStr)",asFUNCTION(::ToString));
Is that correct?
So what does the prototype for ToString need to be? I'm thinking taking in a void* ...but I have a feeling templates might work? I'm currently using this, but clearly that only works for ints, and I would like to no have to overload this function 10times!
std::string ToString( int in )
{
std::string out;
try
{
out = boost::lexical_cast<std::string>(in);
}
catch (...)
{
out = "Bad cast.";
}
return out;
}
Any guidance would be great.
Cheers
_S