Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utils
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
utils
Commits
efafd301
Commit
efafd301
authored
7 years ago
by
Jesper Andersson
Browse files
Options
Downloads
Patches
Plain Diff
Changed << to check for user defined flag on stream and adapt its behaviour accordingly
parent
35143a9d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
functions.cc
+22
-2
22 additions, 2 deletions
functions.cc
options.h
+22
-0
22 additions, 0 deletions
options.h
with
44 additions
and
2 deletions
functions.cc
+
22
−
2
View file @
efafd301
...
...
@@ -4,6 +4,21 @@
#include
"options.h"
// Below I declare variables and a function
// needed for changing the behaviour of << so that the
// user can chose between old style and more detailed
// output.
// Jesper Andersson
namespace
Utilities
{
std
::
map
<
string
,
long
>
UserStreamFlag
;
std
::
ostream
&
detailed_output
(
std
::
ostream
&
os
)
{
if
(
UserStreamFlag
.
find
(
"OutputType"
)
==
UserStreamFlag
.
end
())
UserStreamFlag
[
"OutputType"
]
=
os
.
xalloc
();
os
.
iword
(
UserStreamFlag
[
"OutputType"
])
=
DetailedOutput
;
return
(
os
);
}
}
namespace
Utilities
{
using
namespace
std
;
...
...
@@ -45,8 +60,13 @@ namespace Utilities {
template
<
>
ostream
&
Option
<
bool
>::
print
(
ostream
&
os
)
const
{
os
<<
"# "
<<
help_text
()
<<
endl
;
if
(
set
())
os
<<
config_key
().
substr
(
0
,
config_key
().
find
(
"="
));
if
(
Utilities
::
UserStreamFlag
.
find
(
"OutputType"
)
!=
Utilities
::
UserStreamFlag
.
end
()
&&
os
.
iword
(
Utilities
::
UserStreamFlag
[
"OutputType"
])
==
Utilities
::
DetailedOutput
)
{
os
<<
key
()
<<
"="
<<
(
set
()
?
"True"
:
"False"
);
}
else
{
if
(
set
())
os
<<
config_key
().
substr
(
0
,
config_key
().
find
(
"="
));
}
return
os
;
}
...
...
This diff is collapsed.
Click to expand it.
options.h
+
22
−
0
View file @
efafd301
...
...
@@ -8,6 +8,7 @@
#include
<stdexcept>
#include
<string>
#include
<vector>
#include
<map>
#include
<iostream>
#include
<sstream>
#include
<iterator>
...
...
@@ -17,6 +18,27 @@
using
namespace
std
;
// Below I define constants and a function
// needed for changing the behaviour of << so that the
// user can chose between old style and more detailed
// output. If one wants for example a log-file with
// details of all parameters one would do something like
//
// Utilities::OptionParser options(...)
// ...
// ofstream dpf; // Detailed Parameter File
// Utilities::detailed_output(dpf);
// dpf.open("my_file.txt"));
// dpf << options << endl;
// dpf.close();
//
// Jesper Andersson
namespace
Utilities
{
const
long
RegularOutput
=
4
;
const
long
DetailedOutput
=
5
;
std
::
ostream
&
detailed_output
(
std
::
ostream
&
os
);
}
namespace
Utilities
{
bool
string_to_T
(
bool
&
b
,
const
std
::
string
&
s
);
...
...
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