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


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

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


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

示例1: splitResourceName

	VBOOL splitResourceName(const Ogre::String& name,Ogre::String& resourceName,Ogre::String& groupName)
	{
		Ogre::String::size_type pos = name.find_first_of(':');
		if (pos ==Ogre::String::npos)
		{
			if (groupName.empty())
				groupName = DEFAULT_RESOURCE_GROUP_NAME;
			resourceName = name;
			return VFALSE;
		}
		else
		{
			groupName = name.substr(0, pos);
			resourceName = name.substr(pos+1,Ogre::String::npos);
			return VTRUE;
		}
	}
开发者ID:asnwerear,项目名称:VEngine,代码行数:17,代码来源:VResource.cpp

示例2: position

Ogre::StringVector
StringTokenise(const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve, const Ogre::String& quote, const Ogre::String& esc)
{
    Ogre::StringVector ret;

    Ogre::String::size_type pos = 0; // the current position (char) in the string
    char ch = 0; // buffer for the current character
    char delimiter = 0;	// the buffer for the delimiter char which
                            // will be added to the tokens if the delimiter
                            // is preserved
    char current_quote = 0; // the char of the current open quote
    bool quoted = false; // indicator if there is an open quote
    Ogre::String token;  // string buffer for the token
    bool token_complete = false; // indicates if the current token is
                                 // read to be added to the result vector
    Ogre::String::size_type len = str.length();  // length of the input-string

    // for every char in the input-string
    while(len > pos)
    {
        // get the character of the string and reset the delimiter buffer
        ch = str.at(pos);
        delimiter = 0;

        // assume ch isn't a delimiter
        bool add_char = true;

        // check ...

        // ... if the delimiter is an escaped character
        bool escaped = false; // indicates if the next char is protected
        if(esc.empty() == false) // check if esc-chars are provided
        {
            if(esc.find_first_of(ch) != std::string::npos)
            {
                // get the escaped char
                ++pos;
                if(pos < len) // if there are more chars left
                {
                    // get the next one
                    ch = str.at(pos);

                    // add the escaped character to the token
                    add_char = true;
                }
                else // cannot get any more characters
                {
                    // don't add the esc-char
                    add_char = false;
                }

                // ignore the remaining delimiter checks
                escaped = true;
            }
        }

        // ... if the delimiter is a quote
        if(quote.empty() == false && escaped == false)
        {
            // if quote chars are provided and the char isn't protected
            if(quote.find_first_of(ch) != std::string::npos)
            {
                // if not quoted, set state to open quote and set
                // the quote character
                if(quoted == false)
                {
                    quoted = true;
                    current_quote = ch;

                    // don't add the quote-char to the token
                    add_char = false;
                }
                else // if quote is open already
                {
                    // check if it is the matching character to close it
                    if(current_quote == ch)
                    {
                        // close quote and reset the quote character
                        quoted = false;
                        current_quote = 0;

                        // don't add the quote-char to the token
                        add_char = false;
                    }
                }
            }
        }

        // if the delimiter isn't preserved
        if(delimiters.empty() == false && escaped == false && quoted == false)
        {
            // if a delimiter is provided and the char isn't protected by
            // quote or escape char
            if(delimiters.find_first_of(ch) != std::string::npos)
            {
                // if ch is a delimiter and the token string isn't empty
                // the token is complete
                if(token.empty() == false)
                {
                    token_complete = true;
//.........这里部分代码省略.........
开发者ID:adrielvel,项目名称:q-gears,代码行数:101,代码来源:Utilites.cpp


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