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


C++ StringList::push_back方法代码示例

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


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

示例1: GetRow

void ConsoleBuffer::GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns) {
    if (table == "console" && row_index < messages.size()) {
        for (size_t i = 0; i < columns.size(); i++) {
            if (columns[i] == "message") {
                eventMessage* em = &(messages[row_index]);
                Rocket::Core::String msg(em->message.c_str());
                row.push_back(msg);
            } else if (columns[i] == "color") {
                eventMessage* em = &(messages[row_index]);
                switch (em->type) {
                case SYSTEM_MSG:
                    row.push_back(systemMsgColorString);
                    break;
                case MOVE_MSG:
                    row.push_back(moveMsgColorString);
                    break;
                case ATTACK_MSG:
                    row.push_back(attackMsgColorString);
                    break;
                default:
                    assert(0);
                }
            }
        }
    }
}
开发者ID:rmaloney77,项目名称:crimson,代码行数:26,代码来源:ConsoleBuffer.cpp

示例2: GetRow

void HighScores::GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns)
{
	if (table == "scores")
	{
		for (size_t i = 0; i < columns.size(); i++)
		{
			if (columns[i] == "name")
			{
				row.push_back(scores[row_index].name);
			}
			else if (columns[i] == "name_required")
			{
				row.push_back(Rocket::Core::String(4, "%d", scores[row_index].name_required));
			}
			else if (columns[i] == "score")
			{
				row.push_back(Rocket::Core::String(32, "%d", scores[row_index].score));
			}
			else if (columns[i] == "colour")
			{
				Rocket::Core::String colour_string;
				Rocket::Core::TypeConverter< Rocket::Core::Colourb, Rocket::Core::String >::Convert(scores[row_index].colour, colour_string);
				row.push_back(colour_string);
			}
			else if (columns[i] == "wave")
			{
				row.push_back(Rocket::Core::String(8, "%d", scores[row_index].wave));
			}
		}
	}
}
开发者ID:AlexKordic,项目名称:libRocket,代码行数:31,代码来源:HighScores.cpp

示例3:

void Phobos::Game::Gui::LevelFileDataSource::GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns)
{
	if(table == "files")
	{
		row.push_back(vecFiles[row_index].c_str());
	}
}
开发者ID:CronosTs,项目名称:phobos3d,代码行数:7,代码来源:LevelSelector.cpp

示例4: GetRow

