本文整理汇总了C++中StString::subString方法的典型用法代码示例。如果您正苦于以下问题:C++ StString::subString方法的具体用法?C++ StString::subString怎么用?C++ StString::subString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StString
的用法示例。
在下文中一共展示了StString::subString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseLine
void StLangMap::parseLine(const StString& theLine) {
if(myIsHeaderSection) {
myIsHeaderSection = !(theLine == StString(HEADER_SECTION_DELIM));
}
for(StUtf8Iter anIter = theLine.iterator(); *anIter != 0; ++anIter) {
if(*anIter != stUtf32_t('=')) {
// not interesting
continue;
}
size_t aKey = size_t(std::atol(theLine.subString(0, anIter.getIndex()).toCString()));
// get value without quotes
StString aValue = theLine.subString(anIter.getIndex() + 2, theLine.getLength() - 1);
///TODO (Kirill Gavrilov#9) add all replacements
for(anIter = aValue.iterator(); *anIter != 0; ++anIter) {
if(*anIter.getBufferHere() == stUtf8_t('\\') && *anIter.getBufferNext() == stUtf8_t('n')) {
// this is a hacking code in fact...
*(stUtf8_t* )anIter.getBufferHere() = stUtf8_t(' ');
*(stUtf8_t* )anIter.getBufferNext() = stUtf8_t('\n');
}
}
myMap.insert(std::pair<size_t, StString>(aKey, aValue));
return;
}
}
示例2: parseString
void StDictEntry::parseString(const StString& theString) {
for(StUtf8Iter anIter = theString.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t('=')) {
myKey = theString.subString(0, anIter.getIndex());
myValue = theString.subString(anIter.getIndex() + 1, theString.getLength()).unquoted();
return;
}
}
myKey = theString;
}
示例3: getNameAndExtension
void StFileNode::getNameAndExtension(const StString& theFileName,
StString& theName,
StString& theExtension) {
size_t aLastPnt = size_t(-1);
for(StUtf8Iter anIter = theFileName.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t('.')) {
aLastPnt = anIter.getIndex();
}
}
if(aLastPnt != size_t(-1)) {
theName = theFileName.subString(0, aLastPnt);
theExtension = theFileName.subString(aLastPnt + 1, theFileName.getLength());
} else {
theName = theFileName;
theExtension = StString();
}
}
示例4: getFolderAndFile
void StFileNode::getFolderAndFile(const StString& theFilePath,
StString& theFolder,
StString& theFileName) {
size_t aLastSplit = size_t(-1);
for(StUtf8Iter anIter = theFilePath.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
aLastSplit = anIter.getIndex();
}
}
if(aLastSplit != size_t(-1)) {
theFolder = theFilePath.subString(0, aLastSplit);
theFileName = theFilePath.subString(aLastSplit + 1, theFilePath.getLength());
} else {
theFolder = StString();
theFileName = theFilePath;
}
}
示例5: getExtension
StString StFileNode::getExtension(const StString& theFileName) {
size_t aPntId = size_t(-1);
for(StUtf8Iter anIter = theFileName.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t('.')) {
aPntId = anIter.getIndex();
}
}
return (aPntId != size_t(-1)) ? theFileName.subString(aPntId + 1, theFileName.getLength()) : StString();
}
示例6: getAbsolutePath
StString StProcess::getAbsolutePath(const StString& thePath) {
StString aPath;
if(thePath.isStartsWith(ST_FILE_PROTOCOL)) {
const StString aData = thePath.subString(ST_FILE_PROTOCOL.getLength(), thePath.getLength());
aPath.fromUrl(aData);
} else {
aPath = thePath;
}
if(StFileNode::isAbsolutePath(aPath)) {
return aPath;
}
return StProcess::getWorkingFolder() + aPath; // make absolute path
}
示例7: getProcessFolder
StString StProcess::getProcessFolder() {
StString aFullPath = getProcessFullPath();
size_t aLastSplit = size_t(-1);
for(StUtf8Iter anIter = aFullPath.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
aLastSplit = anIter.getIndex();
}
}
if(aLastSplit != size_t(-1)) {
return aFullPath.subString(0, aLastSplit + 1); // including trailing separator!
} else {
return StString();
}
}
示例8: getProcessName
StString StProcess::getProcessName() {
StString aFullPath = getProcessFullPath();
size_t aLastSplit = size_t(-1);
for(StUtf8Iter anIter = aFullPath.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
aLastSplit = anIter.getIndex();
}
}
if(aLastSplit != size_t(-1)) {
return aFullPath.subString(aLastSplit + 1, aFullPath.getLength());
} else {
return aFullPath;
}
}
示例9: getFolderUp
StString StFileNode::getFolderUp(const StString& thePath) {
size_t aLastSplit = size_t(-1);
size_t aPreSplit = size_t(-1);
for(StUtf8Iter anIter = thePath.iterator(); *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t(SYS_FS_SPLITTER)) {
aPreSplit = aLastSplit;
aLastSplit = anIter.getIndex();
}
}
if(aLastSplit != size_t(-1)
&& aLastSplit + 1 == thePath.getLength()) {
aLastSplit = aPreSplit;
}
if(aLastSplit == size_t(-1)) {
return StString();
}
return thePath.subString(0, aLastSplit);
}
示例10: load
bool StLibrary::load(const StString& thePath) {
// this is probably some logical error in the code if close() wasn't explicitly called before!
ST_ASSERT(!isOpened(), "StLibrary::load() - library is already opened!");
close();
StString aDinLibExt = StString(ST_DLIB_SUFFIX);
if(thePath.isEndsWithIgnoreCase(aDinLibExt)) {
// got the full path?
myPath = thePath;
myLibH = DLibLoadFull(myPath);
if(myLibH == NULL) {
// try to remove an extension
myPath = thePath.subString(0, thePath.getLength() - aDinLibExt.getLength());
myLibH = DLibLoad(myPath);
}
} else {
// got short name?
myPath = thePath;
myLibH = DLibLoad(myPath);
}
return isOpened();
}
示例11: setOpenPath
void StAndroidGlue::setOpenPath(const jstring theOpenPath,
const jstring theMimeType,
const jboolean theIsLaunchedFromHistory) {
JNIEnv* aJniEnv = myActivity->env;
StString anOpenPath = stStringFromJava(aJniEnv, theOpenPath);
StString aMimeType = stStringFromJava(aJniEnv, theMimeType);
const StString ST_FILE_PROTOCOL("file://");
if(anOpenPath.isStartsWith(ST_FILE_PROTOCOL)) {
const size_t aCutFrom = ST_FILE_PROTOCOL.getLength();
const StString aPath = anOpenPath.subString(aCutFrom, (size_t )-1);
anOpenPath.fromUrl(aPath);
}
StMutexAuto aLock(myFetchLock);
if(myCreatePath.isEmpty()) {
myCreatePath = anOpenPath;
}
// ignore outdated intent from history list - use C++ recent list instead
if(!theIsLaunchedFromHistory) {
myDndPath = anOpenPath;
}
}
示例12: StOpenInfo
StHandle<StOpenInfo> StApplication::parseProcessArguments() {
StHandle<StOpenInfo> anInfo = new StOpenInfo();
StArrayList<StString> anArguments = StProcess::getArguments();
StArgumentsMap anOpenFileArgs;
size_t aFilesCount = 0;
bool isFilesSection = false;
const StString ARGUMENT_FILES_SECTION = '-';
const StString ARGUMENT_ANY = "--";
const StString ARGUMENT_HELP = "help";
const StString ARGUMENT_FILE = "file";
const StString ARGUMENT_LEFT_VIEW = "left";
const StString ARGUMENT_RIGHT_VIEW = "right";
// parse extra parameters
for(size_t aParamIter = 1; aParamIter < anArguments.size(); ++aParamIter) {
StString aParam = anArguments[aParamIter];
///ST_DEBUG_LOG("aParam= '" + aParam + "'");
if(isFilesSection) {
// file name
StString aFilePath = StProcess::getAbsolutePath(aParam);
anOpenFileArgs.add(StArgument(ARGUMENT_FILE + aFilesCount++, aFilePath));
if(!anInfo->hasPath()) {
// first file determines MIME type (needed to autoselect Drawer plugin)
anInfo->setPath(aFilePath);
}
} else if(aParam == ARGUMENT_FILES_SECTION) {
isFilesSection = true;
} else if(aParam.isStartsWith(ARGUMENT_ANY)) {
// argument
StArgument anArg; anArg.parseString(aParam.subString(2, aParam.getLength())); // cut suffix --
if(anArg.getKey().isEqualsIgnoreCase(ARGUMENT_HELP)) {
return NULL;
} else if(anArg.getKey().isEqualsIgnoreCase(ARGUMENT_LEFT_VIEW)) {
// left view
anArg.setValue(StProcess::getAbsolutePath(anArg.getValue()));
anOpenFileArgs.add(anArg);
anInfo->setPath(anArg.getValue()); // left file always determines MIME type
} else if(anArg.getKey().isEqualsIgnoreCase(ARGUMENT_RIGHT_VIEW)) {
// right view
anArg.setValue(StProcess::getAbsolutePath(anArg.getValue()));
anOpenFileArgs.add(anArg);
if(!anInfo->hasPath()) {
anInfo->setPath(anArg.getValue());
}
} else {
// pass argument unchanged
anOpenFileArgs.add(anArg);
}
} else {
// file name
StString aFilePath = StProcess::getAbsolutePath(aParam);
anOpenFileArgs.add(StArgument(ARGUMENT_FILE + aFilesCount++, aFilePath));
if(!anInfo->hasPath()) {
// first file determines MIME type (needed to autoselect Drawer plugin)
anInfo->setPath(aFilePath);
}
}
}
anInfo->setArgumentsMap(anOpenFileArgs);
return anInfo;
}