57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#include "externals.hh"
|
|
#include "c-project.hh"
|
|
|
|
|
|
/*= A_ProjectPathListener ====================================================*/
|
|
|
|
A_ProjectPathListener::~A_ProjectPathListener( ) {}
|
|
|
|
|
|
/*= T_Project ================================================================*/
|
|
|
|
void T_Project::setBasePath(
|
|
T_String const& path ) noexcept
|
|
{
|
|
if ( !path || path[ path.length( ) - 1 ] != '/' ) {
|
|
setBasePathInternal( path );
|
|
} else {
|
|
setBasePathInternal( path.substr( 0 , path.length( ) - 1 ) );
|
|
}
|
|
}
|
|
|
|
void T_Project::setBasePathInternal(
|
|
T_String path ) noexcept
|
|
{
|
|
if ( ( path && basePath_ == path )
|
|
|| ( !path && basePath_ == "." ) ) {
|
|
return;
|
|
}
|
|
if ( !path ) {
|
|
basePath_ = T_String::Pooled( "." );
|
|
} else {
|
|
basePath_ = std::move( path );
|
|
}
|
|
|
|
const auto n{ listeners_.size( ) };
|
|
for ( auto i = 0u ; i < n ; i ++ ) {
|
|
listeners_[ i ]->projectPathChanged( );
|
|
}
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
T_String T_Project::pathOf(
|
|
T_String const& file ) const noexcept
|
|
{
|
|
T_StringBuilder sb;
|
|
sb << basePath_ << '/' << file;
|
|
return std::move( sb );
|
|
}
|
|
|
|
T_String T_Project::pathOf(
|
|
char const* file ) const noexcept
|
|
{
|
|
T_StringBuilder sb;
|
|
sb << basePath_ << '/' << file;
|
|
return std::move( sb );
|
|
}
|