39#include "blocxx/BLOCXX_config.h"
59#if defined(BLOCXX_HAVE_ISTREAM) && defined(BLOCXX_HAVE_OSTREAM)
69#define SNPRINTF _snprintf
71#define SNPRINTF snprintf
89 return ls1.compareToIgnoreCase(
ls2);
119 char*
buf =
new char[
arg.m_len+1];
135#if defined(BLOCXX_AIX)
158#if defined(BLOCXX_WIN32)
159#define snprintf _snprintf
181#if defined(BLOCXX_INT32_IS_INT) && defined(BLOCXX_INT64_IS_LONG_LONG)
203#if defined(BLOCXX_WIN32)
218#if defined(BLOCXX_INT64_IS_LONG)
222#elif defined(BLOCXX_INT64_IS_LONG_LONG)
237#if defined(BLOCXX_REAL32_IS_FLOAT)
239#elif defined(BLOCXX_REAL32_IS_DOUBLE)
243#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))"
253#if defined(BLOCXX_REAL64_IS_DOUBLE)
255#elif defined(BLOCXX_REAL64_IS_LONG_DOUBLE)
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))"
302 size_t sz =
ra.size();
306 for (
size_t i = 0;
i <
sz;
i++)
366#define vsnprintf _vsnprintf
385 return static_cast<int>(
length());
409 const char*
lhs =
"";
414 return ::strcmp(
lhs,
arg);
426 const char*
lhs =
"";
539 for (
size_t i = 0;
i <
len;
i++)
808 const char*
s2 =
p2 - 1;
974template <
typename T,
typename FP>
999#if defined(BLOCXX_REAL32_IS_FLOAT) && defined(BLOCXX_HAVE_STRTOF)
1001#elif defined(BLOCXX_REAL32_IS_DOUBLE) || (defined(BLOCXX_REAL32_IS_FLOAT) && !defined(BLOCXX_HAVE_STRTOF))
1009#if defined(BLOCXX_REAL64_IS_DOUBLE)
1011#elif defined(BLOCXX_REAL64_IS_LONG_DOUBLE)
1033template <
typename T,
typename FP,
typename FPRT>
1044 T rv =
static_cast<T>(
v);
1061template <
typename T>
1067template <
typename T>
1073template <
typename T>
1079template <
typename T>
1202#ifdef BLOCXX_HAVE_STRTOLL
1210#if BLOCXX_SIZEOF_LONG_LONG_INT == 8
1211#define LLONG_MAX 9223372036854775807LL
1213#define LLONG_MAX 2147483647LL
1215#define LLONG_MIN (-LLONG_MAX - 1LL)
1230 c = (
unsigned char) *s++;
1247 && (*s ==
'x' || *s ==
'X'))
1255 base =
c ==
'0' ? 8 : 10;
1346#ifdef BLOCXX_HAVE_STRTOULL
1347unsigned long long int
1354#if BLOCXX_SIZEOF_LONG_LONG_INT == 8
1355#define ULLONG_MAX 18446744073709551615ULL
1357#define ULLONG_MAX 4294967295ULL
1360unsigned long long int
1370 c = (
unsigned char) *s++;
1387 && (*s ==
'x' || *s ==
'X'))
1395 base =
c ==
'0' ? 8 : 10;
1413 if (
c >= (
unsigned int)
base)
1437#pragma warning (push)
1438#pragma warning (disable: 4146)
1444#pragma warning (pop)
1509 return rv.releaseString();
#define BLOCXX_ASSERT(CON)
BLOCXX_ASSERT works similar to the assert() macro, but instead of calling abort(),...
#define BLOCXX_DEFINE_EXCEPTION_WITH_ID(NAME)
Define a new exception class named <NAME>Exception that derives from Exception.
#define BLOCXX_THROW(exType, msg)
Throw an exception using FILE and LINE.
std::vector< char > & m_buf
Array<> wraps std::vector<> in COWReference<> adding ref counting and copy on write capability.
void append(const T &x)
Append an element to the end of the Array.
The AutoPtrVec class provides a simple class for smart pointers to a dynamically allocated array of o...
The Bool class is an abstraction for the boolean data type.
void swap(COWIntrusiveReference &rhs)
The Char16 class is an abstraction for a double byte character.
ByteBuf(const ByteBuf &arg)
ByteBuf & operator=(const ByteBuf &arg)
ByteBuf(AutoPtrVec< char > &s, size_t len)
This String class is an abstract data type that represents as NULL terminated string of characters.
bool equalsIgnoreCase(const String &arg) const
Determine if another String object is equal to this String object, ignoring case in the comparision.
const char * c_str() const
String & operator=(const String &arg)
Assignment operator.
void swap(String &x)
Swap this instance with another.
String & concat(const char *arg)
Append a C string to this String object.
String & erase()
Delete all the characters of the string.
static String getLine(std::istream &istr)
Reads from in input stream until a newline is encountered.
unsigned int toUnsignedInt(int base=10) const
int compareToIgnoreCase(const String &arg) const
Compare another string with this one ignoring case.
~String()
Destroy this String object.
UInt32 toUInt32(int base=10) const
static unsigned long long int strtoull(const char *nptr, char **endptr, int base)
Convert a null terminated string to an unsigned 64 bit value.
String()
Create a new String object with a length of 0.
String substring(size_t beginIndex, size_t length=npos) const
Create another String object that is comprised of a substring of this String object.
int format(const char *fmt,...)
Format this string according to the given format and variable argument list (printf style)
UInt8 toUInt8(int base=10) const
int toInt(int base=10) const
bool equals(const String &arg) const
Determine if another String object is equal to this String object.
static const char * strchr(const char *theStr, int c)
Find the first occurrence of a character in a null terminated string.
Char16 toChar16() const BLOCXX_DEPRECATED
DEPRECATED in favor of Char16::Char16(const String&) in 3.1.0.
String & toLowerCase()
Convert this String object to lower case characters.
void writeObject(std::streambuf &ostrm) const
Write this String object to the given ostream.
char * allocateCString() const
Create a null terminated string that contains the contents of this String.
String & trim()
Strip all leading and trailing space characters (as defined by the C function isspace()) from this St...
StringArray tokenize(const char *delims=" \n\r\t\v", EReturnDelimitersFlag returnDelimitersAsTokens=E_DISCARD_DELIMITERS, EEmptyTokenReturnFlag returnEmptyTokens=E_SKIP_EMPTY_TOKENS) const
Tokenize this String object using the given delimeters.
Int32 toInt32(int base=10) const
Int64 toInt64(int base=10) const
bool startsWith(const char *arg, EIgnoreCaseFlag ignoreCase=E_CASE_SENSITIVE) const
Determine if this String object starts with a given substring.
Int16 toInt16(int base=10) const
size_t indexOf(char ch, size_t fromIndex=0) const
Find the first occurence of a given character in this String object.
UInt16 toUInt16(int base=10) const
UInt64 toUInt64(int base=10) const
String & rtrim()
Strip all trailing space characters (as defined by the C function isspace()) from this String object.
size_t UTF8Length() const
If the string is not valid UTF-8, then the result of this function is undefined.
size_t lastIndexOf(char ch, size_t fromIndex=npos) const
Find the last occurence of a character in this String object.
static long long int strtoll(const char *nptr, char **endptr, int base)
Convert a null terminated string to an signed 64 bit value.
int compareTo(const String &arg) const
Compare another String object with this one.
Int8 toInt8(int base=10) const
String & toUpperCase()
Convert this String object to upper case characters.
char charAt(size_t ndx) const
Get the character at a specified index.
const char & operator[](size_t ndx) const
Operator [].
bool endsWith(const char *arg, EIgnoreCaseFlag ignoreCase=E_CASE_SENSITIVE) const
Determine if this String object ends with given C string.
String & ltrim()
Strip all leading space characters (as defined by the C function isspace()) from this String object.
void readObject(std::streambuf &istrm)
Read this String object from the given istream.
void readLen(std::streambuf &istrm, UInt32 &len)
void read(std::streambuf &istrm, void *dataIn, size_t dataInLen)
void write(std::streambuf &ostrm, void const *dataOut, size_t dataOutLen)
void writeLen(std::streambuf &ostrm, UInt32 len)
String toUpperCase(const char *input)
Convert the UTF-8 string to upper case and return the result.
BLOCXX_COMMON_API int compareToIgnoreCase(const char *str1, const char *str2)
Compares 2 UTF-8 strings, ignoring any case differences as defined by the Unicode spec CaseFolding....
bool toUpperCaseInPlace(char *input)
Convert the UTF-8 string to upper case.
String toLowerCase(const char *input)
Convert the UTF-8 string to lower case and return the result.
size_t charCount(const char *utf8str)
Count the number of UTF-8 chars in the string.
bool toLowerCaseInPlace(char *input)
Convert the UTF-8 string to lower case.
Char16 operator+(const Char16 &arg1, const Char16 &arg2)
unsigned long long int(* strtoullfp_t)(const char *, char **, int)
static int strncmpi(const char *s1, const char *s2, size_t n)
static T convertToUIntType(const String::buf_t &m_buf, const char *msg, int base)
static T convertToInt64Type(const String::buf_t &m_buf, const char *msg, int base)
unsigned long int(* strtoulfp_t)(const char *, char **, int)
long long int(* strtollfp_t)(const char *, char **, int)
bool operator==(const Array< T > &x, const Array< T > &y)
long int(* strtolfp_t)(const char *, char **, int)
static const char cnullChar
static T doConvertToIntType(const String::buf_t &m_buf, const char *type, FP fp, int base)
ostream & operator<<(ostream &ostrm, const Bool &arg)
static T convertToUInt64Type(const String::buf_t &m_buf, const char *msg, int base)
static void throwStringConversion(const String::buf_t &m_buf, const char *type)
static T convertToIntType(const String::buf_t &m_buf, const char *msg, int base)
static T convertToRealType(const String::buf_t &m_buf, const char *type, FP fp)