diff options
Diffstat (limited to 'tester/covoar/TargetFactory.cc')
-rw-r--r-- | tester/covoar/TargetFactory.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tester/covoar/TargetFactory.cc b/tester/covoar/TargetFactory.cc index 57ba686..0b6be52 100644 --- a/tester/covoar/TargetFactory.cc +++ b/tester/covoar/TargetFactory.cc @@ -37,11 +37,9 @@ namespace Target { //! typedef struct { //! This is the string found in configuration to match. - const char *theTarget; + std::string theTarget; //! This is the static wrapper for the constructor. - TargetBase *(*theCtor)( - std::string - ); + TargetBase *(*theCtor)( std::string ); } FactoryEntry_t; //! @@ -60,27 +58,27 @@ namespace Target { { "powerpc", Target_powerpc_Constructor }, { "sparc", Target_sparc_Constructor }, { "riscv", Target_riscv_Constructor }, - { "TBD", NULL }, + { "TBD", NULL } }; - TargetBase* TargetFactory( - std::string targetName - ) + TargetBase* TargetFactory( std::string targetName ) { size_t i; std::string cpu; i = targetName.find( '-' ); - if ( i == targetName.npos ) + if ( i == targetName.npos ) { cpu = targetName; - else + } else { cpu = targetName.substr( 0, i ); + } - // fprintf( stderr, "%s --> %s\n", targetName.c_str(), cpu.c_str()); + // std::cerr << targetName << " --> " << cpu << std::endl; // Iterate over the table trying to find an entry with a matching name - for ( i=0 ; i < sizeof(FactoryTable) / sizeof(FactoryEntry_t); i++ ) { - if ( !strcmp(FactoryTable[i].theTarget, cpu.c_str() ) ) + for ( i = 0 ; i < sizeof( FactoryTable ) / sizeof( FactoryEntry_t ); i++) { + if ( FactoryTable[i].theTarget == cpu ) { return FactoryTable[i].theCtor( targetName ); + } } std::ostringstream what; |