• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/include/paramUtil.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
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

Generated on Fri Oct 22 2010 11:02:25 for SST by  doxygen 1.7.1