本文整理汇总了C++中StringBuffer::append方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::append方法的具体用法?C++ StringBuffer::append怎么用?C++ StringBuffer::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::append方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toString
void SQLParameterPlaceHolderExpression::toString(StringBuffer & targetstr, bool fullOutput)
{
targetstr.append(value.str());
}
示例2: toECLStringTranslateSource
void SQLBinaryExpression::toECLStringTranslateSource(
StringBuffer & eclStr,
IProperties * map,
bool ignoreMisTranslations,
bool forHaving,
bool funcParam,
bool countFuncParam)
{
StringBuffer translation1;
StringBuffer translation2;
operand1->toECLStringTranslateSource(translation1, map, ignoreMisTranslations, forHaving, false, false);
operand2->toECLStringTranslateSource(translation2, map, ignoreMisTranslations, forHaving, false, false);
if (translation1.length()>0 && translation2.length()>0)
{
eclStr.append(translation1);
eclStr.append(getOpStr());
eclStr.append(translation2);
}
else if (translation1.length()<0 && translation2.length()<0)
{
return;
}
else if (ignoreMisTranslations)
{
/*
* If operand1 or operand2 could not be translated using the translation map,
* and ignoreMisTranslations = true, we're going to attempt to return an valid
* ECL translation of this binary expression. IF the binary expression is of type
* OR | AND, we can substitute the mistranslated operand with the appropriate boolean value
* to complete the expression with out changing the gist of the expression.
*
* This is typically done when converting an SQL 'WHERE' clause or 'ON' clause to ECL to
* be used in an ECL JOIN function. In any one particular ECL Join funtion only two datasets
* are joined, therefore not all portions of the SQL logic clause might be relevant.
*
*/
if (op == OR_SYM || op == AND_SYM)
{
StringBuffer convert( op == OR_SYM ? "FALSE" : "TRUE");
if (translation1.length()>0)
{
WARNLOG("Operand 1 of binary expression could not be translated.");
eclStr.append(translation1);
eclStr.append(getOpStr());
eclStr.append(convert);
}
else
{
WARNLOG("Operand 2 of binary expression could not be translated.");
eclStr.append(convert);
eclStr.append(getOpStr());
eclStr.append(translation2);
}
}
else
{
WARNLOG("Binary expression could not be translated.");
return;
}
}
else
{
WARNLOG("Binary expression could not be translated.");
return;
}
}
示例3: reserialize
void reserialize(VariableUnserializer *uns, StringBuffer &buf) {
char type = uns->readChar();
char sep = uns->readChar();
if (type == 'N') {
buf.append(type);
buf.append(sep);
return;
}
switch (type) {
case 'r':
case 'R':
case 'b':
case 'i':
case 'd':
{
buf.append(type);
buf.append(sep);
while (uns->peek() != ';') {
char ch;
ch = uns->readChar();
buf.append(ch);
}
}
break;
case 'S':
case 'A':
{
// shouldn't happen, but keep the code here anyway.
buf.append(type);
buf.append(sep);
char pointer[8];
uns->read(pointer, 8);
buf.append(pointer, 8);
}
break;
case 's':
{
String v;
v.unserialize(uns);
assert(!v.isNull());
if (v->isStatic()) {
union {
char pointer[8];
StringData *sd;
} u;
u.sd = v.get();
buf.append("S:");
buf.append(u.pointer, 8);
buf.append(';');
} else {
buf.append("s:");
buf.append(v.size());
buf.append(":\"");
buf.append(v.data(), v.size());
buf.append("\";");
}
sep = uns->readChar();
return;
}
break;
case 'a':
{
buf.append("a:");
int64_t size = uns->readInt();
char sep2 = uns->readChar();
buf.append(size);
buf.append(sep2);
sep2 = uns->readChar();
buf.append(sep2);
for (int64_t i = 0; i < size; i++) {
reserialize(uns, buf); // key
reserialize(uns, buf); // value
}
sep2 = uns->readChar(); // '}'
buf.append(sep2);
return;
}
break;
case 'o':
case 'O':
{
buf.append(type);
buf.append(sep);
String clsName;
clsName.unserialize(uns);
buf.append(clsName.size());
buf.append(":\"");
buf.append(clsName.data(), clsName.size());
buf.append("\":");
uns->readChar();
int64_t size = uns->readInt();
char sep2 = uns->readChar();
buf.append(size);
buf.append(sep2);
//.........这里部分代码省略.........
示例4: rewriteURL
bool VirtualHost::rewriteURL(CStrRef host, String &url, bool &qsa,
int &redirect) const {
String normalized = url;
if (normalized.empty() || normalized.charAt(0) != '/') {
normalized = String("/") + normalized;
}
for (unsigned int i = 0; i < m_rewriteRules.size(); i++) {
const RewriteRule &rule = m_rewriteRules[i];
bool passed = true;
for (vector<RewriteCond>::const_iterator it = rule.rewriteConds.begin();
it != rule.rewriteConds.end(); ++it) {
String subject;
if (it->type == RewriteCond::Request) {
subject = normalized;
} else {
subject = host;
}
Variant ret = preg_match(String(it->pattern.c_str(), it->pattern.size(),
AttachLiteral), subject);
if (!ret.same(it->negate ? 0 : 1)) {
passed = false;
break;
}
}
if (!passed) continue;
Variant matches;
int count = preg_match(rule.pattern.c_str(), normalized, matches);
if (count > 0) {
const char *s = rule.to.c_str();
StringBuffer ret;
while (*s) {
int backref = -1;
if (*s == '\\') {
if ('0' <= s[1] && s[1] <= '9') {
s++;
backref = get_backref(&s);
} else if (s[1] == '\\') {
s++;
}
} else if (*s == '$') {
if (s[1] == '{') {
const char *t = s+2;
if ('0' <= *t && *t <= '9') {
backref = get_backref(&t);
if (*t != '}') {
backref = -1;
} else {
s = t+1;
}
}
} else if ('0' <= s[1] && s[1] <= '9') {
s++;
backref = get_backref(&s);
}
}
if (backref >= 0) {
String br = matches[backref].toString();
if (rule.encode_backrefs) {
br = StringUtil::UrlEncode(br);
}
ret.append(br);
} else {
ret.append(s, 1);
s++;
}
}
url = ret.detach();
qsa = rule.qsa;
redirect = rule.redirect;
return true;
}
}
return false;
}
示例5: determineInstallFiles
//---------------------------------------------------------------------------
// determineInstallFiles
//---------------------------------------------------------------------------
int CConfigGenEngine::determineInstallFiles(IPropertyTree& processNode, CInstallFiles& installFiles) const
{
try
{
m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL,
"Determining files to install for %s", processNode.queryProp("@name"));
StringBuffer compListPath(CONFIGGEN_COMP_LIST);
if (m_inDir.length())
compListPath.clear().append(m_inDir).append(PATHSEPCHAR).append(CONFIGGEN_COMP_LIST);
Owned<IPropertyTree> deployNode = createPTreeFromXMLFile(compListPath.str(), ipt_caseInsensitive);
StringBuffer srcFilePath;
srcFilePath.ensureCapacity(_MAX_PATH);
const bool bFindStartable = &m_process == &processNode && m_startable == unknown;
const bool bFindStoppable = &m_process == &processNode && m_stoppable == unknown;
StringBuffer xpath;
xpath.appendf("Component[@name=\"%s\"]",processNode.queryProp("@buildSet"));
IPropertyTree* pComponent = deployNode->queryPropTree(xpath.str());
if (!pComponent)
{
m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL,
"Cannot find files to install for %s", processNode.queryProp("@buildSet"));
return 0;
}
Owned<IPropertyTreeIterator> iter = pComponent->getElements("File");
ForEach(*iter)
{
IPropertyTree* pFile = &iter->query();
const char* name = pFile->queryProp("@name");
if (!stricmp(name, "deploy_map.xml"))
continue;
if (bFindStartable && !strnicmp(name, "startup", sizeof("startup")-1))
m_startable = yes;
if (bFindStoppable && !strnicmp(name, "stop", sizeof("stop")-1))
m_stoppable = yes;
const char* method = pFile->queryProp("@method");
if (method && !stricmp(method, "schema"))
continue;
//if we are not deploying build files and method is copy then ignore this file
if (!(m_deployFlags & DEFLAGS_BUILDFILES) && (!method || !stricmp(method, "copy")))
continue;
const char* srcPath = pFile->queryProp("@srcPath");
const char* destPath= pFile->queryProp("@destPath");
const char* destName= pFile->queryProp("@destName");
bool bCacheable = pFile->getPropBool("@cache", false);
// Get source filespec
if (srcPath && !strcmp(srcPath, "@temp"))
{
char tempfile[_MAX_PATH];
getTempPath(tempfile, sizeof(tempfile), m_name);
srcFilePath.clear().append(tempfile).append(name);
}
else
{
srcFilePath.clear().append(m_inDir);
//adjust source paths
if (srcPath && 0!=strcmp(srcPath, "."))
{
if (!strncmp(srcPath, "..", 2) && (*(srcPath+2)=='/' || *(srcPath+2)=='\\'))
{
StringBuffer reldir(srcPath);
reldir.replace('/', '\\');
while (!strncmp(reldir.str(), "..\\", 3))
{
srcFilePath.setLength( srcFilePath.length() - 1 ); //remove last char PATHSEPCHAR
const char* tail = pathTail(srcFilePath.str());
srcFilePath.setLength( tail - srcFilePath.str() );
reldir.remove(0, 3);
}
srcFilePath.append(reldir).append(PATHSEPCHAR);
}
else
srcFilePath.append(srcPath).append(PATHSEPCHAR);
}
srcFilePath.append(name);
}
std::string sDestName;
if (method && (!stricmp(method, "esp_service_module") || !stricmp(method, "esp_plugin")))
{
//if this is xsl transformation and we are not generating config files then ignore
//
if (!(m_deployFlags & DEFLAGS_CONFIGFILES) && !stricmp(method, "esp_service_module"))
continue;
//.........这里部分代码省略.........
示例6: doSendQuery
int doSendQuery(const char * ip, unsigned port, const char * base)
{
ISocket * socket;
__int64 starttime, endtime;
StringBuffer ipstr;
try
{
if (strcmp(ip, ".")==0)
ip = GetCachedHostName();
else
{
const char *dash = strchr(ip, '-');
if (dash && isdigit(dash[1]) && dash>ip && isdigit(dash[-1]))
{
if (persistConnections)
UNIMPLEMENTED;
const char *startrange = dash-1;
while (isdigit(startrange[-1]))
startrange--;
char *endptr;
unsigned firstnum = atoi(startrange);
unsigned lastnum = strtol(dash+1, &endptr, 10);
if (lastnum > firstnum)
{
static unsigned counter;
static CriticalSection counterCrit;
CriticalBlock b(counterCrit);
ipstr.append(startrange - ip, ip).append((counter++ % (lastnum+1-firstnum)) + firstnum).append(endptr);
ip = ipstr.str();
printf("Sending to %s\n", ip);
}
}
}
starttime= get_cycles_now();
if (persistConnections)
{
if (!persistSocket) {
SocketEndpoint ep(ip,port);
persistSocket = ISocket::connect_timeout(ep, 1000);
}
socket = persistSocket;
}
else {
SocketEndpoint ep(ip,port);
socket = ISocket::connect_timeout(ep,1000);
}
}
catch(IException * e)
{
pexception("failed to connect to server", e);
return 1;
}
StringBuffer fullQuery;
bool useHTTP = forceHTTP || strstr(base, "<soap:Envelope") != NULL;
if (useHTTP)
{
StringBuffer newQuery;
Owned<IPTree> p = createPTreeFromXMLString(base, ipt_none, ptr_none);
const char *queryName = p->queryName();
if ((stricmp(queryName, "envelope") != 0) && (stricmp(queryName, "envelope") != 0))
{
if (queryNameOverride.length())
queryName = queryNameOverride;
newQuery.appendf("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><Body><%sRequest>", queryName);
Owned<IPTreeIterator> elements = p->getElements("./*");
ForEach(*elements)
{
IPTree &elem = elements->query();
toXML(&elem, newQuery, 0, XML_SingleQuoteAttributeValues);
}
newQuery.appendf("</%sRequest></Body></Envelope>", queryName);
base = newQuery.str();
}
// note - don't support queryname override unless original query is xml
fullQuery.appendf("POST /doc HTTP/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n", (int) strlen(base)).append(base);
}
else
{
if (sendToSocket)
示例7: readResults
//.........这里部分代码省略.........
showMessage("request for datablock\n");
dataBlockRequest = true;
break;
case 'P':
showMessage("request for plugin\n");
pluginRequest = true;
break;
case 'S':
if (showStatus)
showMessage("Status:");
is_status=true;
break;
case 'T':
showMessage("Timing:\n");
break;
case 'X':
showMessage("---Compound query finished---\n");
return 1;
case 'R':
isBlockedResult = true;
break;
}
len &= 0x7FFFFFFF;
len--; // flag already read
}
char * mem = (char*) malloc(len+1);
char * t = mem;
unsigned sendlen = len;
t[len]=0;
try
{
if (useHTTP)
{
try
{
socket->read(t, 0, len, sendlen);
}
catch (IException *E)
{
if (E->errorCode()!= JSOCKERR_graceful_close)
throw;
E->Release();
break;
}
if (!sendlen)
break;
}
else if (readBlocked)
socket->receive_block(t, len);
else
socket->read(t, len);
}
catch(IException * e)
{
pexception("failed to read data", e);
return 1;
}
if (pluginRequest)
{
//Not very robust! A poor man's implementation for testing...
StringBuffer dllname, libname;
const char * dot = strchr(t, '.');
dllname.append("\\edata\\bin\\debug\\").append(t);
libname.append("\\edata\\bin\\debug\\").append(dot-t,t).append(".lib");
sendFile(dllname.str(), socket);
sendFile(libname.str(), socket);
}
else if (dataBlockRequest)
{
//Not very robust! A poor man's implementation for testing...
offset_t offset;
memcpy(&offset, t, sizeof(offset));
_WINREV(offset);
sendFileChunk(t+sizeof(offset), offset, socket);
}
else
{
if (isBlockedResult)
{
t += 8;
t += strlen(t)+1;
sendlen -= (t - mem);
}
if (echoResults && (!is_status || showStatus))
{
fwrite(t, sendlen, 1, stdout);
fflush(stdout);
}
if (!is_status)
result.append(sendlen, t);
}
free(mem);
if (abortAfterFirst)
return 0;
}
return 0;
}