本文整理汇总了C++中VArray类的典型用法代码示例。如果您正苦于以下问题:C++ VArray类的具体用法?C++ VArray怎么用?C++ VArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __glob_gdn
void __glob_gdn( const char* a_path, const char* a_fnpattern,
VArray &a_va ) // glob getdirname
{
VString pat = a_fnpattern;
pat += "*";
a_va.undef();
DIR *dir;
dirent *de;
if ( !a_path || a_path[0] == 0 )
dir = opendir(".");
else
dir = opendir( a_path );
if (dir)
{
while ( (de = readdir(dir)) )
{
if ( strcmp( de->d_name, "." ) == 0 ||
strcmp( de->d_name, ".." ) == 0 ) continue;
if ( a_fnpattern[0] == 0 || FNMATCH( pat, de->d_name)==0 )
{
VString str; // = a_path;
str += de->d_name;
if ( file_is_dir( a_path + str ) )
{
str += "/";
a_va.push(str);
}
}
}
closedir(dir);
}
}
示例2: str_split_simple
// split `source' with exact string `delimiter_str'
VArray str_split_simple( const char* delimiter_str, const char* source, int maxcount )
{
VArray arr;
const char* ps = source;
const char* fs;
int rl = strlen( delimiter_str );
VString s;
while( (fs = strstr( ps, delimiter_str )) )
{
if ( maxcount != -1 )
{
maxcount--;
if ( maxcount == 0 ) break;
}
int l = fs - ps;
s.setn( ps, l );
arr.push( s );
ps = (const char *)(ps + l + rl);
}
if ( ps && ps[0] )
arr.push( ps );
return arr;
}
示例3: str_split
// split `source' with `regexp_str' regexp
VArray str_split( const char* regexp_str, const char* source, int maxcount )
{
VArray arr;
VRegexp re;
int z = re.comp( regexp_str );
ASSERT( z );
if ( ! z ) return arr;
const char* ps = source;
while( ps && ps[0] && re.m( ps ) )
{
if ( maxcount != -1 )
{
maxcount--;
if ( maxcount == 0 ) break;
}
VString s;
s.setn( ps, re.sub_sp( 0 ) );
arr.push( s );
ps += re.sub_ep( 0 );
}
if ( ps && ps[0] )
arr.push( ps );
return arr;
}
示例4: vfu_load_dir_colors
void vfu_load_dir_colors()
{
#ifdef _TARGET_UNIX_
VArray va;
va.fload( "/etc/DIR_COLORS" );
if (va.count() == 0) return;
while( va.count() )
{
VString str = va[0];
va.del( 0 );
int comment = str_find( str, '#' );
if ( comment != -1 ) str_sleft( str, comment );
str_cut( str, " \t" );
if ( str_len( str ) == 0 ) continue;
if ( strncmp( str, "TERM " , 5 ) == 0 ) continue;
if ( strncmp( str, "COLOR " , 6 ) == 0 ) continue;
if ( strncmp( str, "OPTIONS ", 8 ) == 0 ) continue;
int pos = -1;
if ( str_find( str, "31" ) != -1 ) pos = cRED; else
if ( str_find( str, "32" ) != -1 ) pos = cGREEN; else
if ( str_find( str, "33" ) != -1 ) pos = cYELLOW; else
if ( str_find( str, "34" ) != -1 ) pos = cBLUE; else
if ( str_find( str, "35" ) != -1 ) pos = cMAGENTA; else
if ( str_find( str, "36" ) != -1 ) pos = cCYAN; else
if ( str_find( str, "37" ) != -1 ) pos = cWHITE; else
;
int spc = str_find( str, ' ' );
if ( spc == -1 || pos == -1 ) continue;
str_sleft( str, spc );
str_replace( str, "DIR", ".[].<>" );
str_replace( str, "LINK", ".->" );
str_replace( str, "FIFO", ".()" );
str_replace( str, "SOCK", ".##" );
str_replace( str, "BLK", ".==" );
str_replace( str, "CHR", ".++" );
str_replace( str, "EXEC", ".**" );
str_ins( ext_colors[pos], 0, str );
};
for ( int z = 0; z < 16; z++ )
if( str_len( ext_colors[z] ) > 0 )
{
ext_colors[z] += ".";
if ( opt.lower_case_ext_config )
str_low( ext_colors[z] );
}
#endif /* _TARGET_UNIX_ */
}
示例5: str_join
// join array data to single string with `glue' string
// returns the result string or store to optional `dest'
VString str_join( VArray array, const char* glue )
{
VString str;
for( int z = 0; z < array.count()-1; z++ )
{
str += array.get( z );
str += glue;
}
str += array.get( array.count()-1 );
return str;
}
示例6: set_arr
int set_arr( const char *line, const char *keyword, VArray &target )
{
VRegexp re("^[ \011]*([a-zA-Z0-9]+)[ \011]*=[ \011]*(.+)");
if ( ! re.m( line ) ) return 0;
if ( str_low( re[1] ) != keyword ) return 0;
target.push( re[2] );
return 1;
}
示例7: if
void VThumbnailManager::ProcessPendingThumbnails()
{
if (s_PendingTasks.GetSize() == 0)
return;
PendingThumbnail& pendingThumbnail = s_PendingTasks[0];
VLoadingTask* pTask = pendingThumbnail.spTask;
if (pTask->GetState() == TASKSTATE_UNASSIGNED)
{
pTask->ScheduleLoadingTask();
}
else if (pTask->GetState() == TASKSTATE_FINISHED)
{
VArray<VSceneListEntry>& list = pendingThumbnail.pDataProvider->GetData();
int iEntryIndex = list.Find(pendingThumbnail.entry); // entry might have been moved or deleted in the meantime
if (iEntryIndex >= 0)
{
VSceneListEntry& entry = list[iEntryIndex];
if (pTask->IsValid())
{
VASSERT(pTask->IsLoaded());
entry.spThumbnail = Vision::TextureManager.Load2DTexture(pendingThumbnail.sFileName,
VTM_FLAG_DEFAULT_NON_MIPMAPPED|VTM_FLAG_NO_DOWNSCALE);
}
else
{
entry.spThumbnail = s_spDefaultThumbnail;
}
VSceneListEvent data(&pendingThumbnail.pDataProvider->m_OnDataChanged, -1, iEntryIndex, VSceneListEvent::DATA_CHANGED);
data.Trigger();
}
s_PendingTasks.RemoveAt(0);
}
}
示例8: ComputePath
bool vHavokAiModule::ComputePath(hkvVec3* startPoint, hkvVec3* endPoint, float radius, VArray<hkvVec3>& pathPoints) const
{
hkaiPathfindingUtil::FindPathInput input(1);
hkaiPathfindingUtil::FindPathOutput output;
if(!_ComputePath(m_aiWorld, startPoint, endPoint, radius, input, output))
return false;
for (int i = 0; i < output.m_pathOut.getSize(); i++)
{
const hkaiPath::PathPoint& pt = output.m_pathOut[i];
hkvVec3 vPos; vHavokConversionUtils::PhysVecToVisVecWorld(pt.m_position, vPos);
pathPoints.Add(vPos);
}
return true;
}
示例9: havokStreamReader
bool vHavokAiModule::LoadNavMeshDeprecated(const char* filename, VArray<vHavokAiNavMeshInstance*>* navMeshInstancesOut)
{
if (!Vision::File.Exists(filename))
{
return false;
}
vHavokStreamReader havokStreamReader(filename);
if (!havokStreamReader.isOk())
{
return false;
}
hkBufferedStreamReader bufferedStreamReader(&havokStreamReader);
if (!bufferedStreamReader.isOk())
{
return false;
}
VArray<vHavokAiNavMeshResource*> navMeshResources;
{
hkArray< hkRefPtr<hkaiNavMesh> > navMeshes;
hkArray< hkRefPtr<hkaiNavMeshQueryMediator> > mediators;
hkObjectResource* res = hkSerializeUtil::loadOnHeap(&bufferedStreamReader);
hkRootLevelContainer* container = res->getContents<hkRootLevelContainer>();
if (container)
{
hkaiNavMesh* navMesh = container->findObject<hkaiNavMesh>();
hkaiNavMeshQueryMediator* mediator = container->findObject<hkaiStaticTreeNavMeshQueryMediator>();
while(navMesh)
{
navMeshes.pushBack(navMesh);
mediators.pushBack(mediator);
navMesh = container->findObject<hkaiNavMesh>(navMesh);
mediator = container->findObject<hkaiStaticTreeNavMeshQueryMediator>(mediator);
}
}
else
{
// dkw.note: loading legacy asset that didn't use a hkRootLevelContainer
hkaiNavMesh* navMesh = res->getContents<hkaiNavMesh>();
if (navMesh == HK_NULL)
{
return false;
}
navMeshes.pushBack(navMesh);
mediators.pushBack(HK_NULL);
}
res->removeReference();
if (navMeshes.getSize() == 0)
{
return false;
}
for (int i = 0; i < navMeshes.getSize(); i++)
{
if (mediators[i] == HK_NULL)
{
VASSERT(navMeshes[i]->getReferenceCount() == 1);
mediators[i].setAndDontIncrementRefCount(hkaiNavMeshUtils::setupQueryMediator( *navMeshes[i] ));
}
else
{
VASSERT(navMeshes[i]->getReferenceCount() == 2);
}
VASSERT(mediators[i]->getReferenceCount() == 1);
vHavokAiNavMeshResource* resource = new vHavokAiNavMeshResource(navMeshes[i], mediators[i]);
VASSERT(navMeshes[i]->getReferenceCount() == 3);
VASSERT(mediators[i]->getReferenceCount() == 2);
navMeshResources.Add(resource);
}
}
VArray<vHavokAiNavMeshInstance*> navMeshInstancesLocal;
VArray<vHavokAiNavMeshInstance*>* navMeshInstancesPtr;
if (navMeshInstancesOut != HK_NULL)
{
navMeshInstancesPtr = navMeshInstancesOut;
}
else
{
navMeshInstancesPtr = &navMeshInstancesLocal;
}
hkaiWorld* aiWorld = GetAiWorld();
for (int i = 0; i < navMeshResources.GetLength(); i++)
{
VASSERT(navMeshResources[i]->GetNavMesh()->getReferenceCount() == 2);
VASSERT(navMeshResources[i]->GetNavMeshQueryMediator()->getReferenceCount() == 1);
vHavokAiNavMeshInstance* navMeshInstance = new vHavokAiNavMeshInstance(navMeshResources[i], i);
VASSERT(navMeshResources[i]->GetNavMesh()->getReferenceCount() == 3);
VASSERT(navMeshResources[i]->GetNavMeshQueryMediator()->getReferenceCount() == 1);
navMeshInstance->AddNavMeshToWorld(aiWorld);
//.........这里部分代码省略.........
示例10: Update
void Update(VArray<float>& values) { values.Append(Vision::GetTimer()->GetTimeDifference()); }
示例11: vfu_extract_files
void vfu_extract_files( int one )
{
if ( sel_count == 0 && one == 0 ) one = 1;
char t[MAX_PATH];
VString target;
if ( one == 0 )
sprintf( t, "EXTRACT SELECTION to: " );
else
sprintf( t, "EXTRACT `%s' to:", files_list[FLI]->full_name() );
target = opt.last_copy_path[ CM_COPY ];
if ( !vfu_get_dir_name( t, target ) ) return;
strcpy( opt.last_copy_path[ CM_COPY ], target );
VArray va;
int z;
for( z = 0; z < files_count; z++ )
if ((files_list[z]->sel && one == 0) || (z == FLI && one != 0))
va.push( files_list[z]->full_name() );
if (chdir(target))
{
sprintf( t, "Cannot chdir to: %s", target.data() );
say1( t );
say2errno();
return;
}
VString tmpfile = vfu_temp();
if (va.fsave( tmpfile ))
{
sprintf( t, "Error writing list file: %s", tmpfile.data() );
say1( t );
return;
}
chmod( tmpfile, S_IRUSR|S_IWUSR );
VString s;
s = "rx_auto x \"";
s += work_path;
s += archive_name;
s += "\" @";
s += tmpfile;
s += " 2> /dev/null";
vfu_shell( s, "" );
if (unlink( tmpfile ))
{
/*
sprintf( t, "Cannot unlink/erase temp file: %s", tmpfile );
say2( t );
*/
}
if (chdir(work_path))
{
sprintf( t, "Cannot chdir back to to: %s", work_path.data() );
say1( t );
say2errno();
return;
}
say1( "EXTRACT ok." );
};
示例12: if
// Comparison operators.
inline bool operator==(const VArray& rhs) { int n=GetLength(); if(n!=rhs.GetLength()) return false; for(int i=0; i<n; ++i) { if((*this)[i] != rhs[i]) return false; } return true; }
示例13: AddRenderStateContainerToWrite
int AddRenderStateContainerToWrite (VRenderStateContainer* pRenderState)
{
int i = 0;
for (; i < m_RenderStateContainersToWrite.GetLength (); ++i)
{
if (m_RenderStateContainersToWrite[i] == pRenderState)
return (i);
}
m_RenderStateContainersToWrite.Add (pRenderState);
return (i);
}
示例14: DeInit
void VThumbnailManager::DeInit()
{
if (s_PendingTasks.GetSize() > 0)
{
VLoadingTask* pTask = s_PendingTasks[0].spTask;
Vision::GetThreadManager()->WaitForTask(pTask, true);
}
s_PendingTasks.Reset();
s_spDefaultThumbnail = NULL;
s_spLoadingThumbnail = NULL;
}
示例15: size_cache_set
void size_cache_set( const char *s, fsize_t size, int sort )
{
int z = size_cache_index( s );
if ( z != -1 )
{
size_cache.set( z, size_cache_compose_key( s, size ) );
}
else
{
size_cache.push( size_cache_compose_key( s, size ) );
if( sort )
size_cache.sort( 0, size_cache_cmp );
}
}