當前位置: 首頁>>代碼示例>>C++>>正文


C++ string_t::length方法代碼示例

本文整理匯總了C++中string_t::length方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::length方法的具體用法?C++ string_t::length怎麽用?C++ string_t::length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在string_t的用法示例。


在下文中一共展示了string_t::length方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: WBUFB

CServerMessagePacket::CServerMessagePacket(const string_t message, int8 language, int32 timestamp, int32 message_offset)
{
    this->type = 0x4D;
    this->size = 0x0E;

    WBUFB(data, (0x04) ) = message_offset == 0 ? 1 : 2;
    WBUFB(data, (0x05) ) = 1;
    WBUFB(data, (0x06) ) = 1;
    WBUFB(data, (0x07) ) = language;
    WBUFL(data, (0x08) ) = timestamp == 0 ? time(0) : timestamp;
    WBUFL(data, (0x0C) ) = 0; // Message Length.. (Total)
    WBUFL(data, (0x10) ) = 0; // Message Offset..
    WBUFL(data, (0x14) ) = 0; // Message Length..

    // Ensure we have a message and the requested offset is not outside of the bounds..
    if (message.length() > 0 && message.length() > message_offset)
    {
        int32 msgLength = message.length();
        int32 sndLength = (msgLength - message_offset) > 236 ? 236 : (msgLength - message_offset);

        WBUFL(data, (0x0C) ) = message.length(); // Message Length.. (Total)
        WBUFL(data, (0x10) ) = message_offset;   // Message Offset..
        WBUFL(data, (0x14) ) = sndLength;        // Message Length..

        memcpy((data + (0x18)) , message.c_str() + message_offset, sndLength);

        int32 textSize = sndLength + sndLength % 2;
        this->size = ((((0x14 + textSize) + 4) >> 1) & 0xFE);
    }
開發者ID:Anthiam,項目名稱:darkstar,代碼行數:29,代碼來源:server_message.cpp

示例2: RemoveExtensionFromFilename

bool Anitomy::RemoveExtensionFromFilename(string_t& filename,
                                          string_t& extension) {
  const size_t position = filename.find_last_of(L'.');

  if (position == string_t::npos)
    return false;

  extension = filename.substr(position + 1);

  const size_t max_length = 4;
  if (extension.length() > max_length)
    return false;

  if (!IsAlphanumericString(extension))
    return false;

  // TODO: Add an option for this
  auto keyword = StringToUpperCopy(extension);
  if (!keyword_manager.Find(kElementFileExtension, keyword))
    return false;

  filename.resize(position);

  return true;
}
開發者ID:vevix,項目名稱:anitomy,代碼行數:25,代碼來源:anitomy.cpp

示例3: match

 bool RegexSearch::match(State * beginState,const string_t &str, int pos)
 {
     beginPos=pos;
     //empty string
     if((flag&MatchFlag::MATCH_NOT_NULL)!=0&&str.length()==0)
     {
         return false;
     }
     //match way choose
     if((flag&MatchFlag::MATCH_BFS)==0)
     {
         return matchDfs(beginState,str,pos-1,pos);
     }
     else
     {
         return matchBfs(beginState,str,pos);
     }
 }
開發者ID:jstzwj,項目名稱:tinyregex,代碼行數:18,代碼來源:regexsearch.cpp

示例4: ToGrid

string_t Square::ToGrid(const string_t & str)
{
#ifdef PUZ_CHECK_STRINGS
    if (str.length() > REBUS_ENTRY_LENGTH)
        throw LongString();
#endif 
    string_t ret;
    string_t::const_iterator it;
    for (it = str.begin(); it != str.end(); ++it)
    {
        char_t ch = ToGrid(*it);
        if (ch != 0)
            ret.append(1, ch);
#ifdef PUZ_CHECK_STRINGS
        else
            throw InvalidString();
#endif
    }
    return ret;
}
開發者ID:mattprintz,項目名稱:wx-xword,代碼行數:20,代碼來源:Square.cpp

示例5: Serialize

void SaveFile::Serialize(string_t &str)
{
	string_t::size_type len = str.length();
	Serialize(len);
	if( len )
	{
		if( loading() )
		{
			std::vector<string_t::value_type> buffer(len);
			SerializeArray(&*buffer.begin(), len);
			str.resize(0);
			str.reserve(len);
			str.insert(str.begin(), buffer.begin(), buffer.end());
		}
		else
		{
			SerializeArray(const_cast<string_t::value_type*>(str.data()), len);
		}
	}
}
開發者ID:ACefalu,項目名稱:tzod,代碼行數:20,代碼來源:SaveFile.cpp

示例6: replace

 string_t RegexSearch::replace(const RegexResult &result, const string_t &str, int pos, const string_t &replaceStr)
 {
     string_t ans;
     unsigned int curSubMatch=0;
     for(unsigned int i=pos;i<str.length();)
     {
         if(curSubMatch!=result.subMatch.size()&&
                 result.subMatch[curSubMatch].begin==(int)i)
         {
             ans.insert(ans.length(),replaceStr);
             i+=result.subMatch[curSubMatch].end-result.subMatch[curSubMatch].begin+1;
             ++curSubMatch;
         }
         else
         {
             ans.push_back(str[i]);
             ++i;
         }
     }
     return ans;
 }
開發者ID:jstzwj,項目名稱:tinyregex,代碼行數:21,代碼來源:regexsearch.cpp

示例7: RemoveExtensionFromFilename

bool Anitomy::RemoveExtensionFromFilename(string_t& filename,
                                          string_t& extension) const {
  const size_t position = filename.find_last_of(L'.');

  if (position == string_t::npos)
    return false;

  extension = filename.substr(position + 1);

  const size_t max_length = 4;
  if (extension.length() > max_length)
    return false;

  if (!IsAlphanumericString(extension))
    return false;

  string_t keyword = keyword_manager.Normalize(extension);
  if (!keyword_manager.Find(kElementFileExtension, keyword))
    return false;

  filename.resize(position);

  return true;
}
開發者ID:gamedeff,項目名稱:anitomy,代碼行數:24,代碼來源:anitomy.cpp

示例8: is_path_rooted

bool pal::is_path_rooted(const string_t& path)
{
    return path.length() >= 2 && path[1] == L':';
}
開發者ID:AustinWise,項目名稱:core-setup,代碼行數:4,代碼來源:pal.windows.cpp

示例9: matchDfs

    bool RegexSearch::matchDfs(State * beginState,const string_t &str, int acpos, int pos)
    {
        bool result(false);
        if((unsigned int)pos==str.length())
        {
            if(beginState->isEndState==true)
            {
                return true;
            }
        }
        if((unsigned int)pos>str.length())
        {
            return false;
        }
        for(unsigned int i=0;i<beginState->out.size();++i)
        {
            Transition &curTransition=*(beginState->out[i]);
            switch(curTransition.type)
            {
            case TransitionType::CHARS:
                if(curTransition.range.isSubSet(str[pos]))
                {
                    if(matchDfs(curTransition.target,str,acpos+1,pos+1))
                    {
                        result = true;
                    }
                }
                break;
            case TransitionType::EMPTY:
                if(matchDfs(curTransition.target,str,acpos,pos))
                {
                    result = true;
                }
                break;
            case TransitionType::BEGINLINE:
                if(pos>=1)
                {
                    if(str[pos-1]==T('\n')||str[pos-1]==T('\r'))
                    {
                        if(matchDfs(curTransition.target,str,acpos,pos))
                        {
                            result = true;
                        }
                    }
                }
                //attention no break
            case TransitionType::BEGINSTRING:
                if((flag&MATCH_NOT_BOL)==0)
                {
                    if(pos==0)
                    {
                        if(matchDfs(curTransition.target,str,acpos,pos))
                        {
                            result = true;
                        }
                    }
                }
                break;
            case TransitionType::ENDLINE:
                if(str[pos]==T('\n')||str[pos]==T('\r'))
                {
                    if(matchDfs(curTransition.target,str,acpos,pos))
                    {
                        result = true;
                    }
                }
                //attention no break
            case TransitionType::ENDSTRING:
                if((flag&MATCH_NOT_EOL)==0)
                {
                    if((unsigned int)pos==str.length())
                    {
                        if(matchDfs(curTransition.target,str,acpos,pos))
                        {
                            result = true;
                        }
                    }
                }
                break;
            case TransitionType::BEGINCAPTURE:
                smatch.captureResult.push_back(RegexPosition(acpos+1,acpos+1));
                if(matchDfs(curTransition.target,str,acpos,pos))
                {
                    result = true;
                }
                else
                {
                    smatch.captureResult.pop_back();
                }
                break;
            case TransitionType::ENDCAPTURE:
            {
                std::vector<RegexPosition>::iterator topCapture;
                int back_saver=0;
                if(!smatch.captureResult.empty())
                {
                    topCapture=smatch.captureResult.end()-1;
                    back_saver=topCapture->end;
                    //no greedy
                    if(topCapture->end<acpos)
//.........這裏部分代碼省略.........
開發者ID:jstzwj,項目名稱:tinyregex,代碼行數:101,代碼來源:regexsearch.cpp

示例10: searchDfs

    bool RegexSearch::searchDfs(State * beginState,const string_t &str, int acpos, int pos, bool isLazy)
    {
        bool result(false);
        if(pos-beginPos>10000)//replace by macro later
        {
            throw RegexError(ErrorCode::error_stack);
        }
        if((unsigned int)pos>str.length())
        {
            return false;
        }
        if(beginState->isEndState==true&&acpos>=0)
        {
            if(isLazy==true)
            {
                smatch.end=acpos;
                return true;
            }
            else
            {
                if(smatch.end<acpos)
                    smatch.end=acpos;
                result=true;
            }
        }
        for(unsigned int i=0;i<beginState->out.size();++i)
        {
            Transition &curTransition=*(beginState->out[i]);
            switch(curTransition.type)
            {
            case TransitionType::CHARS:
                if(curTransition.range.isSubSet(str[pos]))
                {
                    if(searchDfs(curTransition.target,str,acpos+1,pos+1,isLazy))
                    {
                        result = true;
                    }
                }
                break;
            case TransitionType::EMPTY:
                if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                {
                    result = true;
                }
                break;
            case TransitionType::BEGINLINE:
                if(pos>=1)
                {
                    if(str[pos-1]==T('\n')||str[pos-1]==T('\r'))
                    {
                        if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                        {
                            result = true;
                        }
                    }
                }
                //attention no break
            case TransitionType::BEGINSTRING:
                if((flag&MATCH_NOT_BOL)==0)
                {
                    if(pos==0)
                    {
                        if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                        {
                            result = true;
                        }
                    }
                }
                break;
            case TransitionType::ENDLINE:
                if(str[pos]==T('\n')||str[pos]==T('\r'))
                {
                    if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                    {
                        result = true;
                    }
                }
                //attention no break
            case TransitionType::ENDSTRING:
                if((flag&MATCH_NOT_EOL)==0)
                {
                    if((unsigned int)pos==str.length())
                    {
                        if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                        {
                            result = true;
                        }
                    }
                }
                break;
            case TransitionType::LAZY:
                if(searchDfs(curTransition.target,str,acpos,pos,true))
                {
                    result = true;
                }
                break;
            case TransitionType::BEGINCAPTURE:
                smatch.captureResult.push_back(RegexPosition(acpos+1,acpos+1));
                if(searchDfs(curTransition.target,str,acpos,pos,isLazy))
                {
//.........這裏部分代碼省略.........
開發者ID:jstzwj,項目名稱:tinyregex,代碼行數:101,代碼來源:regexsearch.cpp

示例11: word_prefix

string_t word_prefix(const string_t &word)
{
	return word.length() > DEPTH ? word.substr(0, DEPTH) : word;
}
開發者ID:aababilov,項目名稱:dictutils,代碼行數:4,代碼來源:wordform.cpp

示例12: has_end

bool has_end(const string_t &a, const string_t &b)
{
	if (a.length() < b.length())
		return false;
	return a.compare(a.length() - b.length(), b.length(), b) == 0;
}
開發者ID:aababilov,項目名稱:dictutils,代碼行數:6,代碼來源:wordform.cpp


注:本文中的string_t::length方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。