From f63c2c091b35e92f066cdace4d7d49cfdd5e1fe1 Mon Sep 17 00:00:00 2001
From: michel <michel@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Sat, 5 Apr 2008 10:52:58 +0000
Subject: [PATCH] v4 preprocessor: added provision for local options; used by
 dynare_sensitivity.m

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1784 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 ComputingTasks.cc    |  4 ++--
 Statement.cc         | 23 +++++++++++++++++++++++
 include/Statement.hh |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index e92d5a28..ddd70718 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -256,8 +256,8 @@ DynareSensitivityStatement::DynareSensitivityStatement(const OptionsList &option
 void
 DynareSensitivityStatement::writeOutput(ostream &output, const string &basename) const
 {
-  options_list.writeOutput(output);
-  output << "dynare_sensitivity;" << endl;
+  options_list.writeOutput(output,"options_gsa");
+  output << "dynare_sensitivity(options_gsa);" << endl;
 }
 
 RplotStatement::RplotStatement(const TmpSymbolTable &tmp_symbol_table_arg,
diff --git a/Statement.cc b/Statement.cc
index 735f21c3..2297e614 100644
--- a/Statement.cc
+++ b/Statement.cc
@@ -73,6 +73,29 @@ OptionsList::writeOutput(ostream &output) const
     it->second->writeOutput("options_."+it->first,output);
 }
 
+void
+OptionsList::writeOutput(ostream &output, const string &option_group) const
+{
+  output << option_group << " = struct();" << endl;
+
+  for(num_options_type::const_iterator it = num_options.begin();
+      it != num_options.end(); it++)
+    output << option_group << "." << it->first << " = " << it->second << ";" << endl;
+
+  for(paired_num_options_type::const_iterator it = paired_num_options.begin();
+      it != paired_num_options.end(); it++)
+    output << option_group << "." << it->first << " = [" << it->second.first << "; "
+           << it->second.second << "];" << endl;
+
+  for(string_options_type::const_iterator it = string_options.begin();
+      it != string_options.end(); it++)
+    output << option_group << "." << it->first << " = '" << it->second << "';" << endl;
+
+  for(string_list_options_type::const_iterator it = string_list_options.begin();
+      it != string_list_options.end(); it++)
+    it->second->writeOutput(option_group+"."+it->first,output);
+}
+
 void
 OptionsList::clear()
 {
diff --git a/include/Statement.hh b/include/Statement.hh
index 4379066d..a05733c7 100644
--- a/include/Statement.hh
+++ b/include/Statement.hh
@@ -78,6 +78,7 @@ public:
   string_options_type string_options;
   string_list_options_type string_list_options;
   void writeOutput(ostream &output) const;
+  void writeOutput(ostream &output, const string &option_group) const;
   void clear();
 };
 
-- 
GitLab