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


C++ AnsiString::Find方法代码示例

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


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

示例1:

   AnsiString 
   Canonicalization::GetDKIMWithoutSignature_(AnsiString value)
   {
      // locate the b= tag
      int pos = value.Find("b=");
      if (pos < 0)
         return "";

      // Locate end of b-tag. We need to use the ;-separator
      // here. The signature may contain spaces and newlines
      // if it's folded (and canon-mode is set to simple).
      int end = value.Find(";", pos);

      int actualEnd = 0;
      if (end > pos)
         actualEnd = end;
      else
         actualEnd = value.GetLength();

      int len = actualEnd - pos;

      AnsiString before = value.Mid(0, pos+2);
      AnsiString after = value.Mid(actualEnd);

      AnsiString result = before + after;

      return result;
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:28,代码来源:Canonicalization.cpp

示例2: while

   std::vector<AnsiString>
   StringParser::SplitString(const AnsiString &sInput, const AnsiString &sSeperators)
   {
      std::vector<AnsiString> vecResult;
      int iBeginning = 0;
      int iEnd = sInput.Find(sSeperators);

      if (iEnd == -1)
      {
         // The separator was not found in the string. 
         // We should put the entire string in the result.
         if (!sInput.IsEmpty())
            vecResult.push_back(sInput);

      }

      int iSeperatorLen = sSeperators.GetLength();

      while (iEnd >= 0)
      {
         int iSubStrLength = iEnd - iBeginning;

         String sSubString;
         sSubString = sInput.Mid(iBeginning, iSubStrLength);

         vecResult.push_back(sSubString);

         // Skip to the position where the next substring
         // can start
         iBeginning = iEnd + iSeperatorLen;
         iEnd = sInput.Find(sSeperators, iBeginning);   
      }

      if (iBeginning > 0)
      {
         String sSubString = sInput.Mid(iBeginning);
         if (!sSubString.IsEmpty())
            vecResult.push_back(sSubString);
      }

      return vecResult;


   }
开发者ID:M0ns1gn0r,项目名称:hmailserver,代码行数:44,代码来源:StringParser.cpp

示例3: ParseFilename

void VirtualDriveManager::ParseFilename(const AnsiString& fileName,
			AnsiString& virtualDriveName, AnsiString& virtualFileName)
{
	int pipePos = fileName.Find('|');
	if (pipePos == -1)
	{
		virtualDriveName.Clear();
		virtualFileName.Clear();

		return;
	}

	virtualDriveName = fileName.Sub(0, pipePos);
	virtualFileName = fileName.Sub(pipePos + 1);
} // ParseFilename()
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:15,代码来源:ZipArchiveManager.cpp

示例4: values

   AnsiString 
   RelaxedCanonicalization::CanonicalizeHeaderValue(AnsiString value)
   {
      /*
      Unfold all header field continuation lines as described in
      [RFC2822]; in particular, lines with terminators embedded in
      continued header field values (that is, CRLF sequences followed by
      WSP) MUST be interpreted without the CRLF.  Implementations MUST
      NOT remove the CRLF at the end of the header field value.
      */

      value.Replace("\r\n ", " ");
      value.Replace("\r\n\t", " ");

      /*
      Convert all sequences of one or more WSP characters to a single SP
      character.  WSP characters here include those before and after a
      line folding boundary.
      */

      value.Replace("\t ", " ");
      value.Replace(" \t", " ");
      
      while (value.Find("  ") >= 0)
         value.Replace("  ", " ");

      /*
      Delete all WSP characters at the end of each unfolded header field value.
      */

      while (value.EndsWith(" ") || value.EndsWith("\t"))
         value = value.Mid(0, value.GetLength() -1);

      /* Delete any WSP characters remaining before and after the colon
      separating the header field name from the header field value.  The
      colon separator MUST be retained.
      */
      value.Trim();


      return value;
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:42,代码来源:Canonicalization.cpp

示例5: String

bool
IPAddress::TryParse(const AnsiString &addressString, bool reportOnFail)
{
    boost::system::error_code error;

    if (addressString.Find(":") >= 0)
        _address = boost::asio::ip::address_v6::from_string(addressString, error);
    else
    {
        // Windows 2000 Workaround:
        // On Windows 2000, WSAStringToAddress won't be able to parse the address
        // 255.255.255.255. This is a bug in Windows 2000, which appears to be fixed
        // in later versions. It does work properly on Windows XP.
        // According to Wine guys...
        // http://www.winehq.org/pipermail/wine-patches/2005-August/020220.html
        // .. this appears to be a known bug.
        // So we just do a hack to get around it.
        //
        if (addressString == "255.255.255.255")
            _SetIPV4Address(0xFFFFFFFF);
        else
            _address = boost::asio::ip::address_v4::from_string(addressString, error);

    }

    if (error)
    {
        if (reportOnFail)
        {
            // Parsing of the TCP/IP address failed. Report error to debug log.
            String formattedMessage;
            formattedMessage.Format(_T("Unable to parse TCP/IP address. Address: %s, Error code: %d, Error message: %s"), String(addressString), error.value(), String(error.message()));
            LOG_DEBUG(formattedMessage);
        }

        return false;
    }
    else
        return true;
}
开发者ID:nberardi,项目名称:hMailServer,代码行数:40,代码来源:IPAddress.cpp

示例6: atoi

   int 
   SpamTestSpamAssassin::_ParseSpamAssassinScore(const AnsiString &sHeader)
   {
      int iStartPos = sHeader.FindNoCase("score=");
      if (iStartPos < 0)
         return 0;

      iStartPos += 6;

      int iScoreEnd = sHeader.Find(".", iStartPos);
      if (iScoreEnd < 0)
         return 0;

      int iScoreLength = iScoreEnd - iStartPos;

      if (iScoreLength <= 0)
         return 0;

      AnsiString sScore = sHeader.Mid(iStartPos, iScoreLength);

      int iRetVal = atoi(sScore);
      return iRetVal;

   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:24,代码来源:SpamTestSpamAssassin.cpp

示例7: if

   void
   SMTPClientConnection::InternalParseData(const AnsiString  &Request)
   {
      LOG_DEBUG("SMTPClientConnection::_ParseASCII()");

      String sData = "RECEIVED: " + Request;
      LOG_SMTP_CLIENT(GetSessionID(), GetIPAddress().ToString(), sData);

      // Below 3 lines is fix of the problem that occurs when the remote server answers
      // with 2 line in his welcome message.
      String sMinus = "-";
      if ((Request.GetLength() > 3) && (Request.GetAt(3) == sMinus.GetAt(0)))
      {
         LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 1");
         return;
      }

      int lFirstSpace = Request.Find(" ");
   
      AnsiString sFirstWordTemp;
      if (lFirstSpace < 0)
         sFirstWordTemp = Request;
      else
         sFirstWordTemp = Request.Mid(0, lFirstSpace);
      sFirstWordTemp.MakeUpper();
      int iCode = atoi(sFirstWordTemp);

      // We should not update all recipient's if we've just sent a
      // RCPT TO. We should only update the specific one we've just
      // sent to.
      // 
      // Also, we should not update state if we've just sent QUIT to
      // the server. At the time we send QUIT, the message has already
      // been either accepted for delivery and rejected. Any error after
      // this isn't relvat.
      if (m_CurrentState != RCPTTOSENT && m_CurrentState != QUITSENT)
      {
         if (IsPermanentNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
         else if (IsTransientNegative(iCode))
         {
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }
   
      switch (m_CurrentState)
      {
      case SENDUSERNAME:
         _ProtocolSendUsername();
         break;
      case SENDPASSWORD:
         _ProtocolSendPassword();
         break;
      case PASSWORDCHECK:
         if (!_ProtocolPassswordCheck(iCode, Request))
         {
            // Authentication failed. We have just sent
            // a quit command.
            return;
         }

         break;
      }
      
      if (m_CurrentState == HELO)
      {
         if (iCode == 220)
         {
			   String sComputerName = Utilities::ComputerName(); 
      
            if (m_bUseSMTPAuth)
            {
               _SendData("EHLO " + sComputerName);
               _SetState(EHLOSENT);
            }
            else
            {
               _SendData("HELO " + sComputerName);
               _SetState(HELOSENT);
            }
        
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 2");

            return ;
         }
         else
         {
            LOG_DEBUG("SMTPClientConnection::~_ParseASCII() - 3");
            _UpdateAllRecipientsWithError(iCode, Request, false);
            _SendQUIT();
            return;
         }
      }

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

示例8: _ProtocolPASS

   POP3Connection::ParseResult
   POP3Connection::InternalParseData(const AnsiString &Request)
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Parses a client POP3 command.
   //---------------------------------------------------------------------------()
   {
      _LogClientCommand(Request);

      if (Request.GetLength() > 500)
      {
         // This line is to long... is this an evil user?
         _SendData("-ERR Line to long.");
         return ResultNormalResponse;
      }
      
      String sCommand;
      String sParameter;

      if (Request.Find(" ")>-1)
      {
         sCommand = Request.Left(Request.Find(" "));
         sParameter = Request.Mid(Request.Find(" ") + 1);
      }
      else
         sCommand = Request;

      POP3Command command = GetCommand(m_CurrentState, sCommand);

      switch (command)
      {
         case NOOP:
            _SendData("+OK");
            return ResultNormalResponse;
         case HELP:
            _SendData("+OK Normal POP3 commands allowed");
            return ResultNormalResponse;
         case USER:
            _ProtocolUSER(sParameter);
            return ResultNormalResponse;
         case PASS:
            return _ProtocolPASS(sParameter);
         case STAT:
            _ProtocolSTAT(sParameter);
            return ResultNormalResponse;
         case LIST:
            _ProtocolLIST(sParameter);
            return ResultNormalResponse;
         case RETR:
            return _ProtocolRETR(sParameter);
         case DELE:
            _ProtocolDELE (sParameter);
            return ResultNormalResponse;
         case TOP:
            _ProtocolTOP(sParameter);
            return ResultNormalResponse;
         case RSET:
            _ProtocolRSET();
            return ResultNormalResponse;   
         case UIDL:
            _ProtocolUIDL(sParameter);
            return ResultNormalResponse;   
         case QUIT:
            _ProtocolQUIT();
            return ResultDisconnect;
         case CAPA:
            _SendData("+OK CAPA list follows\r\nUSER\r\nUIDL\r\nTOP\r\n.");
            return ResultNormalResponse;
         case INVALID:
            _SendData("-ERR Invalid command in current state." );
            return ResultNormalResponse;  
         default:
            assert(0); // What command is this?
            _SendData("-ERR Invalid command in current state." );
            return ResultNormalResponse;  
      }
   }
开发者ID:jrallo,项目名称:hMailServer,代码行数:77,代码来源:POP3Connection.cpp

示例9: atoi

   bool
   SMTPClientConnection::InternalParseData(const AnsiString &Request)
   {
      LogReceivedResponse_(Request);

      int lFirstSpace = Request.Find(" ");
   
      AnsiString sFirstWordTemp;
      if (lFirstSpace < 0)
         sFirstWordTemp = Request;
      else
         sFirstWordTemp = Request.Mid(0, lFirstSpace);

      sFirstWordTemp.MakeUpper();
      int iCode = atoi(sFirstWordTemp);
   
      bool ifFailureFailAllRecipientsAndQuit = 
         current_state_ == HELO ||
         current_state_ == HELOSENT ||
         current_state_ == AUTHLOGINSENT ||
         current_state_ == USERNAMESENT || 
         current_state_ == PASSWORDSENT ||
         current_state_ == MAILFROMSENT ||
         current_state_ == DATACOMMANDSENT ||
         current_state_ == DATASENT ||
         current_state_ == PASSWORDSENT;

      if (ifFailureFailAllRecipientsAndQuit)
      {
         if (!IsPositiveCompletion(iCode))
         {
            UpdateAllRecipientsWithError_(iCode, Request, false);
            SendQUIT_();
            return true;
         }
      }

      switch (current_state_)
      {
      case HELO:
         ProtocolStateHELOEHLO_(Request);  
         return true;
      case HELOSENT:
         ProtocolHELOSent_(Request);
         return true;
      case EHLOSENT:
         ProtocolEHLOSent_(iCode, Request);
         return true;
      case STARTTLSSENT:
         ProtocolSTARTTLSSent_(iCode);
         return false;
      case AUTHLOGINSENT:
         ProtocolSendUsername_();
         return true;
      case USERNAMESENT:
         ProtocolSendPassword_();
         return true;
      case PASSWORDSENT:
         ProtocolSendMailFrom_();
         return true;
      case MAILFROMSENT:
         ProtocolMailFromSent_();
         return true;
      case DATACOMMANDSENT:
         ProtocolData_();
         return false;
      case DATASENT:
         SendQUIT_();
         UpdateSuccessfulRecipients_();
         return true;
      case RCPTTOSENT:
         ProtocolRcptToSent_(iCode, Request);
         return true;
      case QUITSENT:
         // We just received a reply on our QUIT. Time to disconnect.
         EnqueueDisconnect();
         return false;
      }

      return true;
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:81,代码来源:SMTPClientConnection.cpp

示例10: assert

   AnsiString 
   SimpleCanonicalization::CanonicalizeHeader(AnsiString header, const std::pair<AnsiString, AnsiString> &signatureField, const std::vector<AnsiString> &fieldsToInclude, AnsiString &fieldList)
   {
      // first build a formatted list of header lines.
      std::vector<AnsiString> formattedHeaderLines;

      AnsiString result;
      std::vector<AnsiString> headerLines = StringParser::SplitString(header, "\r\n");

      AnsiString foldedLines;
      for (size_t i = headerLines.size(); i > 0; i--)
      {
         AnsiString line = headerLines[i-1];

         if (line.StartsWith(" ") || line.StartsWith("\t"))
         {
            // line is folded. append to next.
            foldedLines = line + "\r\n" + foldedLines;
         }
         else
         {
            // we have a line!
            int colonPos = line.Find(":");
            if (colonPos < 0)
            {
               assert(0); // broken header.
               continue;
            }

            AnsiString entireHeaderField = line + "\r\n" + foldedLines;

            formattedHeaderLines.push_back(entireHeaderField);

            foldedLines = "";
         }
      }

      for(AnsiString fieldToInclude : fieldsToInclude)
      {
         fieldToInclude.Trim();

         // locate the header line.
         auto iter = formattedHeaderLines.begin();
         auto iterEnd = formattedHeaderLines.end();
         
         for (; iter != iterEnd; iter++)
         {
            AnsiString headerLine = (*iter);

            int colonPos = headerLine.Find(":");
            AnsiString headerName = headerLine.Mid(0, colonPos);

            if (headerName.CompareNoCase(fieldToInclude) == 0) 
            {
               result += headerLine;

               if (!fieldList.IsEmpty())
                  fieldList += ":";

               fieldList += headerName;

               formattedHeaderLines.erase(iter);
               break;
            }
         }

      }

      if (!signatureField.first.IsEmpty())
      {
         // Don't pick the value from the actual header, use the header we're verifying instead
         // If there are more than one DKIM-signature fields in the header, this will be important.
         AnsiString headerName = signatureField.first;

         AnsiString headerLine = headerName + ": " + GetDKIMWithoutSignature_(signatureField.second);

         if (headerLine.EndsWith("\r\n"))
            headerLine = headerLine.Mid(0, headerLine.GetLength()-2);

         result += headerLine;
      }


      return result;
   }
开发者ID:AimaTeam-hehai,项目名称:hmailserver,代码行数:85,代码来源:Canonicalization.cpp


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