📄 stafstringinlimpl.cpp
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2001 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************/#ifndef STAF_StringInlImpl#define STAF_StringInlImpl#include "STAF.h"#include <stdio.h>#include "STAFString.h"#include "STAF_iostream.h"#include "STAFRefPtr.h"#include "STAFException.h"STAF_INLINE STAFString::STAFString() : fStringImpl(0){ unsigned int osRC = 0; STAFRC_t rc = STAFStringConstruct(&fStringImpl, 0, 0, &osRC); STAFException::checkRC(rc, "STAFStringConstruct", osRC);}STAF_INLINE STAFString::STAFString(const char *buffer, unsigned int length, CodePageType cpType) : fStringImpl(0){ unsigned int osRC = 0; STAFRC_t rc = kSTAFOk; if (cpType == kCurrent) { rc = STAFStringConstructFromCurrentCodePage(&fStringImpl, buffer, (length == 0xFFFFFFFF) ? strlen(buffer) : length, &osRC); } else { rc = STAFStringConstruct(&fStringImpl, buffer, length, &osRC); } STAFException::checkRC(rc, "STAFStringConstruct[FromCurrentCodePage]", osRC);}STAF_INLINE STAFString::STAFString(unsigned int fromValue, unsigned int base) : fStringImpl(0){ unsigned int osRC = 0; STAFRC_t rc = STAFStringConstructFromUInt(&fStringImpl, fromValue, base, &osRC); STAFException::checkRC(rc, "STAFStringConstructFromUInt", osRC);}STAF_INLINE STAFString::STAFString(const STAFString &from) : fStringImpl(0){ unsigned int osRC = 0; STAFRC_t rc = STAFStringConstructCopy(&fStringImpl, from.fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC);}STAF_INLINE STAFString::STAFString(STAFStringConst_t from){ unsigned int osRC = 0; STAFRC_t rc = kSTAFOk; // if from is null, then construct an empty string, else // construct either a shallow or deep copy if (from == 0) rc = STAFStringConstruct(&fStringImpl, 0, 0, &osRC); else rc = STAFStringConstructCopy(&fStringImpl, from, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC);}STAF_INLINE STAFString::STAFString(STAFString_t from, CopyMode mode){ unsigned int osRC = 0; STAFRC_t rc = kSTAFOk; // if from is null, then construct an empty string, else // construct either a shallow or deep copy if (from == 0) rc = STAFStringConstruct(&fStringImpl, 0, 0, &osRC); else if (mode == kShallow) fStringImpl = (STAFString_t)from; else rc = STAFStringConstructCopy(&fStringImpl, from, &osRC); STAFException::checkRC(rc, "STAFStringConstructCopy", osRC);}STAF_INLINE STAFString::STAFString(STAFUTF8Char_t aChar){ unsigned int osRC = 0; STAFRC_t rc = STAFStringConstructChar(&fStringImpl, aChar, &osRC); STAFException::checkRC(rc, "STAFStringConstructChar", osRC);}STAF_INLINE STAFString STAFString::subString(unsigned int begin, unsigned int length, IndexRep corb) const{ STAFString_t newString; unsigned int osRC = 0; STAFRC_t rc = STAFStringConstructSubString(&newString, fStringImpl, begin, length, corb, &osRC); STAFException::checkRC(rc, "STAFStringConstructSubString", osRC); return STAFString(newString, STAFString::kShallow);}STAF_INLINE unsigned int STAFString::numWords() const{ unsigned int osRC = 0; unsigned int theNumWords = 0; STAFRC_t rc = STAFStringNumOfWords(fStringImpl, &theNumWords, &osRC); STAFException::checkRC(rc, "STAFStringNumWords", osRC); return theNumWords;}STAF_INLINE STAFString STAFString::subWord(unsigned int begin, unsigned int length) const{ STAFString_t newString; unsigned int osRC = 0; STAFRC_t rc = STAFStringConstructSubWord(&newString, fStringImpl, begin, length, &osRC); STAFException::checkRC(rc, "STAFStringConstructSubWord", osRC); return STAFString(newString, STAFString::kShallow);} STAF_INLINE unsigned int STAFString::count(const STAFString &theSubStr) const{ unsigned int osRC = 0; unsigned int theCount = 0; STAFRC_t rc = STAFStringCountSubStrings(fStringImpl, theSubStr.fStringImpl, &theCount, &osRC); STAFException::checkRC(rc, "STAFStringCount", osRC); return theCount;}STAF_INLINE unsigned int STAFString::length(IndexRep corb) const{ unsigned int osRC = 0; unsigned int theLength = 0; STAFRC_t rc = STAFStringLength(fStringImpl, &theLength, corb, &osRC); STAFException::checkRC(rc, "STAFStringLength", osRC); return theLength;}STAF_INLINE unsigned int STAFString::sizeOfChar(unsigned int index, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theSize = 0; STAFRC_t rc = STAFStringSizeOfChar(fStringImpl, index, corb, &theSize, &osRC); STAFException::checkRC(rc, "STAFStringSizeOfChar", osRC); return theSize;}STAF_INLINE const char *STAFString::buffer(unsigned int *bufLength) const{ unsigned int osRC = 0; const char *theData = 0; STAFRC_t rc = STAFStringGetBuffer(fStringImpl, &theData, bufLength, &osRC); STAFException::checkRC(rc, "STAFStringGetBuffer", osRC); return theData;}STAF_INLINE STAFString_t STAFString::getImpl() const{ return fStringImpl;}STAF_INLINE STAFString_t STAFString::adoptImpl(){ STAFString_t temp = fStringImpl; fStringImpl = 0; return temp;}STAF_INLINE void STAFString::replaceImpl(STAFString_t replacementImpl){ STAFString_t temp = fStringImpl; fStringImpl = replacementImpl; unsigned int osRC = 0; STAFRC_t rc = STAFStringDestruct(&temp, &osRC); STAFException::checkRC(rc, "STAFStringDestruct", osRC);}STAF_INLINE unsigned int STAFString::byteIndexOfChar(unsigned int charIndex) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringByteIndexOfChar(fStringImpl, charIndex, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringByteIndexOfChar", osRC); return theIndex;}STAF_INLINE unsigned int STAFString::find(const STAFString &searchFor, unsigned int begin, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringFind(fStringImpl, searchFor.fStringImpl, begin, corb, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringFind", osRC); return theIndex;}STAF_INLINE unsigned int STAFString::findFirstOf(const STAFString &searchList, unsigned int begin, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringFindFirstOf(fStringImpl, searchList.fStringImpl, begin, corb, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringFindFirstOf", osRC); return theIndex;}STAF_INLINE unsigned int STAFString::findFirstNotOf(const STAFString &searchList, unsigned int begin, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringFindFirstNotOf(fStringImpl, searchList.fStringImpl, begin, corb, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringFindFirstNotOf", osRC); return theIndex;}STAF_INLINE unsigned int STAFString::findLastOf(const STAFString &searchList, unsigned int begin, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringFindLastOf(fStringImpl, searchList.fStringImpl, begin, corb, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringFindLastOf", osRC); return theIndex;}STAF_INLINE unsigned int STAFString::findLastNotOf(const STAFString &searchList, unsigned int begin, IndexRep corb) const{ unsigned int osRC = 0; unsigned int theIndex = 0; STAFRC_t rc = STAFStringFindLastNotOf(fStringImpl, searchList.fStringImpl, begin, corb, &theIndex, &osRC); STAFException::checkRC(rc, "STAFStringFindLastNotOf", osRC); return theIndex;}STAF_INLINE STAFString &STAFString::lowerCase(){ unsigned int osRC = 0; STAFRC_t rc = STAFStringToLowerCase(fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringToLowerCase", osRC); return *this;}STAF_INLINE STAFString &STAFString::upperCase(){ unsigned int osRC = 0; STAFRC_t rc = STAFStringToUpperCase(fStringImpl, &osRC); STAFException::checkRC(rc, "STAFStringToUpperCase", osRC);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -