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
0e72c980
Commit
0e72c980
authored
Jun 19, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make undocumented output_range internal
parent
f13906f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
39 deletions
+32
-39
include/fmt/chrono.h
include/fmt/chrono.h
+1
-1
include/fmt/format.h
include/fmt/format.h
+27
-33
include/fmt/locale.h
include/fmt/locale.h
+1
-1
test/format
test/format
+3
-4
No files found.
include/fmt/chrono.h
View file @
0e72c980
...
...
@@ -696,7 +696,7 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
// is not specified.
basic_memory_buffer
<
Char
>
buf
;
auto
out
=
std
::
back_inserter
(
buf
);
typedef
output_range
<
decltype
(
ctx
.
out
()),
Char
>
range
;
using
range
=
internal
::
output_range
<
decltype
(
ctx
.
out
()),
Char
>
;
basic_writer
<
range
>
w
(
range
(
ctx
.
out
()));
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
spec
.
width_
,
width_ref
,
ctx
,
format_str
.
begin
());
...
...
include/fmt/format.h
View file @
0e72c980
...
...
@@ -225,54 +225,35 @@ template <typename T> inline bool use_grisu() {
sizeof
(
T
)
<=
sizeof
(
double
);
}
// A range w
hose output iterator appends
to a buffer.
// A range w
ith an iterator appending
to a buffer.
template
<
typename
T
>
class
buffer_range
{
public:
using
value_type
=
T
;
using
iterator
=
std
::
back_insert_iterator
<
internal
::
buffer
<
T
>>
;
using
iterator
=
std
::
back_insert_iterator
<
buffer
<
T
>>
;
private:
iterator
begin_
;
public:
buffer_range
(
internal
::
buffer
<
T
>&
buf
)
:
begin_
(
std
::
back_inserter
(
buf
))
{}
buffer_range
(
buffer
<
T
>&
buf
)
:
begin_
(
std
::
back_inserter
(
buf
))
{}
explicit
buffer_range
(
iterator
it
)
:
begin_
(
it
)
{}
iterator
begin
()
const
{
return
begin_
;
}
};
}
// namespace internal
// A range with the specified output iterator and value type.
template
<
typename
OutputIt
,
typename
T
=
typename
OutputIt
::
value_type
>
class
output_range
{
private:
OutputIt
it_
;
// Unused yet.
typedef
void
sentinel
;
sentinel
end
()
const
;
public:
typedef
OutputIt
iterator
;
typedef
T
value_type
;
using
value_type
=
T
;
using
iterator
=
OutputIt
;
explicit
output_range
(
OutputIt
it
)
:
it_
(
it
)
{}
OutputIt
begin
()
const
{
return
it_
;
}
};
template
<
typename
Range
>
class
basic_writer
;
using
writer
=
basic_writer
<
internal
::
buffer_range
<
char
>>
;
using
wwriter
=
basic_writer
<
internal
::
buffer_range
<
wchar_t
>>
;
/** A formatting error such as invalid format string. */
class
format_error
:
public
std
::
runtime_error
{
public:
explicit
format_error
(
const
char
*
message
)
:
std
::
runtime_error
(
message
)
{}
explicit
format_error
(
const
std
::
string
&
message
)
:
std
::
runtime_error
(
message
)
{}
~
format_error
()
FMT_NOEXCEPT
;
};
namespace
internal
{
#ifdef _SECURE_SCL
// Make a checked iterator to avoid MSVC warnings.
template
<
typename
T
>
using
checked_ptr
=
stdext
::
checked_array_iterator
<
T
*>
;
...
...
@@ -287,10 +268,9 @@ template <typename T> inline T* make_checked(T* p, std::size_t) { return p; }
template
<
typename
T
>
template
<
typename
U
>
void
buffer
<
T
>::
append
(
const
U
*
begin
,
const
U
*
end
)
{
std
::
size_t
new_size
=
size_
+
internal
::
to_unsigned
(
end
-
begin
);
std
::
size_t
new_size
=
size_
+
to_unsigned
(
end
-
begin
);
reserve
(
new_size
);
std
::
uninitialized_copy
(
begin
,
end
,
internal
::
make_checked
(
ptr_
,
capacity_
)
+
size_
);
std
::
uninitialized_copy
(
begin
,
end
,
make_checked
(
ptr_
,
capacity_
)
+
size_
);
size_
=
new_size
;
}
}
// namespace internal
...
...
@@ -436,6 +416,19 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
typedef
basic_memory_buffer
<
char
>
memory_buffer
;
typedef
basic_memory_buffer
<
wchar_t
>
wmemory_buffer
;
/** A formatting error such as invalid format string. */
class
format_error
:
public
std
::
runtime_error
{
public:
explicit
format_error
(
const
char
*
message
)
:
std
::
runtime_error
(
message
)
{}
explicit
format_error
(
const
std
::
string
&
message
)
:
std
::
runtime_error
(
message
)
{}
~
format_error
()
FMT_NOEXCEPT
;
};
template
<
typename
Range
>
class
basic_writer
;
using
writer
=
basic_writer
<
internal
::
buffer_range
<
char
>>
;
using
wwriter
=
basic_writer
<
internal
::
buffer_range
<
wchar_t
>>
;
namespace
internal
{
// A workaround for std::string not having mutable data() until C++17.
...
...
@@ -2981,8 +2974,9 @@ struct formatter<T, Char,
specs_
.
width_
,
specs_
.
width_ref
,
ctx
,
format_str_
);
internal
::
handle_dynamic_spec
<
internal
::
precision_checker
>
(
specs_
.
precision
,
specs_
.
precision_ref
,
ctx
,
format_str_
);
using
range_type
=
output_range
<
typename
FormatContext
::
iterator
,
typename
FormatContext
::
char_type
>
;
using
range_type
=
internal
::
output_range
<
typename
FormatContext
::
iterator
,
typename
FormatContext
::
char_type
>
;
return
visit_format_arg
(
arg_formatter
<
range_type
>
(
ctx
,
nullptr
,
&
specs_
),
internal
::
make_arg
<
FormatContext
>
(
val
));
}
...
...
@@ -3073,8 +3067,8 @@ template <typename Char = char> class dynamic_formatter {
else
if
(
specs_
.
has
(
HASH_FLAG
))
checker
.
on_hash
();
if
(
specs_
.
precision
!=
-
1
)
checker
.
end_precision
();
typedef
output_range
<
typename
FormatContext
::
iterator
,
typename
FormatContext
::
char_type
>
typedef
internal
::
output_range
<
typename
FormatContext
::
iterator
,
typename
FormatContext
::
char_type
>
range
;
visit_format_arg
(
arg_formatter
<
range
>
(
ctx
,
nullptr
,
&
specs_
),
internal
::
make_arg
<
FormatContext
>
(
val
));
...
...
@@ -3373,7 +3367,7 @@ template <typename S, typename OutputIt, typename... Args,
inline
OutputIt
vformat_to
(
OutputIt
out
,
const
S
&
format_str
,
typename
format_args_t
<
OutputIt
,
char_t
<
S
>>::
type
args
)
{
typedef
output_range
<
OutputIt
,
char_t
<
S
>>
range
;
typedef
internal
::
output_range
<
OutputIt
,
char_t
<
S
>>
range
;
return
vformat_to
<
arg_formatter
<
range
>>
(
range
(
out
),
to_string_view
(
format_str
),
args
);
}
...
...
include/fmt/locale.h
View file @
0e72c980
...
...
@@ -55,7 +55,7 @@ template <typename S, typename OutputIt, typename... Args,
inline
OutputIt
vformat_to
(
OutputIt
out
,
const
std
::
locale
&
loc
,
const
S
&
format_str
,
typename
format_args_t
<
OutputIt
,
Char
>::
type
args
)
{
using
range
=
output_range
<
OutputIt
,
Char
>
;
using
range
=
internal
::
output_range
<
OutputIt
,
Char
>
;
return
vformat_to
<
arg_formatter
<
range
>>
(
range
(
out
),
to_string_view
(
format_str
),
args
,
internal
::
locale_ref
(
loc
));
}
...
...
test/format
View file @
0e72c980
...
...
@@ -693,9 +693,8 @@ struct formatter {
specs_.width_, specs_.width_ref, ctx, nullptr);
fmt::internal::handle_dynamic_spec<fmt::internal::precision_checker>(
specs_.precision, specs_.precision_ref, ctx, nullptr);
typedef fmt::output_range<typename FormatContext::iterator,
typename FormatContext::char_type>
range_type;
using range_type = fmt::internal::output_range<typename FormatContext::iterator,
typename FormatContext::char_type>;
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
basic_format_arg<FormatContext>(val));
}
...
...
@@ -742,7 +741,7 @@ template<class Out, class... Args>
template<class Out>
Out vformat_to(Out out, string_view fmt, format_args_t<Out, char> args) {
typedef fmt::output_range<Out, char> range
;
using range = fmt::internal::output_range<Out, char>
;
detail::format_handler<detail::arg_formatter<range>, char, basic_format_context<Out, char>>
h(range(out), fmt, args, {});
fmt::internal::parse_format_string<false>(fmt::to_string_view(fmt), h);
...
...
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