00001 #include "ObjectivityOptionParser.h" 00002 00003 #ifdef OLDSTREAMS 00004 # include <strstream> 00005 # define istringstream istrstream 00006 #else 00007 # include <sstream> 00008 #endif 00009 00010 static const std::string defaultDatabaseName = "System"; 00011 static const std::string defaultContainerName = "HepSystem"; 00012 static const std::string namingEnabled_keyword = "--useNaming"; 00013 00014 Anaphe::AIDA_ObjectivityStore::ObjectivityOptionParser::ObjectivityOptionParser( const std::string& options ): 00015 m_namingEnabled( false ) 00016 { 00017 if ( options.find( namingEnabled_keyword ) != std::string::npos ) m_namingEnabled = true; 00018 } 00019 00020 00021 std::pair< std::string, std::string > 00022 Anaphe::AIDA_ObjectivityStore::ObjectivityOptionParser::topLevelDatabaseAndContainer( const std::string& name ) const 00023 { 00024 std::string db = ""; 00025 std::string cont = ""; 00026 00027 std::string::size_type idx = name.find( ":" ); 00028 if ( idx != std::string::npos && idx != 0 ) { 00029 std::istringstream is( name.substr(0, idx).c_str() ); 00030 if ( ! is.eof() ) { 00031 is >> db; 00032 std::istringstream iss( name.substr( idx + 1 ).c_str() ); 00033 if ( ! iss.eof() ) iss >> cont; 00034 } 00035 } 00036 else { 00037 std::istringstream is( name.c_str() ); 00038 is >> db; 00039 } 00040 00041 std::istringstream is( name.c_str() ); 00042 00043 if ( db == "" ) db = defaultDatabaseName; 00044 if ( cont == "" ) cont = defaultContainerName; 00045 return std::make_pair( db, cont ); 00046 } 00047 00048 00049 bool 00050 Anaphe::AIDA_ObjectivityStore::ObjectivityOptionParser::isNamingEnabled() const 00051 { 00052 return m_namingEnabled; 00053 }