/// Fetches the contents of one row of a table within the data source.
/// @param[out] row The list of values in the table.
/// @param[in] table The name of the table to query.
/// @param[in] row_index The index of the desired row.
/// @param[in] columns The list of desired columns within the row.
void LuaDataSource::GetRow(Rocket::Core::StringList& row, const Rocket::Core::String& table, int row_index, const Rocket::Core::StringList& columns)
{
    if(getRowRef == LUA_NOREF || getRowRef == LUA_REFNIL) return;

    //setup the call
    Interpreter::BeginCall(getRowRef);
    lua_State* L = Interpreter::GetLuaState();
    lua_pushstring(L,table.CString());
    lua_pushinteger(L,row_index);
    lua_newtable(L);
    int index = 0;
    for(Rocket::Core::StringList::const_iterator itr = columns.begin(); itr != columns.end(); ++itr)
    {
        lua_pushstring(L,itr->CString());
        lua_rawseti(L,-2,index++);
    }
    Interpreter::ExecuteCall(3,1); //3 parameters, 1 return. After here, the top of the stack contains the return value

    int res = lua_gettop(L);
    if(lua_type(L,res) == LUA_TTABLE)
    {
        lua_pushnil(L);
        while(lua_next(L,res) != 0)
        {
            //key at -2, value at -1
            row.push_back(luaL_checkstring(L,-1));
            lua_pop(L,1); //pops value, leaves key for next iteration
        }
        lua_pop(L,1); //pop key
    }
    else
        Log::Message(Log::LT_WARNING, "Lua: DataSource.GetRow must return a table, the function it called returned a %s", lua_typename(L,res));

    Interpreter::EndCall(1);
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:40,代码来源:LuaDataSource.cpp

示例5: GetRow

void GameTypesDataSource::GetRow( Rocket::Core::StringList &row, const Rocket::Core::String&, int row_index, const Rocket::Core::StringList& cols ) {
	if( row_index < 0 || (size_t)row_index >= gameTypes.size() ) {
		return;
	}

	for( Rocket::Core::StringList::const_iterator it = cols.begin();
		 it != cols.end();
		 ++it ) {
		if( *it == "name" ) {
			row.push_back( gameTypes[row_index].name.c_str() );
		} else if( *it == "title" ) {
			row.push_back( gameTypes[row_index].title.c_str() );
		} else if( *it == "description" ) {
			row.push_back( gameTypes[row_index].description.c_str() );
		} else {
			row.push_back( "" );
		}
	}
}
开发者ID:adem4ik,项目名称:qfusion,代码行数:19,代码来源:ui_gametypes_datasource.cpp

示例6: GetRow

void ItemViewModel::GetRow(Rocket::Core::StringList& row,
      const Rocket::Core::String& table, int row_index,
      const Rocket::Core::StringList& columns)
{
   if (table == "items")
   {
      const ItemList& itemList = m_playerData.getInventory()->getItemList();
      for (int i = 0; i < columns.size(); ++i)
      {
         const UsableId usableId = itemList[row_index].first;
         const int itemQuantity = itemList[row_index].second;
         const Item* rowItem = m_metadata.getItem(usableId);
         if (columns[i] == "name")
         {
            if(rowItem == nullptr)
            {
               row.emplace_back(13, "Unknown %d", usableId);
            }
            else
            {
               row.emplace_back(rowItem->getName().c_str());
            }
         }
         else if (columns[i] == "quantity")
         {
            row.emplace_back(5, "%d", itemQuantity);
         }
         else if (columns[i] == "icon")
         {
            if(rowItem == nullptr)
            {
               row.push_back(ItemViewModel::UnknownItemIconPath);
            }
            else
            {
               row.emplace_back(rowItem->getIconPath().c_str());
            }
         }
      }
   }
}
开发者ID:noam-c,项目名称:EDEn,代码行数:41,代码来源:ItemViewModel.cpp

示例7: BuildOptions

// Builds the option list from the data source.
void ElementFormControlDataSelect::BuildOptions()
{
	widget->ClearOptions();

	if (data_source == NULL)
		return;

	// Store the old selection value and index. These will be used to restore the selection to the
	// most appropriate option after the options have been rebuilt.
	Rocket::Core::String old_value = GetValue();
	int old_selection = GetSelection();

	Rocket::Core::String fields_attribute = GetAttribute<Rocket::Core::String>("fields", "");
	Rocket::Core::String valuefield_attribute = GetAttribute<Rocket::Core::String>("valuefield", "");
	Rocket::Core::String data_formatter_attribute = GetAttribute<Rocket::Core::String>("formatter", "");
	DataFormatter* data_formatter = NULL;

	// Process the attributes.
	if (fields_attribute.Empty())
	{
		Core::Log::Message(Rocket::Core::Log::LT_ERROR, "DataQuery failed, no fields specified for %s.", GetTagName().CString());
		return;
	}

	if (valuefield_attribute.Empty())
	{
		valuefield_attribute = fields_attribute.Substring(0, fields_attribute.Find(","));
	}

	if (!data_formatter_attribute.Empty())
	{
		data_formatter = DataFormatter::GetDataFormatter(data_formatter_attribute);
		if (!data_formatter)
			Core::Log::Message(Rocket::Core::Log::LT_WARNING, "Unable to find data formatter named '%s', formatting skipped.", data_formatter_attribute.CString());
	}

	// Build a list of attributes
	Rocket::Core::String fields(valuefield_attribute);
	fields += ",";
	fields += fields_attribute;

	DataQuery query(data_source, data_table, fields);
	while (query.NextRow())
	{
		Rocket::Core::StringList fields;
		Rocket::Core::String value = query.Get<Rocket::Core::String>(0, "");

		for (size_t i = 1; i < query.GetNumFields(); ++i)
			fields.push_back(query.Get< Rocket::Core::String>(i, ""));

		Rocket::Core::String formatted("");
		if (fields.size() > 0)
			formatted = fields[0];

		if (data_formatter)
			data_formatter->FormatData(formatted, fields);

		// Add the data as an option.
		widget->AddOption(formatted, value, -1, false);
	}

	// If an option was selected before, attempt to restore the selection to it.
	if (old_selection > -1)
	{
		// Try to find a selection with the same value as the previous one.
		for (int i = 0; i < GetNumOptions(); ++i)
		{
			SelectOption* option = GetOption(i);
			if (option->GetValue() == old_value)
			{
				widget->SetSelection(i, true);
				return;
			}
		}

		// Failed to find an option with the same value. Attempt to at least set the same index.
		int new_selection = Rocket::Core::Math::Clamp(old_selection, 0, GetNumOptions() - 1);
		if (GetNumOptions() == 0)
			new_selection = -1;

		widget->SetSelection(new_selection, true);
	}
}
开发者ID:MatiasNAmendola,项目名称:libRocket,代码行数:84,代码来源:ElementFormControlDataSelect.cpp


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