本文整理汇总了C++中StringList::CountItems方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::CountItems方法的具体用法?C++ StringList::CountItems怎么用?C++ StringList::CountItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList::CountItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
static void
add_languages_to_menu(const StringList& languages, BMenu* menu)
{
for (int i = 0; i < languages.CountItems(); i++) {
const BString& language = languages.ItemAtFast(i);
BMessage* message = new BMessage(MSG_LANGUAGE_SELECTED);
message->AddString("code", language);
BMenuItem* item = new BMenuItem(language, message);
menu->AddItem(item);
}
}
示例2: Init
bool Sprites::Init()
{
memset(spritesheet, 0, sizeof(spritesheet));
// load sprites info--sheet positions, bounding boxes etc
if (load_sif("sprites.sif"))
return 1;
num_spritesheets = sheetfiles.CountItems();
return 0;
}
示例3: Init
bool Sprites::Init()
{
char f_sprites_sif[1024];
memset(spritesheet, 0, sizeof(spritesheet));
retro_create_path_string(f_sprites_sif, sizeof(f_sprites_sif), "data", "sprites.sif");
// load sprites info--sheet positions, bounding boxes etc
if (load_sif(f_sprites_sif))
return 1;
num_spritesheets = sheetfiles.CountItems();
return 0;
}
示例4: LoadStatusses
status_t LoadStatusses(BPath statFilePath)
{
status_t error = B_OK;
//open file
BFile statFile(statFilePath.Path(), B_READ_ONLY);
error = statFile.InitCheck();
if (error != B_ERROR)
{
StringList *tokenList = new StringList();
//read line
off_t fileSize;
if (statFile.GetSize(&fileSize) == B_OK)
{
ssize_t bytesRead = 0;
BString* token = new BString("");
bool newToken = false;
do
{
char c[2];
bytesRead += statFile.Read(c,1);
c[1] = '\0';
if (c[0] == '\t' || c[0] == '\n')
{
//clear token
if (!newToken)
{
//add token to list
tokenList->AddItem(token);
token = new BString("");
newToken = true;
}
}
else
{
token->Append(c);
newToken = false;
}
}
while (bytesRead < fileSize);
}
int32 startIndex = -1;
int32 endIndex = -1;
for (int32 i = 0; i < tokenList->CountItems(); i++)
{
if ((*tokenList)[i].ICompare("<status>") == 0)
startIndex = i;
else if ((*tokenList)[i].ICompare("</status>") == 0)
{
endIndex = i;
break;
}
}
if (startIndex != -1 && endIndex != -1)
{
//start past the <status> tag
startIndex++;
for (int32 i = startIndex; i < endIndex; i++)
{
int32 lastLineIndex = i + 4;
if (lastLineIndex < endIndex)
{
//parse lines
BString bitmapString = (*tokenList)[i];
BString statusName = (*tokenList)[i+1];
BString abbreviation = (*tokenList)[i+2];
bool userChoice = atoi((*tokenList)[i+3].String());
BString colourString = (*tokenList)[i+4];
i += 4;
//construct bitmap path
BPath bitmapPath;
statFilePath.GetParent(&bitmapPath);
bitmapPath.Append(bitmapString.String());
BBitmap *icon = BTranslationUtils::GetBitmap(bitmapPath.Path());
//construct status object
Status *status = FindStatus(abbreviation);
if (status != NULL)
{
status->AddIcon(icon);
}
else
{
//remove brackets from colourString
colourString.RemoveAll("{");
colourString.RemoveAll("}");
int32 colours[4];
int32 startIndex = 0;
for (int i = 0; i < 4; i++)
{
int32 commaIndex = colourString.FindFirst(",",startIndex);
if (commaIndex != B_ERROR)
{
BString colourValue;
colourString.CopyInto(colourValue,startIndex, commaIndex-startIndex);
colours[i] = atoi(colourValue.String());
startIndex = commaIndex + 1;
//.........这里部分代码省略.........