Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dynare
preprocessor
Commits
ae97c4eb
Verified
Commit
ae97c4eb
authored
May 17, 2022
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Factorization in OptionsList class
parent
3e942505
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Statement.cc
+14
-58
14 additions, 58 deletions
src/Statement.cc
src/Statement.hh
+2
-0
2 additions, 0 deletions
src/Statement.hh
with
16 additions
and
58 deletions
src/Statement.cc
+
14
−
58
View file @
ae97c4eb
/*
/*
* Copyright © 2006-202
1
Dynare Team
* Copyright © 2006-202
2
Dynare Team
*
*
* This file is part of Dynare.
* This file is part of Dynare.
*
*
...
@@ -158,63 +158,7 @@ VerbatimStatement::writeJsonOutput(ostream &output) const
...
@@ -158,63 +158,7 @@ VerbatimStatement::writeJsonOutput(ostream &output) const
void
void
OptionsList
::
writeOutput
(
ostream
&
output
)
const
OptionsList
::
writeOutput
(
ostream
&
output
)
const
{
{
for
(
const
auto
&
[
name
,
val
]
:
num_options
)
writeOutputCommon
(
output
,
"options_"
);
output
<<
"options_."
<<
name
<<
" = "
<<
val
<<
";"
<<
endl
;
for
(
const
auto
&
[
name
,
vals
]
:
paired_num_options
)
output
<<
"options_."
<<
name
<<
" = ["
<<
vals
.
first
<<
"; "
<<
vals
.
second
<<
"];"
<<
endl
;
for
(
const
auto
&
[
name
,
val
]
:
string_options
)
output
<<
"options_."
<<
name
<<
" = '"
<<
val
<<
"';"
<<
endl
;
for
(
const
auto
&
[
name
,
val
]
:
date_options
)
output
<<
"options_."
<<
name
<<
" = "
<<
val
<<
";"
<<
endl
;
for
(
const
auto
&
[
name
,
list
]
:
symbol_list_options
)
list
.
writeOutput
(
"options_."
+
name
,
output
);
for
(
const
auto
&
[
name
,
vals
]
:
vector_int_options
)
{
output
<<
"options_."
<<
name
<<
" = "
;
if
(
vals
.
size
()
>
1
)
{
output
<<
"["
;
for
(
int
viit
:
vals
)
output
<<
viit
<<
";"
;
output
<<
"];"
<<
endl
;
}
else
output
<<
vals
.
front
()
<<
";"
<<
endl
;
}
for
(
const
auto
&
[
name
,
vals
]
:
vector_str_options
)
{
output
<<
"options_."
<<
name
<<
" = "
;
if
(
vals
.
size
()
>
1
)
{
output
<<
"{"
;
for
(
const
auto
&
viit
:
vals
)
output
<<
"'"
<<
viit
<<
"';"
;
output
<<
"};"
<<
endl
;
}
else
output
<<
vals
.
front
()
<<
";"
<<
endl
;
}
/* vector_cellstr_options should ideally be merged into vector_str_options
only difference is treatment of vals.size==1, where vector_str_options
does not add quotes and curly brackets, i.e. allows for type conversion of
'2' into the number 2
*/
for
(
const
auto
&
[
name
,
vals
]
:
vector_cellstr_options
)
{
output
<<
"options_."
<<
name
<<
" = {"
;
for
(
const
auto
&
viit
:
vals
)
output
<<
"'"
<<
viit
<<
"';"
;
output
<<
"};"
<<
endl
;
}
}
}
void
void
...
@@ -231,6 +175,12 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
...
@@ -231,6 +175,12 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
else
else
output
<<
option_group
<<
" = struct();"
<<
endl
;
output
<<
option_group
<<
" = struct();"
<<
endl
;
writeOutputCommon
(
output
,
option_group
);
}
void
OptionsList
::
writeOutputCommon
(
ostream
&
output
,
const
string
&
option_group
)
const
{
for
(
const
auto
&
[
name
,
val
]
:
num_options
)
for
(
const
auto
&
[
name
,
val
]
:
num_options
)
output
<<
option_group
<<
"."
<<
name
<<
" = "
<<
val
<<
";"
<<
endl
;
output
<<
option_group
<<
"."
<<
name
<<
" = "
<<
val
<<
";"
<<
endl
;
...
@@ -275,6 +225,12 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
...
@@ -275,6 +225,12 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const
output
<<
vals
.
front
()
<<
";"
<<
endl
;
output
<<
vals
.
front
()
<<
";"
<<
endl
;
}
}
/* vector_cellstr_options should ideally be merged into vector_str_options
only difference is treatment of vals.size==1, where vector_str_options
does not add quotes and curly brackets, i.e. allows for type conversion of
'2' into the number 2
*/
for
(
const
auto
&
[
name
,
vals
]
:
vector_cellstr_options
)
for
(
const
auto
&
[
name
,
vals
]
:
vector_cellstr_options
)
{
{
output
<<
option_group
<<
"."
<<
name
<<
" = {"
;
output
<<
option_group
<<
"."
<<
name
<<
" = {"
;
...
...
This diff is collapsed.
Click to expand it.
src/Statement.hh
+
2
−
0
View file @
ae97c4eb
...
@@ -230,6 +230,8 @@ public:
...
@@ -230,6 +230,8 @@ public:
void
writeOutput
(
ostream
&
output
,
const
string
&
option_group
)
const
;
void
writeOutput
(
ostream
&
output
,
const
string
&
option_group
)
const
;
void
writeJsonOutput
(
ostream
&
output
)
const
;
void
writeJsonOutput
(
ostream
&
output
)
const
;
void
clear
();
void
clear
();
private:
void
writeOutputCommon
(
ostream
&
output
,
const
string
&
option_group
)
const
;
};
};
#endif // ! _STATEMENT_HH
#endif // ! _STATEMENT_HH
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment