[Avida-SVN] r1205 - in development: . source/main
avidaedward at myxo.css.msu.edu
avidaedward at myxo.css.msu.edu
Sat Jan 27 22:10:46 PST 2007
Author: avidaedward
Date: 2007-01-28 01:10:46 -0500 (Sun, 28 Jan 2007)
New Revision: 1205
Modified:
development/
development/source/main/cAvidaConfig.cc
development/source/main/cAvidaConfig.h
Log:
r1246 at clearly: kaben | 2007-01-21 22:51:37 -0500
Added "cAvidaConfig::LoadWithArgs(cStringList &args)" to configure and run Avida inside a test.
Property changes on: development
___________________________________________________________________
Name: svk:merge
- 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/development:1222
+ 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/development:1246
Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc 2007-01-28 06:10:38 UTC (rev 1204)
+++ development/source/main/cAvidaConfig.cc 2007-01-28 06:10:46 UTC (rev 1205)
@@ -308,7 +308,7 @@
}
}
-cAvidaConfig* cAvidaConfig::LoadWithCmdLineArgs(int argc, char * argv[])
+cAvidaConfig* cAvidaConfig::LoadWithArgs(cStringList &argv)
{
cString config_filename = "avida.cfg";
bool crash_if_not_found = false;
@@ -317,8 +317,11 @@
int arg_num = 1; // Argument number being looked at.
// Load all of the args into string objects for ease of access.
+ int argc = argv.GetSize();
cString* args = new cString[argc];
- for (int i = 0; i < argc; i++) args[i] = argv[i];
+ for (int i = 0; i < argc; i++) {
+ args[i] = argv.Pop();
+ }
// -config option
if (argc > 1 && (args[1] == "-c" || args[1] == "-config")) {
@@ -431,8 +434,8 @@
cerr << "Error: -c[onfig] option must be listed first." << endl;
exit(0);
} else {
- cerr << "Error: Unknown Option '" << argv[arg_num] << "'" << endl
- << "Type: \"" << argv[0] << " -h\" for a full option list." << endl;
+ cerr << "Error: Unknown Option '" << args[arg_num] << "'" << endl
+ << "Type: \"" << args[0] << " -h\" for a full option list." << endl;
exit(0);
}
@@ -460,6 +463,14 @@
return cfg;
}
+cAvidaConfig* cAvidaConfig::LoadWithCmdLineArgs(int argc, char * argv[])
+{
+ cStringList sl;
+ for(int i=0; i<argc; i++){
+ sl.PushRear(argv[i]);
+ }
+ return LoadWithArgs(sl);
+}
bool cAvidaConfig::Get(const cString& entry, cString& ret) const
{
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2007-01-28 06:10:38 UTC (rev 1204)
+++ development/source/main/cAvidaConfig.h 2007-01-28 06:10:46 UTC (rev 1205)
@@ -20,6 +20,7 @@
#include <iostream>
#include "cString.h"
+#include "cStringList.h"
#include "cStringUtil.h"
#include "tList.h"
@@ -163,6 +164,7 @@
cAvidaConfig() { group_list.Transfer(global_group_list); }
~cAvidaConfig() { ; }
+ static cAvidaConfig* LoadWithArgs(cStringList &args);
static cAvidaConfig* LoadWithCmdLineArgs(int argc, char* argv[]);
#ifdef OVERRIDE_CONFIG
More information about the Avida-cvs
mailing list