Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
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
Franck Dary
macaon
Commits
12d4cff9
Commit
12d4cff9
authored
5 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Made debug printing for Config easier to read
parent
a74b1252
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/include/util.hpp
+2
-0
2 additions, 0 deletions
common/include/util.hpp
common/src/util.cpp
+28
-0
28 additions, 0 deletions
common/src/util.cpp
reading_machine/src/Config.cpp
+3
-2
3 additions, 2 deletions
reading_machine/src/Config.cpp
with
33 additions
and
2 deletions
common/include/util.hpp
+
2
−
0
View file @
12d4cff9
...
...
@@ -41,6 +41,8 @@ utf8string splitAsUtf8(std::string_view s);
std
::
string
int2HumanStr
(
int
number
);
std
::
string
shrink
(
const
std
::
string
&
s
,
int
printedSize
);
int
printedLength
(
std
::
string_view
s
);
bool
isSeparator
(
utf8char
c
);
...
...
This diff is collapsed.
Click to expand it.
common/src/util.cpp
+
28
−
0
View file @
12d4cff9
...
...
@@ -75,6 +75,34 @@ util::utf8string util::splitAsUtf8(std::string_view s)
return
result
;
}
std
::
string
util
::
shrink
(
const
std
::
string
&
s
,
int
printedSize
)
{
static
const
std
::
string
filler
=
".."
;
if
(
printedLength
(
s
)
<=
printedSize
)
return
s
;
auto
splited
=
splitAsUtf8
(
s
);
std
::
string
result
;
std
::
string
begin
,
end
;
int
nbLoop
=
0
;
while
(
printedLength
(
begin
)
+
printedLength
(
end
)
+
2
<=
printedSize
)
{
result
=
begin
+
filler
+
end
;
if
(
nbLoop
%
2
)
end
=
fmt
::
format
(
"{}{}"
,
splited
[
splited
.
size
()
-
1
-
(
nbLoop
/
2
)],
end
);
else
begin
=
fmt
::
format
(
"{}{}"
,
begin
,
splited
[
nbLoop
/
2
]);
++
nbLoop
;
}
return
result
;
}
void
util
::
warning
(
std
::
string_view
message
,
const
std
::
experimental
::
source_location
&
location
)
{
fmt
::
print
(
stderr
,
"WARNING ({}) : {}
\n
"
,
location
,
message
);
...
...
This diff is collapsed.
Click to expand it.
reading_machine/src/Config.cpp
+
3
−
2
View file @
12d4cff9
...
...
@@ -80,6 +80,7 @@ void Config::printForDebug(FILE * dest) const
{
static
constexpr
int
windowSize
=
5
;
static
constexpr
int
lettersWindowSize
=
40
;
static
constexpr
int
maxWordLength
=
7
;
int
firstLineToPrint
=
wordIndex
;
int
lastLineToPrint
=
wordIndex
;
...
...
@@ -102,7 +103,7 @@ void Config::printForDebug(FILE * dest) const
toPrint
.
emplace_back
();
toPrint
.
back
().
emplace_back
(
line
==
(
int
)
wordIndex
?
"=>"
:
""
);
for
(
unsigned
int
i
=
0
;
i
<
getNbColumns
();
i
++
)
toPrint
.
back
().
emplace_back
(
getLastNotEmptyConst
(
i
,
line
));
toPrint
.
back
().
emplace_back
(
util
::
shrink
(
getLastNotEmptyConst
(
i
,
line
)
,
maxWordLength
)
);
}
std
::
vector
<
std
::
size_t
>
colLength
(
toPrint
[
0
].
size
(),
0
);
...
...
@@ -146,7 +147,7 @@ void Config::printForDebug(FILE * dest) const
if
(
line
==
1
)
fmt
::
print
(
dest
,
"{}
\n
"
,
longLine
);
for
(
unsigned
int
col
=
0
;
col
<
toPrint
[
line
].
size
()
-
1
;
col
++
)
fmt
::
print
(
dest
,
"{}{:>{}}{}"
,
toPrint
[
line
][
col
],
""
,
colLength
[
col
]
-
util
::
printedLength
(
toPrint
[
line
][
col
]),
col
==
toPrint
[
line
].
size
()
-
2
?
"
\n
"
:
"
\t
"
);
fmt
::
print
(
dest
,
"{}{:>{}}{}"
,
toPrint
[
line
][
col
],
""
,
colLength
[
col
]
-
util
::
printedLength
(
toPrint
[
line
][
col
]),
col
==
toPrint
[
line
].
size
()
-
2
?
"
\n
"
:
"
"
);
if
(
toPrint
[
line
].
back
()
==
EOSSymbol1
)
fmt
::
print
(
dest
,
"
\n
"
);
}
...
...
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