// ************************************************************************** /** @file tools.cc @todo - Resolve the dependancies with dim - Move code to a more appropriate place - put stuff in namespaces */ // ************************************************************************** #include "tools.h" #include using namespace std; string Format(const char *fmt, va_list &ap) { int n=256; char *ret=0; while (1) { ret = new char[n+1]; const int sz = vsnprintf(ret, n, fmt, ap); if (sz<=n) break; n *= 2; delete [] ret; }; string str(ret); delete [] ret; return str; } string Form(const char *fmt, ...) { va_list ap; va_start(ap, fmt); string str = Format(fmt, ap); va_end(ap); return str; }