本文整理汇总了C++中CStringArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ CStringArray::size方法的具体用法?C++ CStringArray::size怎么用?C++ CStringArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStringArray
的用法示例。
在下文中一共展示了CStringArray::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFrameDimensionsFromFileName
void RageTexture::GetFrameDimensionsFromFileName( CString sPath, int* piFramesWide, int* piFramesHigh )
{
*piFramesWide = *piFramesHigh = 1; // set default values in case we don't find the dimension in the file name
sPath.MakeLower();
const CString sFName = SetExtension( sPath, "" );
CStringArray arrayBits;
split( sFName, " ", arrayBits, false );
/* XXX: allow dims to be in parens */
for( unsigned i=0; i<arrayBits.size(); i++ )
{
CString &sBit = arrayBits[ i ];
// Test to see if it looks like "%ux%u" (e.g. 16x8)
CStringArray arrayDimensionsBits;
split( sBit, "x", arrayDimensionsBits, false );
if( arrayDimensionsBits.size() != 2 )
continue;
else if( !IsAnInt(arrayDimensionsBits[0]) || !IsAnInt(arrayDimensionsBits[1]) )
continue;
*piFramesWide = atoi(arrayDimensionsBits[0]);
*piFramesHigh = atoi(arrayDimensionsBits[1]);
return;
}
}
示例2: Init
void Dialog::Init()
{
if( g_pImpl != NULL )
return;
CString drivers = "win32,cocoa,null";
CStringArray DriversToTry;
split(drivers, ",", DriversToTry, true);
ASSERT( DriversToTry.size() != 0 );
CString Driver;
for( unsigned i = 0; g_pImpl == NULL && i < DriversToTry.size(); ++i )
{
try {
Driver = DriversToTry[i];
#if defined(HAVE_DIALOG_WIN32)
if( !DriversToTry[i].CompareNoCase("Win32") ) g_pImpl = new DialogDriver_Win32;
#endif
if( !DriversToTry[i].CompareNoCase("Null") ) g_pImpl = new DialogDriver_Null;
}
catch( const RageException &e )
{
if( LOG )
LOG->Info("Couldn't load driver %s: %s", DriversToTry[i].c_str(), e.what());
}
}
/* DialogDriver_Null should have worked, at least. */
ASSERT( g_pImpl != NULL );
}
示例3: GetDirListing
void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo )
{
LockMut( *g_Mutex );
NormalizePath( sPath );
for( unsigned i = 0; i < g_Drivers.size(); ++i )
{
LoadedDriver &ld = g_Drivers[i];
const CString p = ld.GetPath( sPath );
if( p.size() == 0 )
continue;
const unsigned OldStart = AddTo.size();
g_Drivers[i].driver->GetDirListing( p, AddTo, bOnlyDirs, bReturnPathToo );
/* If returning the path, prepend the mountpoint name to the files this driver returned. */
if( bReturnPathToo )
for( unsigned j = OldStart; j < AddTo.size(); ++j )
AddTo[j] = ld.MountPoint + AddTo[j];
}
/* More than one driver might return the same file. Remove duplicates (case-
* insensitively). */
sort( AddTo.begin(), AddTo.end(), ilt );
CStringArray::iterator it = unique( AddTo.begin(), AddTo.end(), ieq );
AddTo.erase(it, AddTo.end());
}
示例4: LoadSoundDir
bool RandomSample::LoadSoundDir( CString sDir, int iMaxToLoad )
{
if( sDir == "" )
return true;
#if 0
/* (don't want to do this just yet) */
/* If this is actually a directory, add a backslash to the filename,
* so we'll look for eg. themes\Default\sounds\sDir\*.mp3. Otherwise,
* don't, so we'll look for all of the files starting with sDir,
* eg. themes\Default\sounds\sDir*.mp3. */
if(IsADirectory(sDir) && sDir[sDir.GetLength()-1] != "/" )
sDir += "/";
#else
// make sure there's a slash at the end of this path
if( sDir.Right(1) != "/" )
sDir += "/";
#endif
CStringArray arraySoundFiles;
GetDirListing( sDir + "*.mp3", arraySoundFiles );
GetDirListing( sDir + "*.ogg", arraySoundFiles );
GetDirListing( sDir + "*.wav", arraySoundFiles );
random_shuffle( arraySoundFiles.begin(), arraySoundFiles.end() );
arraySoundFiles.resize( min( arraySoundFiles.size(), (unsigned)iMaxToLoad ) );
for( unsigned i=0; i<arraySoundFiles.size(); i++ )
LoadSound( sDir + arraySoundFiles[i] );
return true;
}
示例5: RefreshTree
void EditMetricsDlg::RefreshTree()
{
m_tree.DeleteAllItems();
iniBase.Reset();
iniBase.SetPath( "Themes\\default\\metrics.ini" );
iniBase.ReadFile();
iniTheme.Reset();
iniTheme.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" );
iniTheme.ReadFile();
IniFile iniCombined;
iniCombined.SetPath( "Themes\\default\\metrics.ini" );
iniCombined.ReadFile();
iniCombined.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" );
iniCombined.ReadFile();
CStringArray asKeys;
IniFile::const_iterator it;
for( it = iniCombined.begin(); it != iniCombined.end(); ++it )
asKeys.push_back( it->first );
SortCStringArray( asKeys );
for( unsigned i=0; i<asKeys.size(); i++ )
{
CString sKey = asKeys[i];
bool bInBase = iniBase.GetKey(sKey) != NULL;
bool bInTheme = iniTheme.GetKey(sKey) != NULL;
HTREEITEM item1 = m_tree.InsertItem( sKey );
SET_ITEM_STYLE( item1, bInBase, bInTheme );
const IniFile::key* pKey = iniCombined.GetKey( sKey );
CStringArray asNames;
for( IniFile::key::const_iterator val = pKey->begin(); val != pKey->end(); ++val )
{
CString sName = val->first, sValue = val->second;
asNames.push_back( sName );
}
SortCStringArray( asNames );
for( unsigned j=0; j<asNames.size(); j++ )
{
CString sName = asNames[j];
CString sValue;
iniCombined.GetValue( sKey, sName, sValue );
CString sThrowAway;
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
bool bInTheme = !!iniTheme.GetValue( sKey, sName, sThrowAway );
HTREEITEM item2 = m_tree.InsertItem( sName, item1 );
SET_ITEM_STYLE( item2, bInBase, bInTheme );
}
}
}
示例6: MountInitialFilesystems
void RageFileManager::MountInitialFilesystems()
{
/* Add file search paths, higher priority first. */
#if defined(XBOX)
RageFileManager::Mount( "dir", "D:\\", "" );
#elif defined(LINUX)
/* Absolute paths. This is rarely used, eg. by Alsa9Buf::GetSoundCardDebugInfo().
* All paths that start with a slash (eg. "/proc") should use this, so put it
* first. */
RageFileManager::Mount( "dir", "/", "/" );
/* We can almost do this, to have machine profiles be system-global to eg. share
* scores. It would need to handle permissions properly. */
/* RageFileManager::Mount( "dir", "/var/lib/games/stepmania", "Data/Profiles" ); */
// CString Home = getenv( "HOME" ) + "/" + PRODUCT_NAME;
/*
* Next: path to write general mutable user data. If the above path fails (eg.
* wrong permissions, doesn't exist), machine memcard data will also go in here.
* XXX: It seems silly to have two ~ directories. If we're going to create a
* directory on our own, it seems like it should be a dot directory, but it
* seems wrong to put lots of data (eg. music) in one. Hmm.
*/
/* XXX: create */
/* RageFileManager::Mount( "dir", Home + "." PRODUCT_NAME, "Data" ); */
/* Next, search ~/StepMania. This is where users can put music, themes, etc. */
/* RageFileManager::Mount( "dir", Home + PRODUCT_NAME, "" ); */
/* Search for a directory with "Songs" in it. Be careful: the CWD is likely to
* be ~, and it's possible that some users will have a ~/Songs/ directory that
* has nothing to do with us, so check the initial directory last. */
CString Root = "";
struct stat st;
if( Root == "" && !stat( DirOfExecutable + "/Songs", &st ) && st.st_mode&S_IFDIR )
Root = DirOfExecutable;
if( Root == "" && !stat( InitialWorkingDirectory + "/Songs", &st ) && st.st_mode&S_IFDIR )
Root = InitialWorkingDirectory;
if( Root == "" )
RageException::Throw( "Couldn't find \"Songs\"" );
RageFileManager::Mount( "dir", Root, "" );
#elif defined(_WINDOWS)
/* All Windows data goes in the directory one level above the executable. */
CHECKPOINT_M( ssprintf( "DOE \"%s\"", DirOfExecutable.c_str()) );
CStringArray parts;
split( DirOfExecutable, "/", parts );
CHECKPOINT_M( ssprintf( "... %i parts", parts.size()) );
ASSERT_M( parts.size() > 1, ssprintf("Strange DirOfExecutable: %s", DirOfExecutable.c_str()) );
CString Dir = join( "/", parts.begin(), parts.end()-1 );
RageFileManager::Mount( "dir", Dir, "" );
#else
/* Paths relative to the CWD: */
RageFileManager::Mount( "dir", ".", "" );
#endif
}
示例7: HasDateRef
//----------------------------------------
bool CUnit::HasDateRef(CDate* dateRef /*= NULL*/, CStringArray* array /*= NULL*/) const
{
if (!IsDate())
{
return false;
}
CStringArray ar;
ar.ExtractStrings(GetText().c_str(), ' ');
size_t len = ar.size();
if (len <= 2)
{
return false;
}
int32_t index = ar.FindIndex("since");
if (index < 0)
{
return false;
}
CDate dateTmp;
int32_t result = BRATHL_ERROR;
std::string strDate;
for (uint32_t i = index + 1 ; i < ar.size() ; i++)
{
strDate.append(ar.at(i));
strDate.append(" ");
}
strDate = CTools::StringTrim(strDate);
result = dateTmp.SetDate(strDate.c_str());
if (result == BRATHL_SUCCESS)
{
if (dateRef != NULL)
{
*dateRef = dateTmp;
}
}
if (array != NULL)
{
array->Insert(ar);
}
return (result == BRATHL_SUCCESS);
}
示例8: SetList
/* Add the list named "ListName" to the given row/handler. */
void ScreenOptionsMaster::SetList( OptionRowData &row, OptionRowHandler &hand, const CString &ListName, CString &TitleOut )
{
hand.type = ROW_LIST;
TitleOut = ListName;
if( !ListName.CompareNoCase("noteskins") )
{
hand.Default.Init(); /* none */
row.bOneChoiceForAllPlayers = false;
CStringArray arraySkinNames;
NOTESKIN->GetNoteSkinNames( arraySkinNames );
ModeChoice mc;
for( unsigned skin=0; skin<arraySkinNames.size(); skin++ )
{
arraySkinNames[skin].MakeUpper();
mc.m_sModifiers = arraySkinNames[skin];
hand.ListEntries.push_back( mc );
row.choices.push_back( arraySkinNames[skin] );
}
return;
}
hand.Default.Load( -1, ENTRY_DEFAULT(ListName) );
/* Parse the basic configuration metric. */
CStringArray asParts;
split( ENTRY(ListName), ",", asParts );
if( asParts.size() < 1 )
RageException::Throw( "Parse error in ScreenOptionsMasterEntries::ListName%s", ListName.c_str() );
row.bOneChoiceForAllPlayers = false;
const int NumCols = atoi( asParts[0] );
for( unsigned i=0; i<asParts.size(); i++ )
{
if( asParts[i].CompareNoCase("together") == 0 )
row.bOneChoiceForAllPlayers = true;
else if( asParts[i].CompareNoCase("multiselect") == 0 )
row.bMultiSelect = true;
}
for( int col = 0; col < NumCols; ++col )
{
ModeChoice mc;
mc.Load( 0, ENTRY_MODE(ListName, col) );
if( mc.m_sName == "" )
RageException::Throw( "List \"%s\", col %i has no name", ListName.c_str(), col );
if( !mc.IsPlayable() )
continue;
hand.ListEntries.push_back( mc );
CString sChoice = ENTRY_NAME(mc.m_sName);
row.choices.push_back( sChoice );
}
}
示例9: Set
void ParsedCommand::Set( const CString &sCommand )
{
CStringArray vsTokens;
split( sCommand, ",", vsTokens, false ); // don't ignore empty
vTokens.resize( vsTokens.size() );
for( unsigned j=0; j<vsTokens.size(); j++ )
vTokens[j].Set( vsTokens[j] );
}
示例10: ParseCommands
void ParseCommands( const CString &sCommands, vector<ParsedCommand> &vCommandsOut )
{
vCommandsOut.clear();
CStringArray vsCommands;
split( sCommands, ";", vsCommands, true ); // do ignore empty
vCommandsOut.resize( vsCommands.size() );
for( unsigned i=0; i<vsCommands.size(); i++ )
vCommandsOut[i].Set( vsCommands[i] );
}
示例11: RageMatrixCommand
void RageMatrixCommand( CString sCommandString, RageMatrix &mat )
{
CStringArray asCommands;
split( sCommandString, ";", asCommands, true );
for( unsigned c=0; c<asCommands.size(); c++ )
{
CStringArray asTokens;
split( asCommands[c], ",", asTokens, true );
int iMaxIndexAccessed = 0;
#define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed))
#define fParam(i) (strtof(sParam(i),NULL))
#define iParam(i) (atoi(sParam(i)))
#define bParam(i) (iParam(i)!=0)
CString& sName = asTokens[0];
sName.MakeLower();
RageMatrix b;
// Act on command
if( sName=="x" ) RageMatrixTranslation( &b, fParam(1),0,0 );
else if( sName=="y" ) RageMatrixTranslation( &b, 0,fParam(1),0 );
else if( sName=="z" ) RageMatrixTranslation( &b, 0,0,fParam(1) );
else if( sName=="zoomx" ) RageMatrixScaling(&b, fParam(1),1,1 );
else if( sName=="zoomy" ) RageMatrixScaling(&b, 1,fParam(1),1 );
else if( sName=="zoomz" ) RageMatrixScaling(&b, 1,1,fParam(1) );
else if( sName=="rotationx" ) RageMatrixRotationX( &b, fParam(1) );
else if( sName=="rotationy" ) RageMatrixRotationY( &b, fParam(1) );
else if( sName=="rotationz" ) RageMatrixRotationZ( &b, fParam(1) );
else
{
CString sError = ssprintf( "MatrixCommand: Unrecognized matrix command name '%s' in command string '%s'.", sName.c_str(), sCommandString.c_str() );
LOG->Warn( sError );
Dialog::OK( sError );
continue;
}
if( iMaxIndexAccessed != (int)asTokens.size()-1 )
{
CString sError = ssprintf( "MatrixCommand: Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).c_str(), iMaxIndexAccessed+1, (int)asTokens.size() );
LOG->Warn( sError );
Dialog::OK( sError );
continue;
}
RageMatrix a(mat);
RageMatrixMultiply(&mat, &a, &b);
}
}
示例12: ParseCommands
void ParseCommands( const CString &sCommands, Commands &vCommandsOut )
{
CStringArray vsCommands;
split( sCommands, ";", vsCommands, true ); // do ignore empty
vCommandsOut.v.resize( vsCommands.size() );
for( unsigned i=0; i<vsCommands.size(); i++ )
{
Command &cmd = vCommandsOut.v[i];
cmd.Load( vsCommands[i] );
}
}
示例13: GetAnnouncerNames
void AnnouncerManager::GetAnnouncerNames( CStringArray& AddTo )
{
GetDirListing( ANNOUNCERS_DIR+"*", AddTo, true );
// strip out the folder called "CVS" and EMPTY_ANNOUNCER_NAME
for( int i=AddTo.size()-1; i>=0; i-- )
if( !stricmp( AddTo[i], "cvs" ) )
AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 );
for( int i=AddTo.size()-1; i>=0; i-- )
if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) )
AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 );
}
示例14: LoadFromDir
bool SMLoader::LoadFromDir( CString sPath, Song &out )
{
CStringArray aFileNames;
GetApplicableFiles( sPath, aFileNames );
if( aFileNames.size() > 1 )
RageException::Throw( "There is more than one SM file in '%s'. There should be only one!", sPath.c_str() );
/* We should have exactly one; if we had none, we shouldn't have been
* called to begin with. */
ASSERT( aFileNames.size() == 1 );
return LoadFromSMFile( sPath + aFileNames[0], out );
}
示例15: IsPackMountable
bool UserPackManager::IsPackMountable( const CString &sPack, CString &sError )
{
RageFileDriverZip *pZip = new RageFileDriverZip;
if ( !pZip->Load(sPack) )
{
sError = "not a valid zip file";
SAFE_DELETE( pZip );
return false;
}
for( unsigned i = 0; i < NUM_BLACKLISTED_FOLDERS && BLACKLISTED_FOLDERS[i] != NULL; i++ )
{
CString sDir = CString("/") + BLACKLISTED_FOLDERS[i];
CStringArray sDirListing;
pZip->GetDirListing( sDir, sDirListing, false, true );
int iListSize = sDirListing.size();
// if any blacklisted folders exist, reject the pack
if ( iListSize > 0 )
{
sError = ssprintf( "blacklisted folder: %s", BLACKLISTED_FOLDERS[i] );
SAFE_DELETE( pZip );
return false;
}
}
// do not add if it's just folders of individual songs without a group folder
CStringArray asRootFolders;
pZip->GetDirListing( "/*", asRootFolders, true, false );
for( unsigned i = 0; i < asRootFolders.size(); i++ )
{
CStringArray asFiles;
pZip->GetDirListing( "/" + asRootFolders[i] + "/*.sm", asFiles, false, false );
pZip->GetDirListing( "/" + asRootFolders[i] + "/*.dwi", asFiles, false, false );
if ( asFiles.size() > 0 )
{
sError = "Package is not a group folder package.\nPlease add songs to a single group folder.\n(i.e. {Group Name}/{Song Folder}/Song.sm)";
SAFE_DELETE( pZip );
return false;
}
}
SAFE_DELETE( pZip );
return true;
}