📄 stafstringinlimpl.cpp
字号:
return *this;}STAF_INLINE STAFString &STAFString::strip(StripWhat stripWhat){ unsigned int osRC = 0; STAFRC_t rc = STAFStringStripCharsOfType(fStringImpl, kUTF8_TYPE_WHITESPACE, stripWhat, &osRC); STAFException::checkRC(rc, "STAFStringStripCharsOfType", osRC); return *this;}STAF_INLINE STAFString &STAFString::join(const STAFString stringArray[], unsigned int arraySize){ unsigned int osRC = 0; STAFRC_t rc = kSTAFOk; if (arraySize == 0) return *this; STAFString_t temp = fStringImpl; unsigned int joinArraySize = arraySize + 1; STAFString_t *joinArray = new STAFString_t[joinArraySize]; joinArray[0] = fStringImpl; for (unsigned int i = 1; i < joinArraySize; ++i) { joinArray[i] = stringArray[i - 1].getImpl(); } rc = STAFStringConstructJoin(&fStringImpl, joinArray, joinArraySize, &osRC); delete [] joinArray; STAFException::checkRC(rc, "STAFStringConstructJoin", osRC); STAFStringDestruct(&temp, 0); return *this;}STAF_INLINE unsigned int STAFString::asUInt(unsigned int base) const{ unsigned int osRC = 0; unsigned int theUInt = 0; STAFRC_t rc = STAFStringToUInt(fStringImpl, &theUInt, base, &osRC); STAFException::checkRC(rc, "STAFStringToUInt", osRC); return theUInt;}STAF_INLINE unsigned int STAFString::asUIntWithDefault( unsigned int defaultValue, unsigned int base) const{ unsigned int osRC = 0; unsigned int theUInt = 0; STAFRC_t rc = STAFStringToUInt(fStringImpl, &theUInt, base, &osRC); if (rc == kSTAFInvalidValue) return defaultValue; STAFException::checkRC(rc, "STAFStringToUInt", osRC); return theUInt;}STAF_INLINE STAFStringBufferPtr STAFString::toCurrentCodePage() const{ unsigned int osRC = 0; char *theBuffer = 0; unsigned int theLength = 0; STAFRC_t rc = STAFStringToCurrentCodePage(fStringImpl, &theBuffer, &theLength, &osRC); STAFException::checkRC(rc, "STAFStringToCurrentCodePage", osRC); return STAFStringBufferPtr(new STAFStringBuffer(theBuffer, theLength), STAFStringBufferPtr::INIT);}STAF_INLINE STAFString STAFString::toLowerCase() const{ unsigned int osRC = 0; STAFString_t theCopy = 0; STAFRC_t rc = STAFStringConstructCopy(&theCopy, fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC); rc = STAFStringToLowerCase(theCopy, &osRC); if (rc != 0) STAFStringDestruct(&theCopy, 0); STAFException::checkRC(rc, "STAFStringToLowerCase", osRC); return STAFString(theCopy, STAFString::kShallow);}STAF_INLINE STAFString STAFString::toUpperCase() const{ unsigned int osRC = 0; STAFString_t theCopy = 0; STAFRC_t rc = STAFStringConstructCopy(&theCopy, fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC); rc = STAFStringToUpperCase(theCopy, &osRC); if (rc != 0) STAFStringDestruct(&theCopy, 0); STAFException::checkRC(rc, "STAFStringToUpperCase", osRC); return STAFString(theCopy, STAFString::kShallow);}STAF_INLINE STAFString STAFString::replace(const STAFString oldstr, const STAFString newstr) const{ unsigned int osRC = 0; STAFString_t theCopy = 0; STAFRC_t rc = STAFStringConstructCopy(&theCopy, fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC); rc = STAFStringReplace(theCopy, oldstr.getImpl(), newstr.getImpl(), &osRC); if (rc != kSTAFOk) STAFStringDestruct(&theCopy, 0); STAFException::checkRC(rc, "STAFStringReplace", osRC); return STAFString(theCopy, STAFString::kShallow);}STAF_INLINE bool STAFString::isWhiteSpace() const{ unsigned int osRC = 0; unsigned int compVal = 0; STAFRC_t rc = STAFStringIsCharsOfType(fStringImpl, kUTF8_TYPE_WHITESPACE, &compVal, &osRC); STAFException::checkRC(rc, "STAFStringIsCharsOfType", osRC); return compVal ? true : false;}STAF_INLINE bool STAFString::isDigits() const{ unsigned int osRC = 0; unsigned int compVal = 0; STAFRC_t rc = STAFStringIsCharsOfType(fStringImpl, kUTF8_TYPE_DIGIT, &compVal, &osRC); STAFException::checkRC(rc, "STAFStringIsCharsOfType", osRC); return compVal ? true : false;}STAF_INLINE bool STAFString::isEqualTo(const STAFString &theString, STAFStringCaseSensitive_t caseSensitive) const{ unsigned int osRC = 0; unsigned int compVal = 0; STAFRC_t rc = STAFStringIsEqualTo(fStringImpl, theString.fStringImpl, caseSensitive, &compVal, &osRC); STAFException::checkRC(rc, "STAFStringIsEqualTo", osRC); return compVal ? true : false;}STAF_INLINE bool STAFString::hasWildcard() const{ unsigned int osRC = 0; unsigned int hasWildcard = 0; STAFRC_t rc = STAFStringContainsWildcard(fStringImpl, &hasWildcard, &osRC); STAFException::checkRC(rc, "STAFStringContainsWildcard", osRC); return hasWildcard ? true : false;}STAF_INLINE bool STAFString::startsWith(const STAFString &someString) const{ unsigned int osRC = 0; unsigned int doesStartWith = 0; STAFRC_t rc = STAFStringStartsWith(fStringImpl, someString.fStringImpl, &doesStartWith, &osRC); STAFException::checkRC(rc, "STAFStringStartsWith", osRC); return doesStartWith ? true : false;}STAF_INLINE bool STAFString::matchesWildcards(const STAFString &wildcardString, STAFStringCaseSensitive_t caseSensitive) const{ unsigned int osRC = 0; unsigned int matches = 0; STAFRC_t rc = STAFStringMatchesWildcards(fStringImpl, wildcardString.fStringImpl, caseSensitive, &matches, &osRC); STAFException::checkRC(rc, "STAFStringMatchesWildcards", osRC); return matches ? true : false;}STAF_INLINE STAFString &STAFString::operator=(const STAFString &rhs){ unsigned int osRC = 0; STAFString_t newString = 0; STAFRC_t rc = STAFStringConstructCopy(&newString, rhs.fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC); STAFString_t temp = fStringImpl; fStringImpl = newString; STAFStringDestruct(&temp, 0); return *this;}STAF_INLINE bool STAFString::operator==(const STAFString &rhs) const{ return isEqualTo(rhs, kSTAFStringCaseSensitive);}STAF_INLINE bool STAFString::operator!=(const STAFString &rhs) const{ return !isEqualTo(rhs, kSTAFStringCaseSensitive);}STAF_INLINE bool STAFString::operator<(const STAFString &rhs) const{ unsigned int osRC = 0; unsigned int compVal = 0; STAFRC_t rc = STAFStringCompareTo(fStringImpl, rhs.fStringImpl, &compVal, &osRC); STAFException::checkRC(rc, "STAFStringCompareTo", osRC); return (compVal == 1);}STAF_INLINE bool STAFString::operator<=(const STAFString &rhs) const{ return !(rhs < *this);}STAF_INLINE bool STAFString::operator>(const STAFString &rhs) const{ return (rhs < *this);}STAF_INLINE bool STAFString::operator>=(const STAFString &rhs) const{ return !(*this < rhs);}STAF_INLINE STAFString &STAFString::operator+=(const STAFString &rhs){ unsigned int osRC = 0; STAFRC_t rc = STAFStringConcatenate(fStringImpl, rhs.fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConcatenate", osRC); return *this;}STAF_INLINE STAFString operator+(const STAFString &lhs, const STAFString &rhs){ unsigned int osRC = 0; STAFString_t newString = 0; STAFRC_t rc = STAFStringConstructCopy(&newString, lhs.fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC); rc = STAFStringConcatenate(newString, rhs.fStringImpl, &osRC); if (rc != kSTAFOk) STAFStringDestruct(&newString, 0); STAFException::checkRC(rc, "STAFStringConcatenate", osRC); return STAFString(newString, STAFString::kShallow);}STAF_INLINE ostream &operator<<(ostream &os, const STAFString &rhs){ STAFStringBufferPtr buf = rhs.toCurrentCodePage(); os << buf->buffer(); return os;}STAF_INLINE STAFString::~STAFString(){ unsigned int osRC = 0; if (fStringImpl) STAFStringDestruct(&fStringImpl, &osRC);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -