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
a9a90181
Commit
a9a90181
authored
May 29, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move wmemory_buffer to wchar.h
parent
4a7801c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
18 deletions
+14
-18
include/fmt/format.h
include/fmt/format.h
+2
-11
include/fmt/wchar.h
include/fmt/wchar.h
+1
-0
test/format-test.cc
test/format-test.cc
+5
-7
test/wchar-test.cc
test/wchar-test.cc
+6
-0
No files found.
include/fmt/format.h
View file @
a9a90181
...
@@ -647,15 +647,7 @@ enum { inline_buffer_size = 500 };
...
@@ -647,15 +647,7 @@ enum { inline_buffer_size = 500 };
A dynamically growing memory buffer for trivially copyable/constructible types
A dynamically growing memory buffer for trivially copyable/constructible types
with the first ``SIZE`` elements stored in the object itself.
with the first ``SIZE`` elements stored in the object itself.
You can use one of the following type aliases for common character types:
You can use the ```memory_buffer`` type alias for ``char`` instead.
+----------------+------------------------------+
| Type | Definition |
+================+==============================+
| memory_buffer | basic_memory_buffer<char> |
+----------------+------------------------------+
| wmemory_buffer | basic_memory_buffer<wchar_t> |
+----------------+------------------------------+
**Example**::
**Example**::
...
@@ -785,7 +777,6 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
...
@@ -785,7 +777,6 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
}
}
using
memory_buffer
=
basic_memory_buffer
<
char
>
;
using
memory_buffer
=
basic_memory_buffer
<
char
>
;
using
wmemory_buffer
=
basic_memory_buffer
<
wchar_t
>
;
template
<
typename
T
,
size_t
SIZE
,
typename
Allocator
>
template
<
typename
T
,
size_t
SIZE
,
typename
Allocator
>
struct
is_contiguous
<
basic_memory_buffer
<
T
,
SIZE
,
Allocator
>>
:
std
::
true_type
{
struct
is_contiguous
<
basic_memory_buffer
<
T
,
SIZE
,
Allocator
>>
:
std
::
true_type
{
...
@@ -1152,7 +1143,7 @@ inline It format_uint(It out, UInt value, int num_digits, bool upper = false) {
...
@@ -1152,7 +1143,7 @@ inline It format_uint(It out, UInt value, int num_digits, bool upper = false) {
// A converter from UTF-8 to UTF-16.
// A converter from UTF-8 to UTF-16.
class
utf8_to_utf16
{
class
utf8_to_utf16
{
private:
private:
wmemory_buffer
buffer_
;
basic_memory_buffer
<
wchar_t
>
buffer_
;
public:
public:
FMT_API
explicit
utf8_to_utf16
(
string_view
s
);
FMT_API
explicit
utf8_to_utf16
(
string_view
s
);
...
...
include/fmt/wchar.h
View file @
a9a90181
...
@@ -24,6 +24,7 @@ using wstring_view = basic_string_view<wchar_t>;
...
@@ -24,6 +24,7 @@ using wstring_view = basic_string_view<wchar_t>;
using
wformat_parse_context
=
basic_format_parse_context
<
wchar_t
>
;
using
wformat_parse_context
=
basic_format_parse_context
<
wchar_t
>
;
using
wformat_context
=
buffer_context
<
wchar_t
>
;
using
wformat_context
=
buffer_context
<
wchar_t
>
;
using
wformat_args
=
basic_format_args
<
wformat_context
>
;
using
wformat_args
=
basic_format_args
<
wformat_context
>
;
using
wmemory_buffer
=
basic_memory_buffer
<
wchar_t
>
;
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
// Workaround broken conversion on older gcc.
// Workaround broken conversion on older gcc.
...
...
test/format-test.cc
View file @
a9a90181
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
#include "fmt/format.h"
#include "fmt/format.h"
// clang-format on
// clang-format on
#include <stdint.h> // uint32_t
#include <stdint.h> // uint32_t
#include <climits> // INT_MAX
#include <climits> // INT_MAX
#include <cmath> // std::signbit
#include <cmath> // std::signbit
#include <cstring> // std::strlen
#include <cstring> // std::strlen
...
@@ -1896,12 +1897,9 @@ TEST(format_test, format_to_wide) {
...
@@ -1896,12 +1897,9 @@ TEST(format_test, format_to_wide) {
}
}
TEST
(
format_test
,
format_to_memory_buffer
)
{
TEST
(
format_test
,
format_to_memory_buffer
)
{
fmt
::
basic_memory_buffer
<
char
,
100
>
buffer
;
auto
buf
=
fmt
::
basic_memory_buffer
<
char
,
100
>
();
fmt
::
format_to
(
buffer
,
"{}"
,
"foo"
);
fmt
::
format_to
(
buf
,
"{}"
,
"foo"
);
EXPECT_EQ
(
"foo"
,
to_string
(
buffer
));
EXPECT_EQ
(
"foo"
,
to_string
(
buf
));
fmt
::
wmemory_buffer
wbuffer
;
fmt
::
format_to
(
wbuffer
,
L"{}"
,
L"foo"
);
EXPECT_EQ
(
L"foo"
,
to_string
(
wbuffer
));
}
}
TEST
(
format_test
,
format_to_vector
)
{
TEST
(
format_test
,
format_to_vector
)
{
...
...
test/wchar-test.cc
View file @
a9a90181
...
@@ -37,6 +37,12 @@ TEST(wchar_test, vformat_to) {
...
@@ -37,6 +37,12 @@ TEST(wchar_test, vformat_to) {
EXPECT_EQ
(
L"42"
,
w
);
EXPECT_EQ
(
L"42"
,
w
);
}
}
TEST
(
wchar_test
,
format_to_memory_buffer
)
{
auto
buf
=
fmt
::
wmemory_buffer
();
fmt
::
format_to
(
buf
,
L"{}"
,
L"foo"
);
EXPECT_EQ
(
L"foo"
,
to_string
(
buf
));
}
TEST
(
format_test
,
wide_format_to_n
)
{
TEST
(
format_test
,
wide_format_to_n
)
{
wchar_t
buffer
[
4
];
wchar_t
buffer
[
4
];
buffer
[
3
]
=
L'x'
;
buffer
[
3
]
=
L'x'
;
...
...
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