Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
1a7d172d
Commit
1a7d172d
authored
Aug 25, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
which_value -> kind
parent
006c2546
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
24 deletions
+17
-24
include/fmt/compile.h
include/fmt/compile.h
+12
-19
test/compile-test.cc
test/compile-test.cc
+5
-5
No files found.
include/fmt/compile.h
View file @
1a7d172d
...
...
@@ -58,30 +58,23 @@ template <typename Char> struct format_part {
};
FMT_CONSTEXPR
format_part
()
:
which
(
which_value
::
argument_id
),
end_of_argument_id
(
0u
),
val
(
0u
)
{}
:
which
(
kind
::
argument_id
),
end_of_argument_id
(
0u
),
val
(
0u
)
{}
FMT_CONSTEXPR
format_part
(
internal
::
string_view_metadata
text
)
:
which
(
which_value
::
text
),
end_of_argument_id
(
0u
),
val
(
text
)
{}
:
which
(
kind
::
text
),
end_of_argument_id
(
0u
),
val
(
text
)
{}
FMT_CONSTEXPR
format_part
(
unsigned
id
)
:
which
(
which_value
::
argument_id
),
end_of_argument_id
(
0u
),
val
(
id
)
{}
:
which
(
kind
::
argument_id
),
end_of_argument_id
(
0u
),
val
(
id
)
{}
FMT_CONSTEXPR
format_part
(
named_argument_id
arg_id
)
:
which
(
which_value
::
named_argument_id
),
end_of_argument_id
(
0u
),
val
(
arg_id
)
{}
:
which
(
kind
::
named_argument_id
),
end_of_argument_id
(
0u
),
val
(
arg_id
)
{}
FMT_CONSTEXPR
format_part
(
specification
spec
)
:
which
(
which_value
::
specification
),
end_of_argument_id
(
0u
),
val
(
spec
)
{}
:
which
(
kind
::
specification
),
end_of_argument_id
(
0u
),
val
(
spec
)
{}
enum
class
which_value
{
argument_id
,
named_argument_id
,
text
,
specification
};
enum
class
kind
{
argument_id
,
named_argument_id
,
text
,
specification
};
which_value
which
;
kind
which
;
std
::
size_t
end_of_argument_id
;
union
value
{
FMT_CONSTEXPR
value
()
:
arg_id
(
0u
)
{}
...
...
@@ -147,7 +140,7 @@ class format_preparation_handler : public internal::error_handler {
if
(
*
begin
!=
'}'
)
on_error
(
"missing '}' in format string"
);
auto
&
last_part
=
parts_
.
back
();
auto
specs
=
last_part
.
which
==
part
::
which_value
::
argument_id
auto
specs
=
last_part
.
which
==
part
::
kind
::
argument_id
?
typename
part
::
specification
(
last_part
.
val
.
arg_id
)
:
typename
part
::
specification
(
last_part
.
val
.
named_arg_id
);
specs
.
parsed_specs
=
parsed_specs
;
...
...
@@ -188,7 +181,7 @@ class prepared_format {
const
auto
&
value
=
part
.
val
;
switch
(
part
.
which
)
{
case
format_part_t
:
:
which_value
::
text
:
{
case
format_part_t
:
:
kind
::
text
:
{
const
auto
text
=
value
.
text
.
to_view
(
format_view
.
data
());
auto
output
=
ctx
.
out
();
auto
&&
it
=
internal
::
reserve
(
output
,
text
.
size
());
...
...
@@ -196,18 +189,18 @@ class prepared_format {
ctx
.
advance_to
(
output
);
}
break
;
case
format_part_t
:
:
which_value
::
argument_id
:
{
case
format_part_t
:
:
kind
::
argument_id
:
{
advance_parse_context_to_specification
(
parse_ctx
,
part
);
format_arg
<
Range
>
(
parse_ctx
,
ctx
,
value
.
arg_id
);
}
break
;
case
format_part_t
:
:
which_value
::
named_argument_id
:
{
case
format_part_t
:
:
kind
::
named_argument_id
:
{
advance_parse_context_to_specification
(
parse_ctx
,
part
);
const
auto
named_arg_id
=
value
.
named_arg_id
.
to_view
(
format_view
.
data
());
format_arg
<
Range
>
(
parse_ctx
,
ctx
,
named_arg_id
);
}
break
;
case
format_part_t
:
:
which_value
::
specification
:
{
case
format_part_t
:
:
kind
::
specification
:
{
const
auto
&
arg_id_value
=
value
.
spec
.
arg_id
.
val
;
const
auto
arg
=
value
.
spec
.
arg_id
.
which
==
format_part_t
::
argument_id
::
which_arg_id
::
index
...
...
test/compile-test.cc
View file @
1a7d172d
...
...
@@ -80,7 +80,7 @@ bool operator!=(const format_part<char>::specification& lhs,
bool
operator
==
(
const
format_part
<
char
>&
lhs
,
const
fmt
::
internal
::
format_part
<
char
>&
rhs
)
{
typedef
format_part
<
char
>::
which_value
which_value
;
typedef
format_part
<
char
>::
kind
kind
;
if
(
lhs
.
which
!=
rhs
.
which
||
lhs
.
end_of_argument_id
!=
rhs
.
end_of_argument_id
)
{
...
...
@@ -88,19 +88,19 @@ bool operator==(const format_part<char>& lhs,
}
switch
(
lhs
.
which
)
{
case
which_value
:
:
argument_id
:
{
case
kind
:
:
argument_id
:
{
return
lhs
.
val
.
arg_id
==
rhs
.
val
.
arg_id
;
}
case
which_value
:
:
named_argument_id
:
{
case
kind
:
:
named_argument_id
:
{
return
lhs
.
val
.
named_arg_id
==
rhs
.
val
.
named_arg_id
;
}
case
which_value
:
:
text
:
{
case
kind
:
:
text
:
{
return
lhs
.
val
.
text
==
rhs
.
val
.
text
;
}
case
which_value
:
:
specification
:
{
case
kind
:
:
specification
:
{
return
lhs
.
val
.
spec
==
rhs
.
val
.
spec
;
}
}
...
...
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