39 #include "blocxx/BLOCXX_config.h"
46 #if defined(BLOCXX_HAVE_ISTREAM) && defined(BLOCXX_HAVE_OSTREAM)
55 namespace BLOCXX_NAMESPACE
58 #if defined(BLOCXX_AIX)
64 m_allocated(allocSize > 0 ? allocSize : BLOCXX_DEFAULT_ALLOCATION_UNIT),
65 m_bfr(new char[m_allocated])
72 m_allocated(m_len + BLOCXX_DEFAULT_ALLOCATION_UNIT),
73 m_bfr(new char[m_allocated])
80 m_allocated(m_len + BLOCXX_DEFAULT_ALLOCATION_UNIT),
81 m_bfr(new char[m_allocated])
87 m_len(arg.m_len), m_allocated(arg.m_allocated),
88 m_bfr(new char[arg.m_allocated])
153 #if defined(BLOCXX_WIN32)
154 #define snprintf _snprintf // stupid windoze...
161 ::snprintf(bfr,
sizeof(bfr),
"%u", UInt32(v));
169 ::snprintf(bfr,
sizeof(bfr),
"%d", Int32(v));
177 ::snprintf(bfr,
sizeof(bfr),
"%u", UInt32(v));
185 ::snprintf(bfr,
sizeof(bfr),
"%d", Int32(v));
193 ::snprintf(bfr,
sizeof(bfr),
"%u", v);
201 ::snprintf(bfr,
sizeof(bfr),
"%d", v);
204 #if defined(BLOCXX_INT32_IS_INT) && defined(BLOCXX_INT64_IS_LONG_LONG)
210 ::snprintf(bfr,
sizeof(bfr),
"%lu", v);
218 ::snprintf(bfr,
sizeof(bfr),
"%ld", v);
227 #if BLOCXX_SIZEOF_LONG_INT == 8
228 ::snprintf(bfr,
sizeof(bfr),
"%lu", v);
230 ::snprintf(bfr,
sizeof(bfr),
"%llu", v);
239 #if BLOCXX_SIZEOF_LONG_INT == 8
240 ::snprintf(bfr,
sizeof(bfr),
"%ld", v);
242 ::snprintf(bfr,
sizeof(bfr),
"%lld", v);
253 #if defined(BLOCXX_REAL32_IS_FLOAT)
254 ::snprintf(bfr,
sizeof(bfr),
"%.*g", FLT_MANT_DIG * 3 / 10 + 1, static_cast<double>(v));
255 #elif defined(BLOCXX_REAL32_IS_DOUBLE)
256 ::snprintf(bfr,
sizeof(bfr),
"%.*g", DBL_MANT_DIG * 3 / 10 + 1, v);
259 #error "The formula for computing the number of digits of precision for a floating point needs to be implmented. It's ceiling(bits * log(FLT_RADIX) / log(10))"
269 #if defined(BLOCXX_REAL64_IS_DOUBLE)
270 ::snprintf(bfr,
sizeof(bfr),
"%.*g", DBL_MANT_DIG * 3 / 10 + 1, v);
271 #elif defined(BLOCXX_REAL64_IS_LONG_DOUBLE)
272 ::snprintf(bfr,
sizeof(bfr),
"%.*Lg", LDBL_MANT_DIG * 3 / 10 + 1, v);
275 #error "The formula for computing the number of digits of precision for a floating point needs to be implmented. It's ceiling(bits * log(FLT_RADIX) / log(10))"
279 #if defined(BLOCXX_WIN32)
296 return ::strcmp(arg,
m_bfr) == 0;
344 while (*p && isspace(*p))
372 std::streambuf *sb = is.rdbuf();
376 int ch = sb->sbumpc();
379 is.setstate(count == 0
380 ? (std::ios::failbit | std::ios::eofbit) : std::ios::eofbit);
391 append(static_cast<char>(ch));
395 const char* p = ::strchr(
m_bfr,
'\r');