本文整理汇总了C++中StringBuffer::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::clear方法的具体用法?C++ StringBuffer::clear怎么用?C++ StringBuffer::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doSendEmail
static void doSendEmail(CMailInfo & info, CMailPart const & part)
{
info.open();
StringBuffer outbuff;
info.read();
info.getHelo(outbuff);
info.write(outbuff.str(), outbuff.length());
info.read();
info.getMailFrom(outbuff.clear());
info.write(outbuff.str(), outbuff.length());
info.read();
unsigned numRcpt = info.numRecipients();
for(unsigned i=0; i<numRcpt; ++i)
{
info.getRecipient(i, outbuff.clear());
info.write(outbuff.str(), outbuff.length());
info.read();
}
info.write(data, strlen(data));
info.read();
info.getHeader(outbuff.clear());
part.getHeader(outbuff);
outbuff.append("\r\n");
info.write(outbuff.str(), outbuff.length(), "mail header");
part.write(info);
info.write(endMail, strlen(endMail), "end of mail body");
info.read();
info.write(quit, strlen(quit));
info.read();
}
示例2: build_globals
bool build_globals(int argc, const char *argv[], IProperties * globals)
{
int i;
for(i = 0; i < argc; i++)
{
if(argv[i] != NULL && argv[i][0] == '@' && argv[i][1] != '\0')
{
globals->loadFile(argv[i]+1);
}
}
for (i = 1; i < argc; i++)
{
if (strchr(argv[i],'='))
{
globals->loadProp(argv[i]);
}
}
StringBuffer tmp;
if(globals->hasProp("encrypt")) {
encrypt(tmp.clear(),globals->queryProp("encrypt") ); // basic encryption at this stage
globals->setProp("encrypt",tmp.str());
}
if(globals->hasProp("decrypt")) {
encrypt(tmp.clear(),globals->queryProp("decrypt") ); // basic encryption at this stage
globals->setProp("decrypt",tmp.str());
}
return true;
}
示例3: ForEach
CWsMachineSoapBindingEx::CWsMachineSoapBindingEx(IPropertyTree* cfg,
const char *bindname/*=NULL*/,
const char *procname/*=NULL*/)
:Cws_machineSoapBinding(cfg, bindname, procname)
{
StringBuffer xpath;
xpath.appendf("Software/EspProcess[@name=\"%s\"]", procname);
IPropertyTree* pEspProcess = cfg->queryPropTree(xpath.str());
if (pEspProcess)
{
xpath.clear().appendf("EspBinding[@name=\"%s\"]/@service", bindname);
const char* service = pEspProcess->queryProp(xpath.str());
if (service)
{
xpath.clear().appendf("EspService[@name=\"%s\"]/MachineInfo/Software/*", service);
Owned<IPropertyTreeIterator> it = pEspProcess->getElements(xpath.str());
ForEach(*it)
{
m_processTypes.append(it->query().queryName());
}
m_processTypes.sort(SortFunction);
}
}
}
示例4: add
unsigned SWBackupNode::add(IPropertyTree *params)
{
unsigned rc = SWProcess::add(params);
IPropertyTree * envTree = m_envHelper->getEnvTree();
const char* key = params->queryProp("@key");
StringBuffer xpath;
xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key);
IPropertyTree * compTree = envTree->queryPropTree(xpath.str());
assert(compTree);
const char* selector = params->queryProp("@selector");
if (selector && !stricmp("NodeGroup", selector))
{
IPropertyTree *nodeGroup = createPTree(selector);
IPropertyTree* pAttrs = params->queryPropTree("Attributes");
updateNode(nodeGroup, pAttrs, NULL);
if (!nodeGroup->hasProp("@interval"))
{
xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default");
const char *interval = m_pSchema->queryProp(xpath.str());
if ( interval && *interval )
{
nodeGroup->addProp("@interval", interval);
}
else
{
throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam,
"Missing required paramter \"interval\" and there is no default value.");
}
}
compTree->addPropTree(selector, nodeGroup);
}
return rc;
}
示例5:
IPropertyTree * SWProcess::getPortDefinition()
{
StringBuffer xpath;
xpath.clear().appendf("xs:element[@name=\"%s\"]", m_instanceElemName.str());
IPropertyTree * instanceNode = m_pSchema->queryPropTree(xpath.str());
if (!instanceNode) return NULL;
xpath.clear().append("xs:attribute[@name=\"port\"]");
return instanceNode->queryPropTree(xpath.str());
}
示例6: getValue
inline LPCSTR getValue() const
{
static StringBuffer buf;
if(isBinary())
buf.clear().append(binaryValue);
else
pTree->getProp(name, buf.clear());
return buf.toCharArray();
}
示例7: write
virtual void write()
{
StringBuffer rowTag;
OwnedRoxieString xmlpath(helper->getXmlIteratorPath());
if (!xmlpath)
{
rowTag.append("Row");
}
else
{
const char *path = xmlpath;
if (*path == '/') path++;
if (strchr(path, '/')) UNIMPLEMENTED;
rowTag.append(path);
}
StringBuffer xmlOutput;
CommonXmlWriter xmlWriter(helper->getXmlFlags());
if (!dlfn.isExternal() || firstNode()) // if external, 1 header,footer
{
OwnedRoxieString header(helper->getHeader());
if (header)
xmlOutput.clear().append(header);
else
xmlOutput.clear().append("<Dataset>").newline();
outraw->write(xmlOutput.length(), xmlOutput.toCharArray());
if (calcFileCrc)
fileCRC.tally(xmlOutput.length(), xmlOutput.toCharArray());
}
while(!abortSoon)
{
OwnedConstThorRow row = input->ungroupedNextRow();
if (!row)
break;
xmlWriter.clear().outputBeginNested(rowTag, false);
helper->toXML((const byte *)row.get(), xmlWriter);
xmlWriter.outputEndNested(rowTag);
outraw->write(xmlWriter.length(), xmlWriter.str());
if (calcFileCrc)
fileCRC.tally(xmlWriter.length(), xmlWriter.str());
processed++;
}
if (!dlfn.isExternal() || lastNode()) // if external, 1 header,footer
{
OwnedRoxieString footer(helper->getFooter());
if (footer)
xmlOutput.clear().append(footer);
else
xmlOutput.clear().append("</Dataset>").newline();
outraw->write(xmlOutput.length(), xmlOutput.toCharArray());
if (calcFileCrc)
fileCRC.tally(xmlOutput.length(), xmlOutput.toCharArray());
}
}
示例8: getInstanceCount
unsigned SWProcess::getInstanceCount(const char* clusterName)
{
StringBuffer xpath;
if (clusterName && *clusterName)
xpath.clear().appendf("%s[@name=\"%s\"]", m_processName.str(), clusterName);
else
xpath.clear().appendf("%s[1]", m_processName.str());
//IPropertyTree * comp = m_envHelper->getEnvTree()->getPropTree(xpath);
IPropertyTree * comp = m_envHelper->getEnvTree()->queryPropTree(xpath);
return comp->getCount(m_instanceElemName.str());
}
示例9: logException
void RemoteXmlEclRepository::logException(IException *e)
{
if (e)
{
e->errorMessage(lastError.clear());
}
else
{
lastError.clear().append("Unknown exception");
}
DBGLOG("Log Exception: %s", lastError.str());
}
示例10: deletePkgInfo
bool deletePkgInfo(const char *name, const char *target, const char *process, bool globalScope)
{
Owned<IRemoteConnection> pkgSetsConn = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
if (!pkgSetsConn)
throw MakeStringException(PKG_NONE_DEFINED, "No package sets defined");
IPropertyTree* packageSets = pkgSetsConn->queryRoot();
StringBuffer pkgSetId;
buildPkgSetId(pkgSetId, process);
VStringBuffer pkgSet_xpath("PackageSet[@id='%s']", pkgSetId.str());
IPropertyTree *pkgSetRegistry = packageSets->queryPropTree(pkgSet_xpath.str());
if (!pkgSetRegistry)
throw MakeStringException(PKG_TARGET_NOT_DEFINED, "No package sets defined for %s", process);
StringBuffer lcTarget(target);
target = lcTarget.toLowerCase().str();
StringBuffer lcName(name);
name = lcName.toLowerCase().str();
Owned<IPropertyTree> mapEntry;
StringBuffer xpath;
if (!globalScope)
{
xpath.appendf("PackageMap[@id='%s::%s'][@querySet='%s']", target, name, target);
mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str()));
}
if (!mapEntry)
{
xpath.clear().appendf("PackageMap[@id='%s'][@querySet='%s']", name, target);
mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str()));
if (!mapEntry)
throw MakeStringException(PKG_DELETE_NOT_FOUND, "Unable to delete %s - information not found", lcName.str());
}
StringAttr pmid(mapEntry->queryProp("@id"));
pkgSetRegistry->removeTree(mapEntry);
xpath.clear().appendf("PackageSet/PackageMap[@id='%s']", pmid.get());
if (!packageSets->hasProp(xpath))
{
Owned<IRemoteConnection> pkgMapsConn = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
if (!pkgMapsConn)
throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]");
IPropertyTree *pkgMaps = pkgMapsConn->queryRoot();
if (!pkgMaps)
throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]");
IPropertyTree *mapTree = pkgMaps->queryPropTree(xpath.clear().appendf("PackageMap[@id='%s']", pmid.get()).str());
if (mapTree)
pkgMaps->removeTree(mapTree);
}
return true;
}
示例11: 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());
}
}
示例12: getPluginDirectory
//---------------------------------------------------------------------------
// getPluginDirectory
//
// returns absolute path where plugins are to be deployed
//---------------------------------------------------------------------------
void CPluginDeploymentEngine::getPluginDirectory(const char* destPath, StringBuffer& sPluginDest) const
{
sPluginDest.clear().append(destPath);
sPluginDest.replace('\\', '/');
StringBuffer sPluginsDir; //relative path (from ECL server installation directory) for plugins
m_process.getProp("@pluginsPath", sPluginsDir);
if (sPluginsDir.length())
{
sPluginsDir.replace('\\', '/');
sPluginsDir.replace('$', ':');
if (! ::PathIsRelative(sPluginsDir.str()))
throw MakeStringExceptionDirect(-1, "Plugins path for ECL server must be relative to its installation directory!");
if (!strncmp(sPluginsDir.str(), "./", 2))
sPluginsDir.remove(0, 2);
sPluginDest.append(sPluginsDir);
}
const char* pchLast = sPluginDest.str() + sPluginDest.length() - 1;
if (*pchLast != '/')
sPluginDest.append('/');
}
示例13: getpassword
void getpassword(const char* prompt, StringBuffer& passwd, bool verify = true)
{
passwd.clear();
StringBuffer passwd1, passwd2;
int tries = 0;
while(1)
{
if(tries++ >= 3)
{
exit(-1);
}
inputpassword(prompt, passwd1);
if(!verify)
break;
inputpassword("Verifying password, retype: ", passwd2);
if(passwd1.length() < 4)
{
printf("password too short, should be 4 characters or longer\n");
}
else if(strcmp(passwd1.str(), passwd2.str()) != 0)
{
printf("passwords don't match.\n");
}
else
break;
}
passwd.append(passwd1.str());
}
示例14: modify
void SWProcess::modify(IPropertyTree *params)
{
SWComponentBase::modify(params);
const char * selector = params->queryProp("@selector");
if ( selector )
{
IPropertyTree * envTree = m_envHelper->getEnvTree();
const char* key = params->queryProp("@key");
StringBuffer xpath;
xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key);
IPropertyTree * compTree = envTree->queryPropTree(xpath.str());
if (!compTree)
throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Selector should matche one element in modify.");
String str(selector);
if (str.startsWith("instance"))
modifyInstance(compTree, params);
return;
}
if (!(params->queryPropTree("Attributes/Attribute[@name=\"name\"]"))) return;
//notify topoploy for component name change
const char *oldName = params->queryProp("@key");
const char *newName = params->queryProp("Attributes/Attribute[@name=\"name\"]/@value");
if (m_notifyTopologyList.find(m_name.str()) != NotFound)
{
((SWProcess*)m_envHelper->getEnvSWComp("topology"))->processNameChanged(m_name.str(), newName, oldName);
}
}
示例15: while
_LUCENE_THREAD_FUNC(atomicIndexTest, _writer){
IndexWriter* writer= (IndexWriter*)_writer;
uint64_t stopTime = Misc::currentTimeMillis() + 1000*ATOMIC_SEARCH_RUN_TIME_SEC;
int count = 0;
try {
while(Misc::currentTimeMillis() < stopTime && !atomicSearchFailed) {
// Update all 100 docs...
TCHAR buf[30];
StringBuffer sb;
for(int i=0; i<100; i++) {
Document d;
_i64tot(rand(), buf, 10);
sb.clear();
English::IntToEnglish(i+10*count, &sb);
d.add(*_CLNEW Field(_T("contents"), sb.getBuffer() , Field::STORE_NO | Field::INDEX_TOKENIZED));
_i64tot(i,buf,10);
d.add(*_CLNEW Field(_T("id"), buf, Field::STORE_YES | Field::INDEX_UNTOKENIZED));
Term* t = _CLNEW Term(_T("id"), buf);
writer->updateDocument(t, &d);
_CLDECDELETE(t);
}
count++;
}
} catch (CLuceneError& e) {
fprintf(stderr, "err 1: #%d: %s\n", e.number(), e.what());
atomicSearchFailed = true;
}
_LUCENE_THREAD_FUNC_RETURN(0);
}