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
e0243000
Commit
e0243000
authored
Nov 26, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arg_index -> arg_id
parent
ac5f9520
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
34 deletions
+29
-34
include/fmt/format.h
include/fmt/format.h
+27
-32
include/fmt/printf.h
include/fmt/printf.h
+1
-1
test/format-test.cc
test/format-test.cc
+1
-1
No files found.
include/fmt/format.h
View file @
e0243000
...
@@ -1710,15 +1710,15 @@ template <typename Char, typename ErrorHandler = internal::error_handler>
...
@@ -1710,15 +1710,15 @@ template <typename Char, typename ErrorHandler = internal::error_handler>
class
basic_parse_context
:
private
ErrorHandler
{
class
basic_parse_context
:
private
ErrorHandler
{
private:
private:
basic_string_view
<
Char
>
format_str_
;
basic_string_view
<
Char
>
format_str_
;
int
next_arg_i
ndex
_
;
int
next_arg_i
d
_
;
protected:
protected:
constexpr
bool
check_no_auto_index
()
{
constexpr
bool
check_no_auto_index
()
{
if
(
next_arg_i
ndex
_
>
0
)
{
if
(
next_arg_i
d
_
>
0
)
{
on_error
(
"cannot switch from automatic to manual argument indexing"
);
on_error
(
"cannot switch from automatic to manual argument indexing"
);
return
false
;
return
false
;
}
}
next_arg_i
ndex
_
=
-
1
;
next_arg_i
d
_
=
-
1
;
return
true
;
return
true
;
}
}
...
@@ -1728,14 +1728,14 @@ class basic_parse_context : private ErrorHandler {
...
@@ -1728,14 +1728,14 @@ class basic_parse_context : private ErrorHandler {
explicit
constexpr
basic_parse_context
(
explicit
constexpr
basic_parse_context
(
basic_string_view
<
Char
>
format_str
,
ErrorHandler
eh
=
ErrorHandler
())
basic_string_view
<
Char
>
format_str
,
ErrorHandler
eh
=
ErrorHandler
())
:
ErrorHandler
(
eh
),
format_str_
(
format_str
),
next_arg_i
ndex
_
(
0
)
{}
:
ErrorHandler
(
eh
),
format_str_
(
format_str
),
next_arg_i
d
_
(
0
)
{}
// Returns an iterator to the beginning of the format string range being
// Returns an iterator to the beginning of the format string range being
// parsed.
// parsed.
constexpr
iterator
begin
()
const
{
return
format_str_
.
begin
();
}
constexpr
iterator
begin
()
const
FMT_NOEXCEPT
{
return
format_str_
.
begin
();
}
// Returns an iterator past the end of the format string range being parsed.
// Returns an iterator past the end of the format string range being parsed.
constexpr
iterator
end
()
const
{
return
format_str_
.
end
();
}
constexpr
iterator
end
()
const
FMT_NOEXCEPT
{
return
format_str_
.
end
();
}
// Advances the begin iterator to ``it``.
// Advances the begin iterator to ``it``.
constexpr
void
advance_to
(
iterator
it
)
{
constexpr
void
advance_to
(
iterator
it
)
{
...
@@ -1743,9 +1743,9 @@ class basic_parse_context : private ErrorHandler {
...
@@ -1743,9 +1743,9 @@ class basic_parse_context : private ErrorHandler {
}
}
// Returns the next argument index.
// Returns the next argument index.
constexpr
unsigned
next_arg_i
ndex
()
{
constexpr
unsigned
next_arg_i
d
()
{
if
(
next_arg_i
ndex
_
>=
0
)
if
(
next_arg_i
d
_
>=
0
)
return
internal
::
to_unsigned
(
next_arg_i
ndex
_
++
);
return
internal
::
to_unsigned
(
next_arg_i
d
_
++
);
on_error
(
"cannot switch from manual to automatic argument indexing"
);
on_error
(
"cannot switch from manual to automatic argument indexing"
);
return
0
;
return
0
;
}
}
...
@@ -2099,8 +2099,8 @@ class context_base : public basic_parse_context<Char>{
...
@@ -2099,8 +2099,8 @@ class context_base : public basic_parse_context<Char>{
basic_args
<
Context
>
args
()
const
{
return
args_
;
}
basic_args
<
Context
>
args
()
const
{
return
args_
;
}
// Returns the argument with specified index.
// Returns the argument with specified index.
format_arg
do_get_arg
(
unsigned
arg_i
ndex
)
{
format_arg
do_get_arg
(
unsigned
arg_i
d
)
{
format_arg
arg
=
args_
[
arg_i
ndex
];
format_arg
arg
=
args_
[
arg_i
d
];
if
(
!
arg
)
if
(
!
arg
)
this
->
on_error
(
"argument index out of range"
);
this
->
on_error
(
"argument index out of range"
);
return
arg
;
return
arg
;
...
@@ -2108,9 +2108,9 @@ class context_base : public basic_parse_context<Char>{
...
@@ -2108,9 +2108,9 @@ class context_base : public basic_parse_context<Char>{
// Checks if manual indexing is used and returns the argument with
// Checks if manual indexing is used and returns the argument with
// specified index.
// specified index.
format_arg
get_arg
(
unsigned
arg_i
ndex
)
{
format_arg
get_arg
(
unsigned
arg_i
d
)
{
return
this
->
check_no_auto_index
()
?
return
this
->
check_no_auto_index
()
?
this
->
do_get_arg
(
arg_i
ndex
)
:
format_arg
();
this
->
do_get_arg
(
arg_i
d
)
:
format_arg
();
}
}
public:
public:
...
@@ -2445,7 +2445,7 @@ class dynamic_specs_handler :
...
@@ -2445,7 +2445,7 @@ class dynamic_specs_handler :
}
}
constexpr
arg_ref_type
make_arg_ref
(
auto_id
)
{
constexpr
arg_ref_type
make_arg_ref
(
auto_id
)
{
return
arg_ref_type
(
context_
.
next_arg_i
ndex
());
return
arg_ref_type
(
context_
.
next_arg_i
d
());
}
}
dynamic_format_specs
<
char_type
>
&
specs_
;
dynamic_format_specs
<
char_type
>
&
specs_
;
...
@@ -2692,13 +2692,13 @@ class format_string_checker {
...
@@ -2692,13 +2692,13 @@ class format_string_checker {
constexpr
void
on_text
(
const
Char
*
,
const
Char
*
)
{}
constexpr
void
on_text
(
const
Char
*
,
const
Char
*
)
{}
constexpr
void
on_arg_id
()
{
constexpr
void
on_arg_id
()
{
arg_i
ndex_
=
context_
.
next_arg_index
();
arg_i
d_
=
context_
.
next_arg_id
();
check_arg_i
ndex
();
check_arg_i
d
();
}
}
constexpr
void
on_arg_id
(
unsigned
i
ndex
)
{
constexpr
void
on_arg_id
(
unsigned
i
d
)
{
arg_i
ndex_
=
index
;
arg_i
d_
=
id
;
context_
.
check_arg_id
(
i
ndex
);
context_
.
check_arg_id
(
i
d
);
check_arg_i
ndex
();
check_arg_i
d
();
}
}
constexpr
void
on_arg_id
(
basic_string_view
<
Char
>
)
{}
constexpr
void
on_arg_id
(
basic_string_view
<
Char
>
)
{}
...
@@ -2706,8 +2706,8 @@ class format_string_checker {
...
@@ -2706,8 +2706,8 @@ class format_string_checker {
constexpr
const
Char
*
on_format_specs
(
const
Char
*
s
)
{
constexpr
const
Char
*
on_format_specs
(
const
Char
*
s
)
{
context_
.
advance_to
(
s
);
context_
.
advance_to
(
s
);
return
to_unsigned
(
arg_i
ndex
_
)
<
NUM_ARGS
?
return
to_unsigned
(
arg_i
d
_
)
<
NUM_ARGS
?
parse_funcs_
[
arg_i
ndex
_
](
context_
)
:
s
;
parse_funcs_
[
arg_i
d
_
](
context_
)
:
s
;
}
}
constexpr
void
on_error
(
const
char
*
message
)
{
constexpr
void
on_error
(
const
char
*
message
)
{
...
@@ -2718,15 +2718,15 @@ class format_string_checker {
...
@@ -2718,15 +2718,15 @@ class format_string_checker {
using
parse_context_type
=
basic_parse_context
<
Char
,
ErrorHandler
>
;
using
parse_context_type
=
basic_parse_context
<
Char
,
ErrorHandler
>
;
constexpr
static
size_t
NUM_ARGS
=
sizeof
...(
Args
);
constexpr
static
size_t
NUM_ARGS
=
sizeof
...(
Args
);
constexpr
void
check_arg_i
ndex
()
{
constexpr
void
check_arg_i
d
()
{
if
(
internal
::
to_unsigned
(
arg_i
ndex
_
)
>=
NUM_ARGS
)
if
(
internal
::
to_unsigned
(
arg_i
d
_
)
>=
NUM_ARGS
)
context_
.
on_error
(
"argument index out of range"
);
context_
.
on_error
(
"argument index out of range"
);
}
}
// Format specifier parsing function.
// Format specifier parsing function.
using
parse_func
=
const
Char
*
(
*
)(
parse_context_type
&
);
using
parse_func
=
const
Char
*
(
*
)(
parse_context_type
&
);
int
arg_i
ndex
_
=
-
1
;
int
arg_i
d
_
=
-
1
;
parse_context_type
context_
;
parse_context_type
context_
;
parse_func
parse_funcs_
[
NUM_ARGS
>
0
?
NUM_ARGS
:
1
]
=
{
parse_func
parse_funcs_
[
NUM_ARGS
>
0
?
NUM_ARGS
:
1
]
=
{
&
parse_format_specs
<
Args
,
parse_context_type
>
...
&
parse_format_specs
<
Args
,
parse_context_type
>
...
...
@@ -2831,13 +2831,8 @@ class basic_context :
...
@@ -2831,13 +2831,8 @@ class basic_context :
basic_string_view
<
Char
>
format_str
,
basic_args
<
basic_context
>
args
)
basic_string_view
<
Char
>
format_str
,
basic_args
<
basic_context
>
args
)
:
Base
(
format_str
,
args
)
{}
:
Base
(
format_str
,
args
)
{}
format_arg
next_arg
()
{
format_arg
next_arg
()
{
return
this
->
do_get_arg
(
this
->
next_arg_id
());
}
return
this
->
do_get_arg
(
this
->
next_arg_index
());
format_arg
get_arg
(
unsigned
arg_id
)
{
return
this
->
do_get_arg
(
arg_id
);
}
}
format_arg
get_arg
(
unsigned
arg_index
)
{
return
this
->
do_get_arg
(
arg_index
);
}
// Checks if manual indexing is used and returns the argument with
// Checks if manual indexing is used and returns the argument with
// specified name.
// specified name.
...
...
include/fmt/printf.h
View file @
e0243000
...
@@ -368,7 +368,7 @@ typename printf_context<Char, AF>::format_arg printf_context<Char, AF>::get_arg(
...
@@ -368,7 +368,7 @@ typename printf_context<Char, AF>::format_arg printf_context<Char, AF>::get_arg(
iterator
it
,
unsigned
arg_index
)
{
iterator
it
,
unsigned
arg_index
)
{
(
void
)
it
;
(
void
)
it
;
if
(
arg_index
==
std
::
numeric_limits
<
unsigned
>::
max
())
if
(
arg_index
==
std
::
numeric_limits
<
unsigned
>::
max
())
return
this
->
do_get_arg
(
this
->
next_arg_i
ndex
());
return
this
->
do_get_arg
(
this
->
next_arg_i
d
());
return
Base
::
get_arg
(
arg_index
-
1
);
return
Base
::
get_arg
(
arg_index
-
1
);
}
}
...
...
test/format-test.cc
View file @
e0243000
...
@@ -1696,7 +1696,7 @@ struct test_context {
...
@@ -1696,7 +1696,7 @@ struct test_context {
template
<
typename
Id
>
template
<
typename
Id
>
constexpr
void
check_arg_id
(
Id
)
{}
constexpr
void
check_arg_id
(
Id
)
{}
constexpr
unsigned
next_arg_i
ndex
()
{
return
33
;
}
constexpr
unsigned
next_arg_i
d
()
{
return
33
;
}
void
on_error
(
const
char
*
)
{}
void
on_error
(
const
char
*
)
{}
...
...
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