39 #ifndef BLOCXX_STRING_HPP_INCLUDE_GUARD_
40 #define BLOCXX_STRING_HPP_INCLUDE_GUARD_
41 #include "blocxx/BLOCXX_config.h"
49 namespace BLOCXX_NAMESPACE
80 explicit String(Int32 val);
87 explicit String(UInt32 val);
89 #if defined(BLOCXX_INT32_IS_INT) && defined(BLOCXX_INT64_IS_LONG_LONG)
103 explicit String(
unsigned long val);
111 explicit String(Int64 val);
118 explicit String(UInt64 val);
125 explicit String(Real32 val);
132 explicit String(Real64 val);
165 explicit String(
const std::string& str);
182 explicit String(ETakeOwnershipFlag,
char* allocatedMemory,
size_t len);
191 explicit String(
const char* str,
size_t len);
219 char* allocateCString()
const;
223 size_t length()
const;
227 size_t size()
const {
return length(); }
233 size_t UTF8Length()
const;
237 bool empty()
const {
return length() == 0; }
246 int format(
const char* fmt, ...);
257 E_RETURN_EMPTY_TOKENS
272 StringArray tokenize(
const char* delims =
" \n\r\t\v",
273 EReturnDelimitersFlag returnDelimitersAsTokens = E_DISCARD_DELIMITERS,
274 EEmptyTokenReturnFlag returnEmptyTokens = E_SKIP_EMPTY_TOKENS )
const;
279 const char* c_str()
const;
291 char charAt(
size_t ndx)
const;
299 int compareTo(
const String& arg)
const;
307 int compareTo(
const char* arg)
const;
329 String& concat(
const char* arg);
338 return concat(arg.
c_str());
360 bool endsWith(
const char* arg, EIgnoreCaseFlag ignoreCase = E_CASE_SENSITIVE)
const;
373 return endsWith(arg.
c_str(), ignoreCase);
382 bool endsWith(
char arg)
const;
391 bool equals(
const String& arg)
const;
399 bool equals(
const char* arg)
const;
408 bool equalsIgnoreCase(
const String& arg)
const;
417 bool equalsIgnoreCase(
const char* arg)
const;
421 UInt32 hashCode()
const;
430 size_t indexOf(
char ch,
size_t fromIndex=0)
const;
438 size_t indexOf(
const char* arg,
size_t fromIndex=0)
const;
446 size_t indexOf(
const String& arg,
size_t fromIndex=0)
const
448 return indexOf(arg.
c_str(), fromIndex);
459 size_t lastIndexOf(
char ch,
size_t fromIndex=npos)
const;
468 size_t lastIndexOf(
const char* arg,
size_t fromIndex=npos)
const;
477 size_t lastIndexOf(
const String& arg,
size_t fromIndex=npos)
const
479 return lastIndexOf(arg.
c_str(), fromIndex);
490 bool startsWith(
const char* arg, EIgnoreCaseFlag ignoreCase = E_CASE_SENSITIVE)
const;
501 return startsWith(arg.
c_str(), ignoreCase);
509 bool startsWith(
char arg)
const;
519 String substring(
size_t beginIndex,
520 size_t length=npos)
const;
525 bool isSpaces()
const;
571 String& erase(
size_t idx,
size_t len = npos );
586 const char& operator[] (
size_t ndx)
const;
587 char& operator[] (
size_t ndx);
601 String& operator+= (
const char* arg) {
return concat(arg); }
608 String& operator+= (
char arg) {
return concat(arg); }
615 void readObject(std::streambuf & istrm);
621 void writeObject(std::streambuf & ostrm)
const;
636 Real32 toReal32() const;
641 Real64 toReal64() const;
652 UInt8 toUInt8(
int base=10) const;
657 Int8 toInt8(
int base=10) const;
662 UInt16 toUInt16(
int base=10) const;
667 Int16 toInt16(
int base=10) const;
672 UInt32 toUInt32(
int base=10) const;
677 Int32 toInt32(
int base=10) const;
682 UInt64 toUInt64(
int base=10) const;
687 Int64 toInt64(
int base=10) const;
692 unsigned int toUnsignedInt(
int base=10) const;
697 int toInt(
int base=10) const;
708 static
unsigned long long int strtoull(const
char* nptr,
char** endptr,
720 static
long long int strtoll(const
char* nptr,
char** endptr,
int base);
728 static const
char* strchr(const
char* theStr,
int c);
737 static
String getLine(std::istream& istr);
739 #if defined(BLOCXX_AIX)
740 static const size_t npos;
742 static const size_t npos = size_t(~0);
746 #pragma warning (push)
747 #pragma warning (disable: 4251)
755 #pragma warning (pop)
762 BLOCXX_COMMON_API std::ostream&
operator<< (std::ostream& ostr,
const String& arg);
811 return (
String(p).compareTo(s) < 0);
826 return (
String(p).compareTo(s) <= 0);
841 return (
String(p).compareTo(s) > 0);
856 return (
String(p).compareTo(s) >= 0);