Sha256: 080a9ce238544354b6626a818c9cbe69f0dbd2fd3a3097fa54dcc42b8d581271
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
#include "xot/string.h" #include <stdio.h> #include <boost/scoped_array.hpp> namespace Xot { String stringf (const char* format, ...) { va_list args; va_start(args, format); String ret = stringf(format, args); va_end(args); return ret; } String stringf (const char* format, va_list args) { enum {BUFSIZE = 256}; char stack[BUFSIZE]; if (vsnprintf(&stack[0], BUFSIZE, format, args) <= BUFSIZE) return &stack[0]; int bufsize = BUFSIZE;// vscprintf(format, args); boost::scoped_array<char> heap; while (true) { bufsize *= 2; heap.reset(new char[bufsize]); if (vsnprintf(&heap[0], bufsize, format, args) <= bufsize) return &heap[0]; } return NULL; } template <> String to_s<int> (const int& val) { return stringf("%d", val); } template <> String to_s<float> (const float& val) { return stringf("%f", val); } template <> String to_s<double> (const double& val) { return stringf("%f", val); } typedef const char* const_char_p; template <> String to_s<const_char_p> (const const_char_p& val) { return val; } template <> String to_s<String> (const String& val) { return val; } }// Xot
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
xot-0.1.6 | src/string.cpp |
xot-0.1.5 | src/string.cpp |
xot-0.1.4 | src/string.cpp |
xot-0.1.3 | src/string.cpp |