Here is my problem:
I'm writting a class to convert to strings and numbers and vice-versa Java style. I'm doing this because I really like the way Java handles data conversions (i.e. INT.parseInt(...)).
The problem is, I cannot find any numbers to strings functions in the ANSI library. So, instead of taking to task writing these myself, I found some OS specific functions.
Solaris UNIX, for instance, has lltostr. Visual Studio .NET has _ltostr. Each has different parameters. What I want is something that I can use on UNIX, Linux, Windows since I'll be using all 3 regularlly.
Now, this is how I am implimenting my method.
char* parse__::STRING(long value) {
#ifdef MICROSOFT__DOT_NET
// use _ltostr
#endif
#elif defined(UNIX_SOLARIS)
// use lltostr
#else
throw exception("Unsupported compiler");
#endif
return NULL;
}
And I want to have something
#if using Solaris #define UNIX_SOLARIS
#elif using .NET #define MICROSOFT__DOT_NET
The only directives I've found for doing this sort of thing is OS specific. That is no good. Any ideas? I have to precompiler directives for some parts because if I don't, the compiler balks about undeclared identifier. Better yet, is there an ANSI number to string like atoi or atof?
Thanks
Wade
I'm writting a class to convert to strings and numbers and vice-versa Java style. I'm doing this because I really like the way Java handles data conversions (i.e. INT.parseInt(...)).
The problem is, I cannot find any numbers to strings functions in the ANSI library. So, instead of taking to task writing these myself, I found some OS specific functions.
Solaris UNIX, for instance, has lltostr. Visual Studio .NET has _ltostr. Each has different parameters. What I want is something that I can use on UNIX, Linux, Windows since I'll be using all 3 regularlly.
Now, this is how I am implimenting my method.
char* parse__::STRING(long value) {
#ifdef MICROSOFT__DOT_NET
// use _ltostr
#endif
#elif defined(UNIX_SOLARIS)
// use lltostr
#else
throw exception("Unsupported compiler");
#endif
return NULL;
}
And I want to have something
#if using Solaris #define UNIX_SOLARIS
#elif using .NET #define MICROSOFT__DOT_NET
The only directives I've found for doing this sort of thing is OS specific. That is no good. Any ideas? I have to precompiler directives for some parts because if I don't, the compiler balks about undeclared identifier. Better yet, is there an ANSI number to string like atoi or atof?
Thanks
Wade
