本文整理汇总了C++中String::A方法的典型用法代码示例。如果您正苦于以下问题:C++ String::A方法的具体用法?C++ String::A怎么用?C++ String::A使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::A方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replyError
void FalhttpdClient::replyError( int errorID, const String& explain )
{
String sErrorDesc = codeDesc( errorID );
String sReply;
String sError;
sReply.A("HTTP/1.1 ").N( errorID ).A( " " + sErrorDesc + "\r\n");
sError.N(errorID ).A( ": " + sErrorDesc );
// for now, we create the docuemnt here.
// TODO Read the error document from a file.
String sErrorDoc = "<html>\n"
"<head>\r\n"
"<title>Error " +sError + "</title>\n"
"</head>\n"
"<body>\n"
"<h1>" + sError + "</h1>\n";
if( explain.size() != 0 )
{
sErrorDoc += "<p>This abnormal condition has been encountered while receiving and processing Your request:</p>\n";
sErrorDoc += "<p><b>" + explain + "</b></p>\n";
}
else
{
sErrorDoc += "<p>An error of type <b>" + sError + "</b> has been detected while parsing your request.</p>\n";
}
sErrorDoc += getServerSignature();
sErrorDoc += "</body>\n</html>\n";
AutoCString content( sErrorDoc );
TimeStamp now;
now.currentTime();
sReply += "Date: " + now.toRFC2822() + "\r\n";
sReply.A( "Content-Length: ").N( (int64) content.length() ).A("\r\n");
sReply += "Content-Type: text/html; charset=utf-8\r\n\r\n";
m_log->log( LOGLEVEL_INFO, "Sending ERROR reply to client " + m_sRemote + ": " + sError );
sendData( sReply );
sendData( content.c_str(), content.length() );
}
示例2: describe_internal
static void describe_internal( VMachine *vm, String &tgt, const Item *elem, int32 level, int32 maxLevel, int32 maxSize )
{
uint32 count;
// return if we reached the maximum level.
if ( maxLevel >= 0 && level > maxLevel )
{
tgt += "...";
return;
}
switch( elem->type() )
{
case FLC_ITEM_NIL:
tgt += "Nil";
break;
case FLC_ITEM_UNB:
tgt += "_";
break;
case FLC_ITEM_BOOL:
tgt += elem->asBoolean() ? "true" : "false";
break;
case FLC_ITEM_INT:
tgt.writeNumber( elem->asInteger() );
break;
case FLC_ITEM_NUM:
tgt.writeNumber( elem->asNumeric(), "%g" );
break;
case FLC_ITEM_RANGE:
elem->toString(tgt);
break;
case FLC_ITEM_STRING:
tgt += "\"";
if ( maxSize < 0 || elem->asString()->length() < (uint32) maxSize )
{
tgt += *elem->asString();
tgt += "\"";
}
else {
tgt += elem->asString()->subString(0, maxSize );
tgt += " ... \"";
}
break;
case FLC_ITEM_LBIND:
tgt += "&";
tgt += *elem->asLBind();
if (elem->isFutureBind())
{
tgt +="|";
describe_internal( vm, tgt, &elem->asFutureBind(), level+1, maxLevel, maxSize );
}
break;
case FLC_ITEM_MEMBUF:
{
MemBuf *mb = elem->asMemBuf();
tgt += "MB(";
tgt.writeNumber( (int64) mb->length() );
tgt += ",";
tgt.writeNumber( (int64) mb->wordSize() );
tgt += ")";
tgt += " [";
String fmt;
int limit = 0;
switch ( mb->wordSize() )
{
case 1: fmt = "%02" LLFMT "X"; limit = 24; break;
case 2: fmt = "%04" LLFMT "X"; limit = 12; break;
case 3: fmt = "%06" LLFMT "X"; limit = 9; break;
case 4: fmt = "%08" LLFMT "X"; limit = 6; break;
}
uint32 max = maxSize < 0 || mb->length() < (uint32) maxSize ? mb->length() : (uint32) maxSize;
for( count = 0; count < max; count++ )
{
tgt.writeNumber( (int64) mb->get( count ), fmt );
tgt += " ";
}
if ( count == (uint32) maxSize )
tgt += " ...";
tgt += "]";
}
break;
case FLC_ITEM_ARRAY:
{
CoreArray *arr = elem->asArray();
tgt += "[";
//.........这里部分代码省略.........