当前位置: 首页>>代码示例>>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;未经允许,请勿转载。