本文整理汇总了C++中StString类的典型用法代码示例。如果您正苦于以下问题:C++ StString类的具体用法?C++ StString怎么用?C++ StString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StFolder
void StFolder::addItem(const StArrayList<StString>& theExtensions,
int theDeep,
const StString& theSearchFolderPath,
const StString& theCurrentItemName) {
if(theCurrentItemName == IGNORE_DIR_CURR_NAME || theCurrentItemName == IGNORE_DIR_UP_NAME) {
return;
}
StString aCurrItemFullName = theSearchFolderPath + SYS_FS_SPLITTER + theCurrentItemName;
if(isFolder(aCurrItemFullName)) {
if(theDeep > 1) {
StFolder* aSubFolder = new StFolder(theCurrentItemName, this);
aSubFolder->init(theExtensions, theDeep - 1);
if(aSubFolder->size() > 0) {
add(aSubFolder);
} else {
// ignore empty folders
delete aSubFolder;
}
}
} else {
StString anItemExtension = StFileNode::getExtension(theCurrentItemName);
for(size_t anExt = 0; anExt < theExtensions.size(); ++anExt) {
if(anItemExtension.isEqualsIgnoreCase(theExtensions[anExt])) {
add(new StFileNode(theCurrentItemName, this));
break;
}
}
}
}
示例2: decodeHotKey
unsigned int decodeHotKey(const StString& theString) {
unsigned int aKey = 0;
if(theString.isEmpty()) {
return aKey;
}
// decode flags (split by + separator)
StUtf8Iter aFrom = theString.iterator();
StUtf8Iter anIter = theString.iterator();
for(; *anIter != 0; ++anIter) {
if(*anIter == stUtf32_t('+')) {
if(anIter.getIndex() == 0) {
return ST_VK_OEM_PLUS; // single '+'
}
const StCStringUtf8 aSubStr = {
aFrom.getBufferHere(),
size_t(anIter.getBufferHere() - aFrom.getBufferHere()),
anIter.getIndex() - aFrom.getIndex()
};
if(aSubStr.isEquals(THE_VKEYS_NAMES[ST_VK_SHIFT])) {
aKey |= ST_VF_SHIFT;
} else if(aSubStr.isEquals(THE_VKEYS_NAMES[ST_VK_CONTROL])) {
aKey |= ST_VF_CONTROL;
}
aFrom = anIter;
++aFrom;
}
}
// decode VKey itself
const StCStringUtf8 aSubStr = {
aFrom.getBufferHere(),
size_t(anIter.getBufferHere() - aFrom.getBufferHere()),
anIter.getIndex() - aFrom.getIndex()
};
if(aSubStr.Size == 1) {
// optimized code for letters
if(*aSubStr.String >= 'A'
&& *aSubStr.String <= 'Z') {
aKey |= (unsigned int )*aSubStr.String;
return aKey;
} else if(*aSubStr.String >= '0'
&& *aSubStr.String <= '9') {
aKey |= (unsigned int )*aSubStr.String;
return aKey;
}
}
for(unsigned int aKeyIter = 0; aKeyIter <= 223; ++aKeyIter) {
if(aSubStr.isEquals(THE_VKEYS_NAMES[aKeyIter])) {
aKey |= aKeyIter;
break;
}
}
return aKey;
}
示例3: getEnv
StString StProcess::getStCoreFolder() {
StString aCoreEnvValue = getEnv(ST_ENV_NAME_STCORE_PATH);
#ifdef _WIN32
if(aCoreEnvValue.isEmpty()) {
// read env. value directly from registry (before first log off / log in)
const StString aRegisterPath = "Environment";
loadStringFromRegister(aRegisterPath, ST_ENV_NAME_STCORE_PATH, aCoreEnvValue);
}
#endif
// repair filesystem splitter
if(!aCoreEnvValue.isEmpty() && !aCoreEnvValue.isEndsWith(SYS_FS_SPLITTER)) {
aCoreEnvValue += StString(SYS_FS_SPLITTER);
}
if(isValidStCorePath(aCoreEnvValue)) {
// environment variable is correctly set
return aCoreEnvValue;
}
const StString aProcessPath = getProcessFolder();
if(isValidStCorePath(aProcessPath)) {
return aProcessPath;
}
return StString();
}
示例4: anUrl
void StBrowserPlugin::streamAsFile(NPStream* theStream,
const char* theFileName) {
if(theFileName == NULL) {
///ST_DEBUG_LOG("streamAsFile ERROR");
return;
}
const StString anUrl((theStream->url != NULL) ? theStream->url : "");
const bool isPreview = !myPreviewUrl.isEmpty()
&& (anUrl.isEndsWith(myPreviewUrl) || anUrl.isEndsWith(myPreviewUrlUtf8));
StString aFileName = StString(theFileName);
StString aFolder, aDummy;
StFileNode::getFolderAndFile(aFileName, aFolder, aDummy);
if(aFileName.isStartsWith(StProcess::getTempFolder())) {
// Some browsers (Safari) returns file copies in temporary folder
// and imidiatly remove it after function execution.
// sView load image async, so we need to copy file until it will be read.
StString aFileNameNew = aFileName + ".sView.tmp";
if(StFileNode::moveFile(aFileName, aFileNameNew)) {
aFileName = aFileNameNew;
myTmpFiles.add(aFileName);
}
}
StMutexAuto aLock(myMutex);
if(isPreview) {
myPreviewPath = aFileName;
} else {
myFullPath = aFileName;
}
}
示例5: mySettingsSet
StSettings::StSettings(const StHandle<StResourceManager>& /*theResMgr*/,
const StString& theSettingsSet)
: mySettingsSet(theSettingsSet.toUtfWide()),
myRegisterPath(StStringUtfWide("SOFTWARE\\sView\\") + theSettingsSet.toUtfWide()),
myToFlush(false) {
//
}
示例6: main
int main(int , char** ) { // force console output
#else
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // prevent console output
#endif
setlocale(LC_ALL, ".OCP"); // we set default locale for console output (useful only for debug)
#else
int main(int , char** ) {
#endif
StOutPageFlip::initGlobalsAsync();
if(!StVersionInfo::checkTimeBomb("sView")) {
return 1;
}
// setup environment variables
const StString ST_ENV_NAME_STCORE_PATH =
#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
"StCore64";
#else
"StCore32";
#endif
const StString aProcessPath = StProcess::getProcessFolder();
StString aProcessUpPath = StFileNode::getFolderUp(aProcessPath);
if(!aProcessUpPath.isEmpty()) {
aProcessUpPath += SYS_FS_SPLITTER;
}
StProcess::setEnv(ST_ENV_NAME_STCORE_PATH, aProcessPath);
if(StFolder::isFolder(aProcessPath + "textures")) {
StProcess::setEnv("StShare", aProcessPath);
} else if(StFolder::isFolder(aProcessUpPath + "textures")) {
StProcess::setEnv("StShare", aProcessUpPath);
}
StString aResDir = StProcess::getStShareFolder();
StProcess::setEnv("CSF_UnitsLexicon", aResDir + "UnitsAPI" ST_FILE_SPLITTER "Lexi_Expr.dat");
StProcess::setEnv("CSF_UnitsDefinition", aResDir + "UnitsAPI" ST_FILE_SPLITTER "Units.dat");
StProcess::setEnv("CSF_ShadersDirectory", aResDir + "shaders" ST_FILE_SPLITTER "StCADViewer");
StProcess::setEnv("CSF_SHMessage", aResDir + "lang");
StProcess::setEnv("CSF_MDTVTexturesDirectory", aResDir + "textures");
StHandle<StOpenInfo> anInfo;
if(anInfo.isNull()
|| (!anInfo->hasPath() && !anInfo->hasArgs())) {
anInfo = StApplication::parseProcessArguments();
}
if(anInfo.isNull()) {
// show help
StString aShowHelpString = getAbout();
st::cout << aShowHelpString;
stInfo(aShowHelpString);
return 0;
}
StHandle<StResourceManager> aResMgr = new StResourceManager();
StHandle<StCADViewer> anApp = new StCADViewer(aResMgr, NULL, anInfo);
if(!anApp->open()) {
return 1;
}
return anApp->exec();
}
示例7: aMime
int StActiveXCtrl::OnCreate(LPCREATESTRUCT theCreateStruct) {
myBackBrush.CreateSolidBrush(RGB(0, 0, 0));
if(COleControl::OnCreate(theCreateStruct) == -1) {
return -1;
}
const StString ST_ASTERIX = '*';
StMIME aMime(StString(myMimeType), ST_ASTERIX, ST_ASTERIX);
myOpenInfo.setMIME(aMime);
StArgumentsMap aDrawerArgs;
const StString ST_SETTING_SRCFORMAT = stCString("srcFormat");
const StString ST_SETTING_COMPRESS = stCString("toCompress");
const StString ST_SETTING_ESCAPENOQUIT = stCString("escNoQuit");
const StMIME ST_MIME_X_JPS("image/x-jps", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_JPS ("image/jps", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_X_PNS("image/x-pns", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_PNS ("image/pns", ST_ASTERIX, ST_ASTERIX);
StArgument anArgSrcFormat = aDrawerArgs[ST_SETTING_SRCFORMAT];
if(!anArgSrcFormat.isValid()) {
anArgSrcFormat.setKey(ST_SETTING_SRCFORMAT);
if(aMime == ST_MIME_X_JPS
|| aMime == ST_MIME_JPS
|| aMime == ST_MIME_X_PNS
|| aMime == ST_MIME_PNS) {
anArgSrcFormat.setValue(st::formatToString(StFormat_SideBySide_RL));
aDrawerArgs.add(anArgSrcFormat);
}
}
aDrawerArgs.add(StArgument(ST_SETTING_COMPRESS, "true")); // optimize memory usage
aDrawerArgs.add(StArgument(ST_SETTING_ESCAPENOQUIT, "true")); // do not close plugin instance by Escape key
myOpenInfo.setArgumentsMap(aDrawerArgs);
// set window
myParentWin = m_hWnd;
// starts out plugin main loop in another thread
myThread = new StThread(stThreadFunction, (void* )this, "StActiveXCtrl");
// load URL
StString aFilePath = loadURL(myHasPreview ? myUrlPreview : myUrlFull);
if(aFilePath.isEmpty()) {
if(!myHasPreview) {
return 0;
}
if(myHasPreview) {
// if we have 2 URLs - try to load another one
aFilePath = loadURL(myUrlFull);
if(aFilePath.isEmpty()) {
return 0;
}
myHasPreview = false;
}
}
myOpenInfo.setPath(aFilePath);
myOpenEvent.set();
return 0;
}
示例8: getActionIdFromName
int StApplication::getActionIdFromName(const StString& theActionName) const {
StString aNameLower = theActionName;
aNameLower.toLowerCase();
const std::string aName(aNameLower.toCString());
std::map< std::string, int >::const_iterator anAction = myActionLookup.find(aName);
return anAction != myActionLookup.end()
? anAction->second
: -1;
}
示例9: size_t
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();
}
示例10: 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;
}
示例11: addAction
void StApplication::addAction(const int theActionId,
const StHandle<StAction>& theAction) {
myActions[theActionId] = theAction;
if(!theAction.isNull()) {
StString aNameLower = theAction->getName();
aNameLower.toLowerCase();
const std::string aName(aNameLower.toCString());
myActionLookup[aName] = theActionId;
}
}
示例12: nppInstance
StBrowserPlugin::StBrowserPlugin(NSPluginCreateData* theCreateDataStruct)
: nppInstance(theCreateDataStruct->instance),
myResMgr(new StResourceManager()),
myParentWin((StNativeWin_t )NULL),
#ifdef _WIN32
myProcOrig(NULL),
myBackBrush(CreateSolidBrush(RGB(0, 0, 0))),
#endif
myToLoadFull(false),
myIsActive(false),
myToQuit(false) {
if(ST_PLUGIN_INSTANCES.increment() == 1) {
StSearchMonitors aMonitors;
aMonitors.init(true); // force update of cached state
}
StArgumentsMap aDrawerArgs;
for(int aParamId = 0; aParamId < theCreateDataStruct->argc; ++aParamId) {
StString aParamName = StString(theCreateDataStruct->argn[aParamId]);
StString aParamValue = StString(theCreateDataStruct->argv[aParamId]);
StArgument stArg(aParamName, aParamValue);
aDrawerArgs.add(stArg);
if(aParamName.isEqualsIgnoreCase(stCString("data-prv-url"))) {
myPreviewUrl = aParamValue;
myPreviewUrlUtf8.fromUrl(aParamValue);
}
}
const StString ST_ASTERIX = '*';
StMIME stMIME(StString(theCreateDataStruct->type), ST_ASTERIX, ST_ASTERIX);
myOpenInfo.setMIME(stMIME);
const StString ST_SETTING_SRCFORMAT = stCString("srcFormat");
const StString ST_SETTING_COMPRESS = stCString("toCompress");
const StString ST_SETTING_ESCAPENOQUIT = stCString("escNoQuit");
const StMIME ST_MIME_X_JPS("image/x-jps", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_JPS ("image/jps", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_X_PNS("image/x-pns", ST_ASTERIX, ST_ASTERIX);
const StMIME ST_MIME_PNS ("image/pns", ST_ASTERIX, ST_ASTERIX);
StArgument anArgSrcFormat = aDrawerArgs[ST_SETTING_SRCFORMAT];
if(!anArgSrcFormat.isValid()) {
anArgSrcFormat.setKey(ST_SETTING_SRCFORMAT);
if(stMIME == ST_MIME_X_JPS
|| stMIME == ST_MIME_JPS
|| stMIME == ST_MIME_X_PNS
|| stMIME == ST_MIME_PNS) {
anArgSrcFormat.setValue(st::formatToString(StFormat_SideBySide_RL));
aDrawerArgs.add(anArgSrcFormat);
}
}
aDrawerArgs.add(StArgument(ST_SETTING_COMPRESS, "true")); // optimize memory usage
aDrawerArgs.add(StArgument(ST_SETTING_ESCAPENOQUIT, "true")); // do not close plugin instance by Escape key
myOpenInfo.setArgumentsMap(aDrawerArgs);
}
示例13: saveString
bool StSettings::saveString(const StString& theParam,
const StString& theValue) {
StRegKey aKey;
if(!aKey.create(myRegisterPath)) {
return false; // No write registry success!
}
StStringUtfWide aValue = theValue.toUtfWide();
return RegSetValueExW(aKey, theParam.toUtfWide().toCString(), 0,
REG_SZ, (LPBYTE )aValue.toCString(), DWORD(aValue.getSize() + sizeof(stUtfWide_t))) == ERROR_SUCCESS;
}
示例14: 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
}
示例15: getProcessFullPath
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;
}
}