Public Member Functions | Private Attributes | List of all members
dbutils::SimpleParameterSet Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/DatabaseUtils/cxx/include/SimpleParameterSet.h"

Public Member Functions

void put (const std::string &key, const std::string &value)
 
void clear ()
 
template<class T >
bool get (const std::string &key, T &resultValue) const
 
bool get (const std::string &key, bool &resultValue) const
 
std::vector< std::stringkeys () const
 
std::string toString () const
 

Private Attributes

std::map< std::string, std::string_paramSet
 

Detailed Description

Simple class to set and retrieve key/value pairs.

This class is somewhat database-specific in its handling of true/false values.

Author
Kurt Biery
Version
Revision
1.5.26.1
Date
2019/09/27 00:07:03

Definition at line 21 of file SimpleParameterSet.h.

Member Function Documentation

void dbutils::SimpleParameterSet::clear ( )
inline

Definition at line 34 of file SimpleParameterSet.h.

References _paramSet.

35  {
36  _paramSet.clear();
37  }
std::map< std::string, std::string > _paramSet
template<class T >
bool dbutils::SimpleParameterSet::get ( const std::string key,
T resultValue 
) const
inline

Definition at line 44 of file SimpleParameterSet.h.

References _paramSet, and T.

Referenced by dbutils::daqconfig::NamedConfigUtils::copyGlobalConfig(), dbutils::daqconfig::NamedConfigUtils::copySubsystemConfig(), and dbutils::daqconfig::ConfigDataTree::saveValues().

45  {
46  std::map<std::string, std::string>::const_iterator iter =
47  _paramSet.find(key);
48  if (iter == _paramSet.end()) {return false;}
49 
50  try {
51  resultValue = boost::lexical_cast<T>(iter->second);
52  return true;
53  }
54  catch (...) {
55  // fall through to "false" (failing) return value below
56  }
57  return false;
58  }
std::map< std::string, std::string > _paramSet
double T
Definition: Xdiff_gwt.C:5
bool dbutils::SimpleParameterSet::get ( const std::string key,
bool &  resultValue 
) const
inline

Definition at line 60 of file SimpleParameterSet.h.

References _paramSet, keys(), string, and toString().

61  {
62  std::map<std::string, std::string>::const_iterator iter =
63  _paramSet.find(key);
64  if (iter == _paramSet.end()) {return false;}
65 
66  if (iter->second == "t" || iter->second == "1") {
67  resultValue = true;
68  }
69  else {
70  resultValue = false;
71  }
72  return true;
73  }
std::map< std::string, std::string > _paramSet
std::vector< std::string > dbutils::SimpleParameterSet::keys ( ) const

Definition at line 5 of file SimpleParameterSet.cpp.

References _paramSet.

Referenced by get(), and dbutils::daqconfig::ConfigDataTree::saveValues().

6 {
7  std::vector<std::string> resultList;
8  std::map<std::string, std::string>::const_iterator iter;
9  std::map<std::string, std::string>::const_iterator iterEnd = _paramSet.end();
10  for (iter = _paramSet.begin(); iter != iterEnd; ++iter) {
11  resultList.push_back(iter->first);
12  }
13  return resultList;
14 }
std::map< std::string, std::string > _paramSet
void dbutils::SimpleParameterSet::put ( const std::string key,
const std::string value 
)
inline
std::string dbutils::SimpleParameterSet::toString ( ) const

Definition at line 16 of file SimpleParameterSet.cpp.

References _paramSet, fillBadChanDBTables::result, and string.

Referenced by get(), and dbutils::daqconfig::ConfigDataTree::saveValues().

17 {
19  std::map<std::string, std::string>::const_iterator iter;
20  std::map<std::string, std::string>::const_iterator iterEnd = _paramSet.end();
21  bool first = true;
22  for (iter = _paramSet.begin(); iter != iterEnd; ++iter) {
23  if (first) {first = false;}
24  else {result.append(";");}
25  result.append(iter->first);
26  result.append("=");
27  result.append(iter->second);
28  }
29  return result;
30 }
std::map< std::string, std::string > _paramSet
enum BeamMode string

Member Data Documentation

std::map<std::string, std::string> dbutils::SimpleParameterSet::_paramSet
private

Definition at line 81 of file SimpleParameterSet.h.

Referenced by clear(), get(), keys(), put(), and toString().


The documentation for this class was generated from the following files: