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


C++ stringw::size方法代码示例

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


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

示例1: serverCreationRequest

// ----------------------------------------------------------------------------
void CreateServerScreen::serverCreationRequest()
{
    const irr::core::stringw name = m_name_widget->getText().trim();
    const int max_players = m_max_players_widget->getValue();
    m_info_widget->setErrorColor();
    if (name.size() < 4 || name.size() > 30)
    {
        m_info_widget->setText(_("Name has to be between 4 and 30 characters long!"), false);
    }
    else if (max_players < 2 || max_players > 12)
    {
        m_info_widget->setText(_("The maxinum number of players has to be between 2 and 12."), false);
    }
    else
    {

        m_server_creation_request = new ServerCreationRequest();
        CurrentUser::setUserDetails(m_server_creation_request);
        m_server_creation_request->addParameter("action", "create_server");
        m_server_creation_request->addParameter("name", name);
        m_server_creation_request->addParameter("max_players", max_players);
        m_server_creation_request->queue();

        return;
    }
    sfx_manager->quickSound("anvil");
}
开发者ID:Podmuch,项目名称:stk-code,代码行数:28,代码来源:create_server_screen.cpp

示例2: createServer

/** In case of WAN it adds the server to the list of servers. In case of LAN
 *  networking, it registers this game server with the stk server.
 */
void CreateServerScreen::createServer()
{
    const irr::core::stringw name = m_name_widget->getText().trim();
    const int max_players = m_max_players_widget->getValue();
    m_info_widget->setErrorColor();
    if (name.size() < 4 || name.size() > 30)
    {
        m_info_widget->setText(
            _("Name has to be between 4 and 30 characters long!"), false);
        SFXManager::get()->quickSound("anvil");
        return;
    }
    else if (max_players < 2 || max_players > 12)
    {
        m_info_widget->setText(
            _("The maxinum number of players has to be between 2 and 12."),
            false);
        SFXManager::get()->quickSound("anvil");
        return;
    }

    // In case of a LAN game, we can create the new server object now
    if (NetworkConfig::get()->isLAN())
    {
        // FIXME Is this actually necessary?? Only in case of WAN, or LAN and WAN?
        TransportAddress address(0x7f000001,0);  // 127.0.0.1
        Server *server = new Server(name, /*lan*/true, max_players,
                                    /*current_player*/1, address);
        ServersManager::get()->addServer(server);
    }

    // In case of a WAN game, we register this server with the
    // stk server, and will get the server's id when this 
    // request is finished.
    NetworkConfig::get()->setMaxPlayers(max_players);
    NetworkConfig::get()->setServerName(name);

    // FIXME: Add the following fields to the create server screen
    // FIXME: Long term we might add a 'vote' option (e.g. GP vs single race,
    // and normal vs FTL vs time trial could be voted about).
    race_manager->setDifficulty(RaceManager::convertDifficulty("hard"));
    race_manager->setMajorMode(RaceManager::MAJOR_MODE_SINGLE);
    race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
    race_manager->setReverseTrack(false);
    STKHost::create();

}   // createServer
开发者ID:bog-dan-ro,项目名称:stk-code,代码行数:50,代码来源:create_server_screen.cpp

示例3: split

    /** Splits a string into substrings separated by a certain character, and
     *  returns a std::vector of all those substring. E.g.:
     *  split("a b=c d=e",' ')  --> ["a", "b=c", "d=e"]
     *  This is the version for wide strings.
     *  \param s The string to split.
     *  \param c The character  by which the string is split.
     */
    std::vector<irr::core::stringw> split(const irr::core::stringw& s, char c,
                                           bool keepSplitChar)
    {
        try
        {
            std::vector<irr::core::stringw> result;

            irr::s32 start = 0;
            while (start < (irr::s32)s.size())
            {
                irr::s32 i = s.findNext(c, start);
                if (i != -1)
                {
                    if (keepSplitChar)
                    {
                        int from = start-1;
                        if (from < 0) from = 0;
                        result.push_back( s.subString(from, i-from) );
                    }
                    else result.push_back( s.subString(start, i-start) );
                    start = i+1;
                }
                else
                {
                    if (keepSplitChar)
                        result.push_back( s.subString(start - 1,
                                                      s.size()-start + 1) );
                    else
                        result.push_back( s.subString(start, s.size()-start) );

                    return result;
                    //start = i+1;
                }
            }
            return result;
        }
        catch (std::exception& e)
        {
            (void)e;  // avoid warning about unused variable
            Log::fatal("StringUtils",
                       "Fatal error in split(stringw) : %s @ line %i : '%s'.",
                       __FILE__, __LINE__, e.what());
            exit(1);
        }
    }   // split
开发者ID:jeremiejig,项目名称:paf-autostereoscopie-2014,代码行数:52,代码来源:string_utils.cpp

示例4: notEmpty

/** Checks if the input string is not empty. ( = has characters different
 *  from a space).
 */
bool notEmpty(const irr::core::stringw& input)
{
    const int size = input.size();
    int nonEmptyChars = 0;
    for (int n=0; n<size; n++)
    {
        if (input[n] != L' ')
        {
            nonEmptyChars++;
        }
    }
    return (nonEmptyChars > 0);
}   // getExtension
开发者ID:rugk,项目名称:stk-code,代码行数:16,代码来源:string_utils.cpp

示例5: xmlEncode

/** Converts a unicode string to plain ASCII using XML entites (e.g. &x00;)
 *  \param s The input string which should be encoded.
 *  \return A std:;string with ASCII characters.
 */
std::string xmlEncode(const irr::core::stringw &s)
{
    std::ostringstream output;
    for(unsigned int i=0; i<s.size(); i++)
    {
        if (s[i] >= 128 || s[i] == '&' || s[i] == '<' || s[i] == '>' || s[i] == '\"')
        {
            output << "&#x" << std::hex << std::uppercase << s[i] << ";";
        }
        else
        {
            irr::c8 c = (char)(s[i]);
            output << c;
        }
    }
    return output.str();
}   // xmlEncode
开发者ID:rugk,项目名称:stk-code,代码行数:21,代码来源:string_utils.cpp

示例6: encodeToHtmlEntities

 /** Converts a unicode string to plain ASCII using html-like & codes.
  *  \param s The input string which should be encoded.
  *  \return A std:;string with ASCII characters.
  */
 std::string encodeToHtmlEntities(const irr::core::stringw &s)
 {
     std::ostringstream output;
     for(unsigned int i=0; i<s.size(); i++)
     {
         if(s[i]=='&')
             output<<"&amp;";
         else
         {
             if(s[i]<128)
             {
                 irr::c8 c=(char)(s[i]);
                 output<<c;
             }
             else
             {
                 output <<"&#x" << std::hex <<std::uppercase<< s[i]<<";";
             }
         }
     }
     return output.str();
 }   // encodeToHtmlEntities
开发者ID:jeremiejig,项目名称:paf-autostereoscopie-2014,代码行数:26,代码来源:string_utils.cpp


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