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


C++ CContainer::begin方法代码示例

本文整理汇总了C++中CContainer::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ CContainer::begin方法的具体用法?C++ CContainer::begin怎么用?C++ CContainer::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContainer的用法示例。


在下文中一共展示了CContainer::begin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Recall

// We recall messages stored in the database
size_t CPartner::Recall( const string&  rsClientData,
                               CSocket* poSocket )
  {
  typedef map<string, string> CMapString2String;
  CMapString2String moQuery;

  for (string::size_type p1=0, p2=0;
       string::npos != ( p2 = rsClientData.find('\n', p1) );
       p1 = p2+1)
    {
    string s = rsClientData.substr(p1, p2-p1);
    size_t l = s.length();
    if ( (l > 2) && (s[1] == ':') )
      {
      if ( l > 4)
        moQuery[ s.substr(0, 3) ] = s.substr(4);
        else
        moQuery[ s.substr(0, 3) ] = "";
      }
    } // for (string::size_type p1=0, p2=0; ...

/*
        client command      | send to server   | receive from server
        ====================+==================+====================
        list all            | l:a              |  m:<message-id>
                            |                  | [...]
        list partially      | l:p <message-id> |  m:<message-id>
                            |                  | [...]
        list mine           | l:m              |  m:<message-id>
                            |                  | [...]
        list mine partially | l:y <message-id> |  m:<message-id>
                            |                  | [...]
        list senders        | l:s              |  s:<sender-id>
                            |                  | [...]
        call all            | c:a              |  m:<message-id>
                            |                  | [...]
        call MsgID          | c:m <message-id> |  m:<message-id>
                            |                  | [<body>]
                            |                  | [n:<next message-id>]
        cbsr MsgID          | c:s <message-id> |  m:<message-id>
                            |                  | [<body>]
                            |                  | [n:<next message-id>]
*/
  for ( CMapString2String::iterator itQuery  = moQuery.begin();
                                    itQuery != moQuery.end();
                                  ++itQuery)
    {
    if ( g_bVerbose)
      {
      cout << " * " << itQuery->first;
      if ( itQuery->second.length() > 0 ) cout << " with " << itQuery->second;
      cout << "\n";
      }

    CContainerMapByCLUID::iterator it;

    switch ( itQuery->first[0] )
      {
      case 'l': // list operations
        switch ( itQuery->first[2] )
          {
          case 'a': // l:a list all
            if ( g_bVerbose) cout << " * list all \n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids for this sender
 */
            for ( it = g_oContainerMapByCLUID.begin(); it != g_oContainerMapByCLUID.end(); ++it )
              {
              *poSocket << it->first << "\n";
              }
            break;
          case 'p': // l:p list part, beginning with message-id
/*
              1) get the recipient from the TLS-session
              2) resend all message ids for this sender starting with the given message-id
 */
            if ( g_bVerbose) cout << " * list partial, beginning with '" << itQuery->second << "'\n";
            for ( it = g_oContainerMapByCLUID.find(itQuery->second); it != g_oContainerMapByCLUID.end(); ++it )
              {
              *poSocket << it->first << "\n";
              }
            break;
          case 'm': // l:m list mine (sent by me)
            if ( g_bVerbose) cout << " * list mine\n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids from this sender
 */
            break;
          case 'y': // l:y list mine part, beginning with message-id
            if ( g_bVerbose) cout << " * list mine partial, beginning with '" << itQuery->second << "'\n";
/*
              1) get the recipient from the TLS-session
              2) resend all message ids from this sender starting at the given message-id
 */
            break;
          case 's': // l:s list senders
            if ( g_bVerbose) cout << " * list senders\n";
//.........这里部分代码省略.........
开发者ID:fmorgner,项目名称:flow,代码行数:101,代码来源:partner.cpp


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