本文整理汇总了C++中Path::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::Clear方法的具体用法?C++ Path::Clear怎么用?C++ Path::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelectDirectory
const Path Browser::SelectDirectory()
{
Path path;
path.Reserve( MAX_PATH*2 );
Object::Pod<BROWSEINFO> bi;
bi.hwndOwner = Application::Instance::GetActiveWindow();
bi.pszDisplayName = path.Ptr();
bi.ulFlags = BIF_RETURNONLYFSDIRS;
if (LPITEMIDLIST const idl = ::SHBrowseForFolder( &bi ))
{
if (::SHGetPathFromIDList( idl, path.Ptr() ) && path.Validate())
path.MakePretty( true );
else
path.Clear();
IMalloc* pMalloc;
if (SUCCEEDED(::SHGetMalloc( &pMalloc )))
{
pMalloc->Free( idl );
pMalloc->Release();
}
}
else
{
path.Clear();
}
return path;
}
示例2: SaveFile
const Path Browser::SaveFile(wchar_t* const filter,Path initial)
{
Path path;
path.Reserve( MAX_PATH*2 );
const Path extension( initial.Extension() );
if (initial.File().Length() && initial.File()[0] != '.')
path = initial.File();
initial.File().Clear();
Object::Pod<OPENFILENAME> ofn;
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = Application::Instance::GetActiveWindow();
ofn.lpstrFile = path.Ptr();
ofn.nMaxFile = path.Capacity();
ofn.lpstrInitialDir = initial.Length() ? initial.Ptr() : L".";
ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
if (filter)
{
for (uint i=0; filter[i]; ++i)
{
if (filter[i] == '\t')
filter[i] = '\0';
}
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
}
if (extension.Length())
ofn.lpstrDefExt = extension.Ptr();
if (::GetSaveFileName( &ofn ))
path.Validate();
else
path.Clear();
return path;
}
示例3: OpenFile
const Path Browser::OpenFile(wchar_t* const filter,const Path dir,const Path ext)
{
for (uint i=0; filter[i]; ++i)
{
if (filter[i] == '\t')
filter[i] = '\0';
}
Path path;
path.Reserve( MAX_PATH*2 );
Object::Pod<OPENFILENAME> ofn;
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = Application::Instance::GetActiveWindow();
ofn.lpstrFile = path.Ptr();
ofn.nMaxFile = path.Capacity();
ofn.lpstrInitialDir = dir.Length() ? dir.Ptr() : L".";
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
if (filter)
{
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
}
if (ext.Length())
ofn.lpstrDefExt = ext.Ptr();
if (::GetOpenFileName( &ofn ))
path.Validate();
else
path.Clear();
return path;
}
示例4: FindBestPathToTile
void Map::FindBestPathToTile( const Unit* unit, const Vec2s& tilePos, Path& result )
{
std::vector< PrimaryDirection > reverseDirections;
int searchIndex = ReserveSearchIndex();
// Clear the list of results.
result.Clear();
result.SetOrigin( unit->GetTilePos() );
// Clear the open list.
mOpenList.clear();
// Get the Unit's current Tile and type.
Iterator originTile = unit->GetTile();
UnitType* unitType = unit->GetUnitType();
MovementType* movementType = unit->GetMovementType();
// Get the starting movement range of the Unit.
int movementRange = unit->GetMovementRange();
// Add the origin tile to the open list.
originTile->Open( searchIndex );
originTile->SetPreviousTileDirection( PrimaryDirection::NONE );
originTile->SetBestTotalCostToEnter( 0 );
mOpenList.insert( 0, originTile );
while( !mOpenList.isEmpty() )
{
// Pop the first element off the open list.
Map::Iterator tile = mOpenList.popMinElement();
if( tile.GetPosition() != tilePos )
{
// If this isn't the goal tile, close it.
tile->Close( searchIndex );
for( int i = 0; i < CARDINAL_DIRECTION_COUNT; ++i )
{
// Determine the direction to search.
PrimaryDirection direction = CARDINAL_DIRECTIONS[ i ];
// If the adjacent tile isn't in the previous direction, get the adjacent tile.
Iterator adjacent = tile.GetAdjacent( direction );
if( adjacent.IsValid() && !adjacent->IsClosed( searchIndex ) )
{
// If the adjacent tile is valid and isn't already closed, get the TerrainType of the adjacent tile.
TerrainType* adjacentTerrainType = adjacent->GetTerrainType();
if( movementType->CanMoveAcrossTerrain( adjacentTerrainType ) )
{
// If the adjacent tile is passable, find the total cost of entering the tile.
int costToEnterAdjacent = movementType->GetMovementCostAcrossTerrain( adjacentTerrainType );
int adjacentTotalCost = ( tile->GetBestTotalCostToEnter() + costToEnterAdjacent );
int distanceToGoal = ( originTile.GetPosition().GetManhattanDistanceTo( tilePos ) );
int adjacentWeight = ( adjacentTotalCost + distanceToGoal );
if( adjacentTotalCost <= movementRange )
{
if( !adjacent->IsOpen( searchIndex ) )
{
// If the tile info isn't already on the open list, add it.
adjacent->SetPreviousTileDirection( direction.GetOppositeDirection() );
adjacent->SetBestTotalCostToEnter( adjacentTotalCost );
mOpenList.insert( adjacentWeight, adjacent );
}
else if( adjacentTotalCost < adjacent->GetBestTotalCostToEnter() )
{
// If the node is already on the open list but has a larger total cost,
// update the value.
adjacent->SetPreviousTileDirection( direction.GetOppositeDirection() );
adjacent->SetBestTotalCostToEnter( adjacentTotalCost );
mOpenList.update( adjacentWeight, adjacent );
}
}
}
}
}
}
else
{
// If this is the goal tile, construct the path to the location.
PrimaryDirection previousDirection = tile->GetPreviousTileDirection();
while( previousDirection != PrimaryDirection::NONE )
{
// Construct the list of directions from the goal back to the origin tile.
reverseDirections.push_back( previousDirection );
tile = tile.GetAdjacent( previousDirection );
previousDirection = tile->GetPreviousTileDirection();
}
// End the search.
break;
}
}
for( auto it = reverseDirections.rbegin(); it != reverseDirections.rend(); ++it )
{
// Construct the path by reversing the directions from the goal to the origin.
//.........这里部分代码省略.........