当前位置: 首页>>代码示例>>C++>>正文


C++ String::A方法代码示例

本文整理汇总了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() );

}
开发者ID:Klaim,项目名称:falcon,代码行数:44,代码来源:falhttpd_client.cpp

示例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 += "[";

//.........这里部分代码省略.........
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:101,代码来源:inspect.cpp


注:本文中的String::A方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。