39#include "blocxx/BLOCXX_config.h"
46#if defined(BLOCXX_HAVE_ISTREAM) && defined(BLOCXX_HAVE_OSTREAM)
58#if defined(BLOCXX_AIX)
62StringBuffer::StringBuffer(size_t allocSize) :
153#if defined(BLOCXX_WIN32)
154#define snprintf _snprintf
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');
The Bool class is an abstraction for the boolean data type.
StringBuffer(size_t allocSize=BLOCXX_DEFAULT_ALLOCATION_UNIT)
void swap(StringBuffer &x)
StringBuffer & append(char c)
bool endsWith(char ch) const
const char * c_str() const
const char * getLine(std::istream &is, bool resetBuffer=true)
Fill this StringBuffer object with the next line from the given input stream.
StringBuffer & operator+=(char c)
static const size_t BLOCXX_DEFAULT_ALLOCATION_UNIT
void truncate(size_t index)
Truncate the string at the given index.
bool startsWith(char ch) const
bool equals(const char *arg) const
char operator[](size_t ndx) const
StringBuffer & operator=(const StringBuffer &arg)
void checkAvail(size_t len=1)
This String class is an abstract data type that represents as NULL terminated string of characters.
const char * c_str() const
bool equals(const String &arg) const
Determine if another String object is equal to this String object.
bool operator==(const Array< T > &x, const Array< T > &y)
ostream & operator<<(ostream &ostrm, const Bool &arg)
bool operator!=(const Array< T > &x, const Array< T > &y)
Determine two Arrays are not equal.