00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _PARAMUTIL_H
00015 #define _PARAMUTIL_H
00016
00017 #include <errno.h>
00018 #include <sst/core/component.h>
00019
00020 inline long str2long( std::string str )
00021 {
00022 long value = strtol( str.c_str(), NULL, 0 );
00023 if ( errno == EINVAL ) {
00024 _abort(XbarV2,"strtol( %s, NULL, 10\n", str.c_str());
00025 }
00026 return value;
00027 }
00028
00029
00030 inline void printParams( SST::Component::Params_t& params )
00031 {
00032 SST::Component::Params_t::iterator it = params.begin();
00033 while( it != params.end() ) {
00034 printf("key=%s value=%s\n", it->first.c_str(),it->second.c_str());
00035 ++it;
00036 }
00037 }
00038
00039 inline void findParams( std::string prefix, SST::Component::Params_t in,
00040 SST::Component::Params_t& out )
00041 {
00042 SST::Component::Params_t::iterator it = in.begin();
00043 while( it != in.end() )
00044 {
00045 if ( it->first.find( prefix.c_str(), 0, prefix.length() ) == 0 ) {
00046 std::string key = it->first.substr( prefix.length() );
00047 out[key] = it->second;
00048 }
00049 ++it;
00050 }
00051 }
00052
00053 #endif