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