本文整理汇总了C++中StringBuffer::appendChar方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::appendChar方法的具体用法?C++ StringBuffer::appendChar怎么用?C++ StringBuffer::appendChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::appendChar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateAtom
void JsonResultGenerator::generateAtom (StringBuffer& output, char const* value) const {
if (value == 0) {
output.appendText("null", 4);
}
else {
output.appendChar('\"');
output.appendText(StringUtils::escapeUnicode(value));
output.appendChar('\"');
}
}
示例2: testAppendChar
//-----------------------------------------------------------------------------
static void testAppendChar()
{
MemoryPool pool = newMemoryPool();
StringBuffer s = newStringBuffer(&pool, "A test string");
s.appendChar(&s, '!');
assertEquals(string, "A test string!", s.str);
s.appendChar(&s, '-');
assertEquals(string, "A test string!-", s.str);
pool.drain(&pool);
}
示例3: ReadInclusiveRange
bool Lexer::ReadInclusiveRange(const TCHAR prev, QueryToken* token) {
int ch = prev;
StringBuffer range;
range.appendChar(ch);
while(!reader->Eos()) {
ch = reader->GetNext();
if ( ch == -1 )
break;
range.appendChar(ch);
if(ch == ']'){
token->set(range.getBuffer(), QueryToken::RANGEIN);
return true;
}
}
queryparser->throwParserException(_T("Unterminated inclusive range! %d %d::%d"),' ',
reader->Column(),reader->Column());
return false;
}
示例4: toString
TCHAR* ConstantScoreQuery::toString(const TCHAR* /*field*/) const
{
StringBuffer buf;
buf.append(_T("ConstantScore("));
TCHAR* tmp = filter->toString();
buf.append(tmp);
_CLLDELETE(tmp);
buf.appendBoost(getBoost());
buf.appendChar(_T(')'));
return buf.giveBuffer();
}
示例5: ReadQuoted
bool Lexer::ReadQuoted(const UChar inCharPrev, QueryToken* outQueryToken)
{
int ch = inCharPrev;
StringBuffer quoted;
quoted.appendChar(ch);
while (!reader->Eos()) {
ch = reader->GetNext();
if (ch == -1)
break;
quoted.appendChar(ch);
if (ch == '"') {
outQueryToken->set(quoted.getBuffer(), 0, quoted.length(), QueryToken::QUOTED);
return true;
}
}
gLog.log(eTypLogError, "Err > Lexer: Unterminated string at %d::%d", reader->Column(), reader->Line());
return false;
}
示例6: ReadFullField
bool Lexer::ReadFullField(const UChar inCharPrev, QueryToken* outQueryToken)
{
int ch = inCharPrev;
StringBuffer range;
range.appendChar(ch);
while (!reader->Eos()) {
ch = reader->GetNext();
if (ch == -1)
break;
range.appendChar(ch);
if (ch == '>') {
outQueryToken->set(range.getBuffer(), 0, range.length(), QueryToken::FULLFIELD);
return true;
}
}
gLog.log(eTypLogError, "Err > Lexer: Unterminated exclusive range at %d::%d", reader->Column(), reader->Line());
return false;
}
示例7: ReadQuoted
bool Lexer::ReadQuoted(const TCHAR prev, QueryToken* token) {
int ch = prev;
StringBuffer quoted;
quoted.appendChar(ch);
while(!reader->Eos()) {
ch = reader->GetNext();
if (ch==-1)
break;
quoted.appendChar(ch);
if(ch == '"'){
token->set(quoted.getBuffer(), QueryToken::QUOTED);
return true;
}
}
queryparser->throwParserException(_T("Unterminated string! %d %d::%d"),' ',
reader->Column(),reader->Column());
return false;
}
示例8: testToString
//-----------------------------------------------------------------------------
static void testToString()
{
MemoryPool pool = newMemoryPool();
StringBuffer sb = newStringBuffer(&pool, "A test strin");
sb.appendChar(&sb, 'g');
assertEquals(string, "A test string", sb.str);
string s = sb.toString(&sb, &pool);
assertEquals(string, "A test string", s);
assertEquals(unsigned_int, 13, strlen(s));
pool.drain(&pool);
}
示例9: setCellValue
ResultStatus CubeWorker::setCellValue(const string& areaIdentifier, const string& sessionIdentifier, const IdentifiersType& path, double value, SplashMode splashMode, bool addValue)
{
StringBuffer sb;
sb.appendText("DOUBLE;");
sb.appendInteger(dbid);
sb.appendChar(';');
sb.appendInteger(cubeid);
sb.appendChar(';');
sb.appendText(StringUtils::escapeString(areaIdentifier));
sb.appendChar(';');
sb.appendText(StringUtils::escapeString(sessionIdentifier));
sb.appendChar(';');
sb.appendText(buildPathString(&path));
sb.appendChar(';');
sb.appendDecimal(value);
sb.appendChar(';');
sb.appendInteger(PaloJob::splashNumber(splashMode));
sb.appendChar(';');
sb.appendInteger((int)addValue);
// we need to change the job-type
// dispatcher->downgradeCurrentJobs();
// send set-cell-value request to worker
vector<string> result;
ResultStatus status = execute(sb.c_str(), result);
if (status != RESULT_OK) {
return status;
}
if (isErrorStatus(result)) {
throw WorkerException(result[0].substr(6), true);
} else if (isExceptionStatus(result)) {
throw WorkerException(result[0].substr(10), true);
}
numFailures = 0;
return RESULT_OK;
}
示例10: ReadTerm
bool Lexer::ReadTerm(const TCHAR prev, QueryToken* token) {
int ch = prev;
bool completed = false;
int32_t asteriskCount = 0;
bool hasQuestion = false;
StringBuffer val;
TCHAR buf[3]; //used for readescaped
while(true) {
switch(ch) {
case -1:
break;
case '\\':
{
if ( ReadEscape(ch, buf) )
val.append( buf );
else
return false;
}
break;
case LUCENE_WILDCARDTERMENUM_WILDCARD_STRING:
asteriskCount++;
val.appendChar(ch);
break;
case LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR:
hasQuestion = true;
val.appendChar(ch);
break;
case '\n':
case '\t':
case ' ':
case '+':
case '-':
case '!':
case '(':
case ')':
case ':':
case '^':
case '[':
case ']':
case '{':
case '}':
case '~':
case '"':
// create new QueryToken
reader->UnGet();
completed = true;
break;
default:
val.appendChar(ch);
break;
// end of switch
}
if(completed || ch==-1 || reader->Eos() )
break;
else
ch = reader->GetNext();
}
// create new QueryToken
if(hasQuestion)
token->set(val.getBuffer(), QueryToken::WILDTERM);
else if(asteriskCount == 1 && val.getBuffer()[val.length() - 1] == '*')
token->set(val.getBuffer(), QueryToken::PREFIXTERM);
else if(asteriskCount > 0)
token->set(val.getBuffer(), QueryToken::WILDTERM);
else if( _tcsicmp(val.getBuffer(), _T("AND"))==0 || _tcscmp(val.getBuffer(), _T("&&"))==0 )
token->set(val.getBuffer(), QueryToken::AND_);
else if( _tcsicmp(val.getBuffer(), _T("OR"))==0 || _tcscmp(val.getBuffer(), _T("||"))==0)
token->set(val.getBuffer(), QueryToken::OR);
else if( _tcsicmp(val.getBuffer(), _T("NOT"))==0 )
token->set(val.getBuffer(), QueryToken::NOT);
else {
bool isnum = true;
int32_t nlen=val.length();
for (int32_t i=0;i<nlen;++i) {
TCHAR ch=val.getBuffer()[i];
if ( _istalpha(ch) ) {
isnum=false;
break;
}
}
if ( isnum )
token->set(val.getBuffer(), QueryToken::NUMBER);
else
token->set(val.getBuffer(), QueryToken::TERM);
}
return true;
}
示例11: generateAtom
void JsonXResultGenerator::generateAtom (StringBuffer& output, uint64_t value) const {
output.appendChar('U');
output.appendInteger(value);
output.appendChar('L');
}
示例12: ReadTerm
bool Lexer::ReadTerm(const UChar inCharPrev, QueryToken* outQueryToken)
{
int ch = inCharPrev;
bool completed = false;
int32_t asteriskCount = 0;
bool hasQuestion = false;
StringBuffer val;
UChar buf[3]; //used for readescaped
while (true) {
switch (ch) {
case -1:
break;
case '\\': {
if (ReadEscape(ch, buf))
val.append(buf);
else
return false;
}
break;
case LUCENE_WILDCARDTERMENUM_WILDCARD_STRING:
asteriskCount++;
val.appendChar(ch);
break;
case LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR:
hasQuestion = true;
val.appendChar(ch);
break;
case '\n':
case '\t':
case ' ':
case '+':
case '-':
case '!':
case '(':
case ')':
case ':':
case '^':
case '[':
case ']':
case '{':
case '}':
case '<':
case '>':
case '~':
case '"':
// create new QueryToken
reader->UnGet();
completed = true;
break;
default:
val.appendChar(ch);
break;
// end of switch
}
if (completed || ch == -1 || reader->Eos())
break;
else
ch = reader->GetNext();
}
// Create new QueryToken
const UChar *uStr = val.getBuffer();
if (hasQuestion)
outQueryToken->set(uStr, QueryToken::WILDTERM);
else if (asteriskCount == 1 && uStr[val.length() - 1] == '*')
outQueryToken->set(uStr, QueryToken::PREFIXTERM);
else if (asteriskCount > 0)
outQueryToken->set(uStr, QueryToken::WILDTERM);
else if (_tcsicmp(uStr, cStrQueryTokenAnd1) == 0 || _tcscmp(uStr, cStrQueryTokenAnd2) == 0)
outQueryToken->set(uStr, QueryToken::AND_);
else if (_tcsicmp(uStr, cStrQueryTokenOr1) == 0 || _tcscmp(uStr, cStrQueryTokenOr2) == 0)
outQueryToken->set(uStr, QueryToken::OR);
else if (_tcsicmp(uStr, cStrQueryTokenNot) == 0)
outQueryToken->set(uStr, QueryToken::NOT);
else {
bool isnum = true;
int32_t nlen = val.length();
for (int32_t i = 0;i < nlen; ++i) {
UChar ch = uStr[i];
if (_istalpha(ch)) {
isnum = false;
break;
}
}
if (isnum)
outQueryToken->set(val.getBuffer(), 0, val.length(), QueryToken::NUMBER);
else
outQueryToken->set(val.getBuffer(), 0, val.length(), QueryToken::TERM);
}
return true;
}