summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/prefs.cc
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2015-03-02 13:44:17 -0500
committerTom Rondeau <tom@trondeau.com>2015-04-02 15:38:57 -0700
commit7bdd6effd7b6b36ea8d86cb57329a20874fb3290 (patch)
treefc493ddf8e28e46f8209f219573e7175dd96cd5c /gnuradio-runtime/lib/prefs.cc
parentc67d0a417f43c644a0ccabe46b38a1e48c3bd15d (diff)
runtime: more generic version of prefs class.
Adds another constructor to open a particular file to configure specific preferences.
Diffstat (limited to 'gnuradio-runtime/lib/prefs.cc')
-rw-r--r--gnuradio-runtime/lib/prefs.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc
index b7fcaada9d..b303ffdaf9 100644
--- a/gnuradio-runtime/lib/prefs.cc
+++ b/gnuradio-runtime/lib/prefs.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2013 Free Software Foundation, Inc.
+ * Copyright 2006,2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -46,7 +46,10 @@ namespace gr {
prefs::prefs()
{
- _read_files();
+ std::string config = _read_files(_sys_prefs_filenames());
+
+ // Convert the string into a map
+ _convert_to_map(config);
}
prefs::~prefs()
@@ -83,13 +86,12 @@ namespace gr {
return fnames;
}
- void
- prefs::_read_files()
+ std::string
+ prefs::_read_files(const std::vector<std::string> &filenames)
{
std::string config;
- std::vector<std::string> filenames = _sys_prefs_filenames();
- std::vector<std::string>::iterator sitr;
+ std::vector<std::string>::const_iterator sitr;
char tmp[1024];
for(sitr = filenames.begin(); sitr != filenames.end(); sitr++) {
fs::ifstream fin(*sitr);
@@ -142,8 +144,7 @@ namespace gr {
fin.close();
}
- // Convert the string into a map
- _convert_to_map(config);
+ return config;
}
void
@@ -188,6 +189,17 @@ namespace gr {
}
}
+ void
+ prefs::add_config_file(const std::string &configfile)
+ {
+ std::vector<std::string> filenames;
+ filenames.push_back(configfile);
+
+ std::string config = _read_files(filenames);
+ _convert_to_map(config);
+ }
+
+
std::string
prefs::to_string()
{