本文整理汇总了C++中String::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Count方法的具体用法?C++ String::Count怎么用?C++ String::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load_Stream
void Sound::Load_Stream(const String& fileName)
{
if(fileName.Count()) return;
name = fileName;
FMOD_RESULT s_result = FMOD_OK;
if(sound != nullptr)
{
s_result = FMOD_Sound_Release(sound);
check_error(s_result);
}
s_result = FMOD_System_CreateSound(fmodSystem, fileName.Data(),
FMOD_SOFTWARE | FMOD_UNICODE | FMOD_CREATESTREAM, nullptr, &sound);
check_error(s_result);
switch(type)
{
case MUSIC:
FMOD_Sound_SetSoundGroup(sound, musicGroup);
break;
case SOUND_EFFECT:
FMOD_Sound_SetSoundGroup(sound, noiseGroup);
break;
}
}
示例2:
std::vector<Tigre::String> Tigre::String::explode(String delimitador) {
std::vector<Tigre::String> result;
int last_push = 0;
for (int i=0; i < this->value.size() && i+delimitador.Count()-1 < this->value.size(); i++) {
if(this->value.substr(i, delimitador.Count()) == delimitador){
result.push_back(this->value.substr(last_push, i-last_push));
last_push = i+delimitador.Count();
}
}
if(last_push < this->value.size()){
result.push_back(this->value.substr(last_push, this->value.size()-last_push));
}
return result;
}
示例3: FindCSVDelimiter
/// Finds appropriate CSV delimiter in given string. Usually highest occurrance of the following ('\t;,')
char FindCSVDelimiter(String csvString)
{
String tokens(";,\t");
int maxDelim = 0, maxCount = 0;
for (int i = 0; i < tokens.Length(); ++i)
{
char delim = tokens.CharAt(i);
int count = csvString.Count(delim);
if (count > maxCount)
{
maxCount = count;
maxDelim = delim;
}
}
return maxDelim;
}
示例4: Execute
void Execute()
{
if (CurrentVote.Voting)
{
Player->PrintToClient(PRINT_HIGH, "Vote already in progress.");
return;
}
if (ArgCount() != 3)
{
Player->PrintToClient (PRINT_HIGH, "Use \"players\" to check the player IDs for kick-by-ID. Syntax:\n vote ban/kick n:id\n vote ban/kick p:playerName\n\n Example: vote ban/kick n:8\n Example: vote ban/kick p:Paril\n");
return;
}
String str = ArgGets(2);
if (str.Count() < 3 ||
str[1] != ':' ||
(str[0] != 'p' && str[0] != 'n'))
{
Player->PrintToClient (PRINT_HIGH, "Syntax error. Type \"vote ban\" or \"vote kick\" to see syntax.\n");
return;
}
int playerToKick = -1;
if (str[0] == 'p')
{
String playerName = str.Substring(2).ToLower();
if (playerName.IsNullOrEmpty())
{
Player->PrintToClient (PRINT_HIGH, "Syntax error. Type \"vote ban\" or \"vote kick\" to see syntax.\n");
return;
}
for (int i = 1; i <= Game.MaxClients; ++i)
{
if (entity_cast<CPlayerEntity>(Game.Entities[i].Entity)->Client.Persistent.Name.Clone().ToLower() == playerName)
{
if (playerToKick != -1)
{
Player->PrintToClient (PRINT_HIGH, "Multiple players exist by that name. Type \"vote ban\" or \"vote kick\" to see how to ban by player number instead.\n");
return;
}
playerToKick = i;
}
}
if (playerToKick == -1)
{
Player->PrintToClient (PRINT_HIGH, "Player does not exist.\n");
return;
}
}
else
{
String playerNum = str.Substring(2);
for (size_t i = 0; i < playerNum.Count(); ++i)
{
if (playerNum[i] < '0' || playerNum[i] > '9')
{
Player->PrintToClient (PRINT_HIGH, "Invalid player number.\n");
return;
}
}
playerToKick = atoi(str.Substring(2).CString());
if (playerToKick <= 0 || playerToKick > Game.MaxClients)
{
Player->PrintToClient (PRINT_HIGH, "Invalid player number.\n");
return;
}
}
CVoteKickBanData *voteData = QNew(TAG_GENERIC) CVoteKickBanData(ban, playerToKick);
CurrentVote.StartVote(voteType, voteData, Player->Client.Persistent.Name);
}
示例5: reader
SharedPtr<Resource> LevelLoader::Load(Stream& source)
{
String line;
List<String> list;
SharedPtr<TextReader> reader(new TextReader(&source));
line = reader->ReadLine();
list = line.Split(' ');
if (list.Count() < 2)
return SharedPtr<Resource>::EMPTY;
const Vector2i size(list[0].ToInt(), list[1].ToInt());
auto data = _context->NewObject<Level>();
auto cache = _context->GetModule<ResourceCache>();
List<SharedPtr<Model>> prefabs;
prefabs.Add(SharedPtr<Model>(cache->Load<Model>("Data/Models/floor.obj")));
prefabs.Add(SharedPtr<Model>(cache->Load<Model>("Data/Models/wall.obj")));
bool** map = new bool*[size.x];
for (int x = 0; x < size.x; x++)
map[x] = new bool[size.y];
for (int y = 0; y < size.y; y++)
{
line = reader->ReadLine();
if (line.Count() != size.x)
{
for (int x = 0; x < size.x; x++)
map[x][y] = false;
continue;
}
for (int x = 0; x < size.x; x++)
map[x][y] = line[x] == '#';
}
for (int x = 0; x < size.x; x++)
for (int y = 0; y < size.y; y++)
{
const Vector2i index(x / LevelChunk::SIDE, y / LevelChunk::SIDE);
const Vector2i pos(x - index.x * LevelChunk::SIDE, y - index.y * LevelChunk::SIDE);
auto chunk = data->GetChunk(index);
auto& cell = chunk->GetCell(pos);
cell.Clear();
if (map[x][y])
continue;
cell.SetFloor(0);
if (x > 0 && map[x - 1][y])
cell.SetWall(DIR_WEST, 1);
if (x + 1 < size.x && map[x + 1][y])
cell.SetWall(DIR_EAST, 1);
if (y > 0 && map[x][y - 1])
cell.SetWall(DIR_NORTH, 1);
if (y + 1 < size.y && map[x][y + 1])
cell.SetWall(DIR_SOUTH, 1);
}
for (int x = 0; x < size.x; x++)
delete[] map[x];
delete[] map;
data->SetPrefabs(prefabs);
return DynamicCast<Resource>(data);
}