本文整理汇总了C++中StringBuffer::replaceString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::replaceString方法的具体用法?C++ StringBuffer::replaceString怎么用?C++ StringBuffer::replaceString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::replaceString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFakePlugins
void CConfigGenEngine::createFakePlugins(StringBuffer& destFilePath) const
{
String destFilePathStr(destFilePath);
String* tmpstr = destFilePathStr.toLowerCase();
if (!tmpstr->endsWith("plugins.xml"))
{
int index = tmpstr->indexOf("plugins.xml");
destFilePath.remove(index + 11, destFilePath.length() - (index + 11));
}
delete tmpstr;
StringBuffer tmpoutbuf("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Plugins/>");
if (m_instances.ordinality() > 1 && strcmp(m_process.queryName(), XML_TAG_ESPPROCESS))
destFilePath.replaceString("@temp"PATHSEPSTR, m_cachePath);
else
{
char tempPath[_MAX_PATH];
getTempPath(tempPath, sizeof(tempPath), m_name);
ensurePath(tempPath);
destFilePath.replaceString("@temp"PATHSEPSTR, tempPath);
}
Owned<IFile> pTargetFile = createIFile(destFilePath.str());
if (pTargetFile->exists() && pTargetFile->isReadOnly())
pTargetFile->setReadOnly(false);
Owned<IFileIO> pTargetFileIO = pTargetFile->open(IFOcreate);
pTargetFileIO->write( 0, tmpoutbuf.length(), tmpoutbuf.str());
m_envDepEngine.addTempFile(destFilePath.str());
}
示例2: addUpdateAttributesFromString
void CEnvGen::addUpdateAttributesFromString(IPropertyTree *updateTree, const char *attrs)
{
StringArray saAttrs;
saAttrs.appendList(attrs, ATTR_SEP);
//printf("attribute: %s\n",attrs);
IPropertyTree *pAttrs = updateTree->addPropTree("Attributes", createPTree("Attributes"));
for ( unsigned i = 0; i < saAttrs.ordinality() ; i++)
{
IPropertyTree *pAttr = pAttrs->addPropTree("Attribute", createPTree("Attribute"));
StringArray keyValues;
keyValues.appendList(saAttrs[i], "=");
pAttr->addProp("@name", keyValues[0]);
StringBuffer sbValue;
sbValue.clear().appendf("%s", keyValues[1]);
sbValue.replaceString("[equal]", "=");
StringArray newOldValues;
if (strcmp(keyValues[1], ""))
{
newOldValues.appendList(sbValue.str(), ATTR_V_SEP);
pAttr->addProp("@value", newOldValues[0]);
if (newOldValues.ordinality() > 1) pAttr->addProp("@oldValue", newOldValues[1]);
}
else
pAttr->addProp("@value", "");
}
}
示例3: MakeStringException
const StringBuffer &CEspApplicationPort::getAppFrameHtml(time_t &modified, const char *inner, StringBuffer &html, IEspContext* ctx)
{
if (!xslp)
throw MakeStringException(0,"Error - CEspApplicationPort XSLT processor not initialized");
bool embedded_url=(inner&&*inner);
StringBuffer params;
bool needRefresh = true;
if (!getUrlParams(ctx->queryRequestParameters(), params))
{
if (params.length()==0)
needRefresh = false;
if (ctx->getClientVersion()>0)
{
params.appendf("%cver_=%g", params.length()?'&':'?', ctx->getClientVersion());
needRefresh = true;
}
}
if (needRefresh || embedded_url || !appFrameHtml.length())
{
int passwordDaysRemaining = scPasswordExpired;//-1 means dont display change password screen
#ifdef _USE_OPENLDAP
ISecUser* user = ctx->queryUser();
ISecManager* secmgr = ctx->querySecManager();
if(user && secmgr)
{
passwordDaysRemaining = user->getPasswordDaysRemaining();//-1 if expired, -2 if never expires
int passwordExpirationDays = (int)secmgr->getPasswordExpirationWarningDays();
if (passwordDaysRemaining == scPasswordNeverExpires || passwordDaysRemaining > passwordExpirationDays)
passwordDaysRemaining = scPasswordExpired;
}
#endif
StringBuffer xml;
StringBuffer encoded_inner;
if(inner && *inner)
encodeXML(inner, encoded_inner);
// replace & with &s;
params.replaceString("&","&");
xml.appendf("<EspApplicationFrame title=\"%s\" navWidth=\"%d\" navResize=\"%d\" navScroll=\"%d\" inner=\"%s\" params=\"%s\" passwordDays=\"%d\"/>",
getESPContainer()->getFrameTitle(), navWidth, navResize, navScroll, (inner&&*inner) ? encoded_inner.str() : "?main", params.str(), passwordDaysRemaining);
Owned<IXslTransform> xform = xslp->createXslTransform();
xform->loadXslFromFile(StringBuffer(getCFD()).append("./xslt/appframe.xsl").str());
xform->setXmlSource(xml.str(), xml.length()+1);
xform->transform( (needRefresh || embedded_url) ? html.clear() : appFrameHtml.clear());
}
if (!needRefresh && !embedded_url)
html.clear().append(appFrameHtml.str());
static time_t startup_time = time(NULL);
modified = startup_time;
return html;
}
示例4: checkInstanceAttributes
void SWProcess::checkInstanceAttributes(IPropertyTree *instanceNode, IPropertyTree *parent)
{
assert(instanceNode);
if (portIsRequired() && !instanceNode->hasProp("@port"))
{
int port = getDefaultPort();
if (!port)
throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss port attribute in instance");
instanceNode->addPropInt("@port", port);
}
StringBuffer xpath;
xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"%s\"]",m_instanceElemName.str());
IPropertyTree * instanceSchemaNode = m_pSchema->queryPropTree(xpath.str());
if (!instanceSchemaNode) return;
bool needDirProp = false;
Owned<IPropertyTreeIterator> attrIter = instanceSchemaNode->getElements("xs:complexType/xs:attribute");
ForEach(*attrIter)
{
IPropertyTree * attr = &attrIter->query();
const char *attrName = attr->queryProp("@name");
if (!stricmp(attrName, "directory"))
{
needDirProp = true;
continue;
}
const char *defaultValue = attr->queryProp("@default");
if (!defaultValue) continue;
xpath.clear().appendf("@%s", attrName);
if (instanceNode->hasProp(xpath.str())) continue;
const char *use = attr->queryProp("@use");
if (!use || !stricmp(use, "required") || !stricmp(use, "optional"))
{
StringBuffer sbDefaultValue;
sbDefaultValue.clear().append(defaultValue);
sbDefaultValue.replaceString("\\", "\\\\");
instanceNode->addProp(xpath.str(), sbDefaultValue.str());
}
}
if (needDirProp && !instanceNode->hasProp("@directory"))
{
const IProperties *props = m_envHelper->getEnvConfigOptions().getProperties();
StringBuffer sb;
sb.clear().appendf("%s/%s",
props->queryProp("runtime"), parent->queryProp(XML_ATTR_NAME));
instanceNode->addProp("@directory", sb.str());
}
}
示例5: doSetCompilerPath
static void doSetCompilerPath(const char * path, const char * includes, const char * libs, const char * tmpdir, unsigned targetCompiler, bool verbose)
{
if (!includes)
includes = INCLUDEPATH[targetCompiler];
if (!libs)
libs = LIB_DIR[targetCompiler];
if (verbose)
{
PrintLog("Include directory set to %s", includes);
PrintLog("Library directory set to %s", libs);
}
compilerRoot.set(path ? path : targetCompiler==GccCppCompiler ? "/usr" : ".\\CL");
stdIncludes.set(includes);
stdLibs.clear();
for (;;)
{
StringBuffer thislib;
while (*libs && *libs != ENVSEPCHAR)
thislib.append(*libs++);
if (thislib.length())
{
stdLibs.append(" ").append(USE_LIBPATH_FLAG[targetCompiler]).append(thislib).append(USE_LIBPATH_TAIL[targetCompiler]);
if (USE_LIBRPATH_FLAG[targetCompiler])
stdLibs.append(" ").append(USE_LIBRPATH_FLAG[targetCompiler]).append(thislib);
}
if (!*libs)
break;
libs++;
}
StringBuffer fname;
if (path)
{
const char *finger = CC_NAME[targetCompiler];
while (*finger)
{
if (*finger == '#')
fname.append(path);
else
fname.append(*finger);
finger++;
}
#if defined(__linux__)
StringBuffer clbin_dir;
const char* dir_end = strrchr(fname, '/');
if(dir_end == NULL)
clbin_dir.append(".");
else
clbin_dir.append((dir_end - fname.str()) + 1, fname.str());
StringBuffer pathenv(clbin_dir.str());
const char* oldpath = getenv("PATH");
if(oldpath != NULL && *oldpath != '\0')
pathenv.append(":").append(oldpath);
setenv("PATH", pathenv.str(), 1);
#endif
}
else
{
fname.append(compilerRoot).append(CC_NAME[targetCompiler]);
fname.replaceString("#",NULL);
}
if (verbose)
PrintLog("Compiler path set to %s", fname.str());
dequote(fname);
#ifdef _WIN32
if (_access(fname.str(), 4))
{
#else
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
struct stat filestatus;
int r = stat(fname.str(), &filestatus);
if ( (r != 0)
|| (!S_ISREG(filestatus.st_mode))
|| ((filestatus.st_mode&(S_IXOTH|S_IXGRP|S_IXUSR))==0))
{
if (r == -1) errno = ENOENT;
#endif
#endif
if (verbose)
PrintLog("SetCompilerPath - no compiler found");
throw makeOsExceptionV(GetLastError(), "setCompilerPath could not locate compiler %s", fname.str());
}
if(tmpdir && *tmpdir)
{
//MORE: this should be done for the child process instead of the parent but invoke does not let me do it
#if defined(__linux__)
setenv("TMPDIR", tmpdir, 1);
#endif
#ifdef _WIN32
StringBuffer tmpbuf;
tmpbuf.append("TMP=").append(tmpdir);
_putenv(tmpbuf.str());
#endif
}
}
//.........这里部分代码省略.........