Sha256: a2348960972bf374abc1dc200bdec22a7dab0098be524779b7d4b61de45f1a65
Contents?: true
Size: 1.6 KB
Versions: 6
Compression:
Stored size: 1.6 KB
Contents
#include "xot/string.h" #include <stdio.h> #include <boost/scoped_array.hpp> namespace Xot { String::String () { } String::String (const char* str) : Super(str) { } String::operator const char* () const { return c_str(); } String operator + (const String& lhs, const String& rhs) { String t = lhs; t += rhs; return t; } String operator + (const String& lhs, const char* rhs) { String t = lhs; t += rhs; return t; } String operator + (const char* lhs, const String& rhs) { String t = lhs; t += rhs; return t; } 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
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
xot-0.1.12 | src/string.cpp |
xot-0.1.11 | src/string.cpp |
xot-0.1.10 | src/string.cpp |
xot-0.1.9 | src/string.cpp |
xot-0.1.8 | src/string.cpp |
xot-0.1.7 | src/string.cpp |