Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
0ca645c6
Unverified
Commit
0ca645c6
authored
Jun 20, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
right align number, if there was a dictionary loaded containing the required information
parent
676c0c8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
11 deletions
+63
-11
src/category.cpp
+63
-11
No files found.
src/category.cpp
View file @
0ca645c6
...
...
@@ -1708,8 +1708,7 @@ void category::reorder_by_index()
namespace
detail
{
size_t
write_value
(
std
::
ostream
&
os
,
std
::
string_view
value
,
size_t
offset
,
size_t
width
)
size_t
write_value
(
std
::
ostream
&
os
,
std
::
string_view
value
,
size_t
offset
,
size_t
width
,
bool
right_aligned
)
{
if
(
value
.
find
(
'\n'
)
!=
std
::
string
::
npos
or
width
==
0
or
value
.
length
()
>
132
)
// write as text field
{
...
...
@@ -1733,17 +1732,33 @@ namespace detail
}
else
if
(
sac_parser
::
is_unquoted_string
(
value
))
{
os
<<
value
;
if
(
value
.
length
()
<
width
)
if
(
right_aligned
)
{
os
<<
std
::
string
(
width
-
value
.
length
(),
' '
);
offset
+=
width
;
if
(
value
.
length
()
<
width
)
{
os
<<
std
::
string
(
width
-
value
.
length
()
-
1
,
' '
);
offset
+=
width
;
}
else
offset
+=
value
.
length
()
+
1
;
}
os
<<
value
;
if
(
right_aligned
)
os
<<
' '
;
else
{
os
<<
' '
;
offset
+=
value
.
length
()
+
1
;
if
(
value
.
length
()
<
width
)
{
os
<<
std
::
string
(
width
-
value
.
length
(),
' '
);
offset
+=
width
;
}
else
{
os
<<
' '
;
offset
+=
value
.
length
()
+
1
;
}
}
}
else
...
...
@@ -1837,6 +1852,19 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
// If the first Row has a next, we need a loop_
bool
needLoop
=
(
m_head
->
m_next
!=
nullptr
);
std
::
vector
<
bool
>
right_aligned
(
m_columns
.
size
(),
false
);
if
(
m_cat_validator
!=
nullptr
)
{
for
(
auto
cix
:
order
)
{
auto
&
col
=
m_columns
[
cix
];
right_aligned
[
cix
]
=
col
.
m_validator
!=
nullptr
and
col
.
m_validator
->
m_type
!=
nullptr
and
col
.
m_validator
->
m_type
->
m_primitive_type
==
cif
::
DDL_PrimitiveType
::
Numb
;
}
}
if
(
needLoop
)
{
os
<<
"loop_"
<<
'\n'
;
...
...
@@ -1905,7 +1933,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
offset
=
0
;
}
offset
=
detail
::
write_value
(
os
,
s
,
offset
,
w
);
offset
=
detail
::
write_value
(
os
,
s
,
offset
,
w
,
right_aligned
[
cix
]
);
if
(
offset
>
132
)
{
...
...
@@ -1933,6 +1961,30 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
l
+=
3
;
size_t
width
=
1
;
for
(
auto
cix
:
order
)
{
if
(
not
right_aligned
[
cix
])
continue
;
std
::
string_view
s
;
auto
iv
=
m_head
->
get
(
cix
);
if
(
iv
!=
nullptr
)
s
=
iv
->
text
();
if
(
s
.
empty
())
s
=
"?"
;
size_t
l
=
s
.
length
();
if
(
not
sac_parser
::
is_unquoted_string
(
s
))
l
+=
2
;
if
(
width
<
l
)
width
=
l
;
}
for
(
uint16_t
cix
:
order
)
{
auto
&
col
=
m_columns
[
cix
];
...
...
@@ -1957,7 +2009,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
offset
=
0
;
}
if
(
detail
::
write_value
(
os
,
s
,
offset
,
1
)
!=
0
)
if
(
detail
::
write_value
(
os
,
s
,
offset
,
width
,
s
.
empty
()
or
right_aligned
[
cix
]
)
!=
0
)
os
<<
'\n'
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment