Permalink
Browse files

* Cleaned up getEnv and getCmdline methods.

* Finished generalized accessor functions.
* This should be the last update for a few weeks - mid-terms and finals
  nipping at my ass.  If any severe bugs crop up, let me know.
  • Loading branch information...
1 parent 30dcab0 commit 8d5245e922b2b66c9a73d02ca2b33772e27659fb jaz147 committed Nov 2, 2000
Showing with 36 additions and 24 deletions.
  1. +6 −0 ChangeLog
  2. +0 −5 TODO
  3. +7 −12 varconf/Config.cc
  4. +23 −7 varconf/Config.h
View
@@ -1,5 +1,11 @@
ChangeLog for varconf
+Thu Nov 02 18:00:00 EST 2000 -- jaz <jaz147@psu.edu>
+ * Config.h: Added generalized accessor methods
+ * Config.cc: Implemented generalized accessor methods
+ * Config.cc: Finished getEnv clean-up.
+ * Config.cc: Finished getCmdline clean-up.
+
Mon Oct 23 16:10:38 EST 2000 -- jaz <jaz147@psu.edu>
* Config.cc: Removed Observer code.
* Config.cc: Converted callbacks to libsigc++.
View
5 TODO
@@ -1,18 +1,13 @@
TODO for varconf
Major Tasks:
- * Redo Config::getCmdline() and Config::getEnv() codex.
- * Handle '--' arguments better
- * Check validity of '-' arguments
* Unify configuration methods (ie: add section support to Config::getEnv())
- + Add delItem() and delSection() methods
* Unify error handling methods
* Convert file parser to lex/yacc
* Design and implement new Observer class
* Add overloaded operators for major functions
* Finish changing functions to general form (getItem to get, etc.)
* Document and arrange the source better.
- * Submit the new interface to the mailing lists to recommend adoption.
* Write a proper testing program to verify functionality of features.
Minor Tasks:
View
@@ -92,34 +92,29 @@ bool Config::erase( const string& section, const string& key = "")
return false;
}
-Variable Config::getItem( const string& section, const string& key)
+Variable Config::get( const string& section, const string& key)
{
return ( m_conf[section])[key];
}
-void Config::setItem( const string& section, const string& name,
- const Variable item)
+void Config::set( const string& section, const string& key,
+ const Variable item)
{
- if ( name.empty()) {
+ if ( key.empty()) {
throw "Invalid configuration item!";
}
else {
- string sec = section, nam = name;
+ string sec = section, nam = key;
clean( sec);
clean( nam);
( m_conf[sec])[nam] = item;
sig.emit();
- sigv.emit( section, name);
+ sigv.emit( sec, nam);
}
-} // Config::setItem()
-
-bool Config::findItem( const string& section, const string& name)
-{
- return find( section, name);
-}
+} // Config::set()
bool Config::find( const string& section, const string& key = "")
{
View
@@ -26,16 +26,32 @@ class Config {
static Config* inst();
// returns a pointer to the global configuration instance and
// initializes it if it does not already exist.
-
- Variable getItem( const std::string& section, const std::string& key);
+
+ Variable get( const std::string& section, const std::string& key);
+ void set( const std::string& section, const std::string& key,
+ const Variable item);
bool erase( const std::string& section, const std::string& key = "");
bool find( const std::string& section, const std::string& key = "");
- void clean( std::string& str);
- // turns 'str' into a section name or key name compatible string.
+ // Config data manipulators - get a config key, set a config key, delete
+ // a config key or config section and find a config key or config section.
- void setItem( const std::string& section, const std::string& name,
- const Variable item);
- bool findItem( const std::string& section, const std::string& name);
+ void clean( std::string& str);
+
+ Variable getItem( const std::string& section, const std::string& key)
+ {
+ return get( section, key);
+ }
+
+ void setItem( const std::string& section, const std::string& key,
+ const Variable item)
+ {
+ set( section, key, item);
+ }
+
+ bool findItem( const std::string& section, const std::string& key)
+ {
+ return find( section, key);
+ }
bool readFromFile( const std::string& filename);
// attempts to read a configuration file 'filename' and parse it. Returns

0 comments on commit 8d5245e

Please sign in to comment.