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
7ae8bd70
Commit
7ae8bd70
authored
Feb 05, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic_format_arg -> basic_arg, Buffer -> buffer
parent
bf0f1075
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
79 deletions
+80
-79
fmt/format.h
fmt/format.h
+51
-50
fmt/ostream.h
fmt/ostream.h
+2
-2
fmt/printf.h
fmt/printf.h
+10
-10
fmt/string.h
fmt/string.h
+1
-1
fmt/time.h
fmt/time.h
+1
-1
test/custom-formatter-test.cc
test/custom-formatter-test.cc
+1
-1
test/ostream-test.cc
test/ostream-test.cc
+1
-1
test/util-test.cc
test/util-test.cc
+13
-13
No files found.
fmt/format.h
View file @
7ae8bd70
This diff is collapsed.
Click to expand it.
fmt/ostream.h
View file @
7ae8bd70
...
...
@@ -23,11 +23,11 @@ class FormatBuf : public std::basic_streambuf<Char> {
typedef
typename
std
::
basic_streambuf
<
Char
>::
int_type
int_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
traits_type
traits_type
;
B
uffer
<
Char
>
&
buffer_
;
b
uffer
<
Char
>
&
buffer_
;
Char
*
start_
;
public:
FormatBuf
(
B
uffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
),
start_
(
&
buffer
[
0
])
{
FormatBuf
(
b
uffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
),
start_
(
&
buffer
[
0
])
{
this
->
setp
(
start_
,
start_
+
buffer_
.
capacity
());
}
...
...
fmt/printf.h
View file @
7ae8bd70
...
...
@@ -85,11 +85,11 @@ class ArgConverter {
private:
typedef
typename
Context
::
char_type
Char
;
basic_
format_
arg
<
Context
>
&
arg_
;
basic_arg
<
Context
>
&
arg_
;
typename
Context
::
char_type
type_
;
public:
ArgConverter
(
basic_
format_
arg
<
Context
>
&
arg
,
Char
type
)
ArgConverter
(
basic_arg
<
Context
>
&
arg
,
Char
type
)
:
arg_
(
arg
),
type_
(
type
)
{}
void
operator
()(
bool
value
)
{
...
...
@@ -139,7 +139,7 @@ class ArgConverter {
// type depending on the type specifier: 'd' and 'i' - signed, other -
// unsigned).
template
<
typename
T
,
typename
Context
,
typename
Char
>
void
convert_arg
(
basic_
format_
arg
<
Context
>
&
arg
,
Char
type
)
{
void
convert_arg
(
basic_arg
<
Context
>
&
arg
,
Char
type
)
{
visit
(
ArgConverter
<
T
,
Context
>
(
arg
,
type
),
arg
);
}
...
...
@@ -147,12 +147,12 @@ void convert_arg(basic_format_arg<Context> &arg, Char type) {
template
<
typename
Context
>
class
CharConverter
{
private:
basic_
format_
arg
<
Context
>
&
arg_
;
basic_arg
<
Context
>
&
arg_
;
FMT_DISALLOW_COPY_AND_ASSIGN
(
CharConverter
);
public:
explicit
CharConverter
(
basic_
format_
arg
<
Context
>
&
arg
)
:
arg_
(
arg
)
{}
explicit
CharConverter
(
basic_arg
<
Context
>
&
arg
)
:
arg_
(
arg
)
{}
template
<
typename
T
>
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
...
...
@@ -287,7 +287,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** Formats an argument of a custom (user-defined) type. */
void
operator
()(
internal
::
CustomValue
<
Char
>
c
)
{
const
Char
format_str
[]
=
{
'}'
,
'\0'
};
auto
args
=
basic_
format_
args
<
basic_format_context
<
Char
>>
();
auto
args
=
basic_args
<
basic_format_context
<
Char
>>
();
basic_format_context
<
Char
>
ctx
(
format_str
,
args
);
c
.
format
(
this
->
writer
(),
c
.
value
,
&
ctx
);
}
...
...
@@ -328,7 +328,7 @@ class printf_context :
\endrst
*/
explicit
printf_context
(
BasicCStringRef
<
Char
>
format_str
,
basic_
format_
args
<
printf_context
>
args
)
basic_args
<
printf_context
>
args
)
:
Base
(
format_str
.
c_str
(),
args
)
{}
/** Formats stored arguments and writes the output to the writer. */
...
...
@@ -516,11 +516,11 @@ void format_value(basic_writer<Char> &w, const T &value,
template
<
typename
Char
>
void
printf
(
basic_writer
<
Char
>
&
w
,
BasicCStringRef
<
Char
>
format
,
basic_
format_
args
<
printf_context
<
Char
>>
args
)
{
basic_args
<
printf_context
<
Char
>>
args
)
{
printf_context
<
Char
>
(
format
,
args
).
format
(
w
);
}
typedef
basic_
format_
args
<
printf_context
<
char
>>
printf_args
;
typedef
basic_args
<
printf_context
<
char
>>
printf_args
;
inline
std
::
string
vsprintf
(
CStringRef
format
,
printf_args
args
)
{
MemoryWriter
w
;
...
...
@@ -543,7 +543,7 @@ inline std::string sprintf(CStringRef format_str, const Args & ... args) {
}
inline
std
::
wstring
vsprintf
(
WCStringRef
format
,
basic_
format_
args
<
printf_context
<
wchar_t
>>
args
)
{
WCStringRef
format
,
basic_args
<
printf_context
<
wchar_t
>>
args
)
{
WMemoryWriter
w
;
printf
(
w
,
format
,
args
);
return
w
.
str
();
...
...
fmt/string.h
View file @
7ae8bd70
...
...
@@ -18,7 +18,7 @@ namespace internal {
// A buffer that stores data in ``std::string``.
template
<
typename
Char
>
class
StringBuffer
:
public
B
uffer
<
Char
>
{
class
StringBuffer
:
public
b
uffer
<
Char
>
{
private:
std
::
basic_string
<
Char
>
data_
;
...
...
fmt/time.h
View file @
7ae8bd70
...
...
@@ -27,7 +27,7 @@ void format_value(writer &w, const std::tm &tm, format_context &ctx) {
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
format
;
format
.
append
(
s
,
end
+
1
);
format
[
format
.
size
()
-
1
]
=
'\0'
;
B
uffer
<
char
>
&
buffer
=
w
.
buffer
();
b
uffer
<
char
>
&
buffer
=
w
.
buffer
();
std
::
size_t
start
=
buffer
.
size
();
for
(;;)
{
std
::
size_t
size
=
buffer
.
capacity
()
-
start
;
...
...
test/custom-formatter-test.cc
View file @
7ae8bd70
...
...
@@ -63,7 +63,7 @@ typedef fmt::printf_context<char, CustomPrintfArgFormatter>
std
::
string
custom_vsprintf
(
const
char
*
format_str
,
fmt
::
basic_
format_
args
<
CustomPrintfFormatter
>
args
)
{
fmt
::
basic_args
<
CustomPrintfFormatter
>
args
)
{
fmt
::
MemoryWriter
writer
;
CustomPrintfFormatter
formatter
(
format_str
,
args
);
formatter
.
format
(
writer
);
...
...
test/ostream-test.cc
View file @
7ae8bd70
...
...
@@ -136,7 +136,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
class
TestWriter
:
public
fmt
::
basic_writer
<
char
>
{
private:
struct
TestBuffer
:
fmt
::
B
uffer
<
char
>
{
struct
TestBuffer
:
fmt
::
b
uffer
<
char
>
{
explicit
TestBuffer
(
std
::
size_t
size
)
{
size_
=
size
;
}
void
grow
(
std
::
size_t
)
{}
}
buffer_
;
...
...
test/util-test.cc
View file @
7ae8bd70
...
...
@@ -52,9 +52,9 @@
#undef min
#undef max
using
fmt
::
basic_
format_
arg
;
using
fmt
::
basic_arg
;
using
fmt
::
format_arg
;
using
fmt
::
B
uffer
;
using
fmt
::
b
uffer
;
using
fmt
::
StringRef
;
using
fmt
::
internal
::
MemoryBuffer
;
using
fmt
::
internal
::
value
;
...
...
@@ -74,7 +74,7 @@ void format_value(fmt::basic_writer<Char> &w, Test,
}
template
<
typename
Context
,
typename
T
>
basic_
format_
arg
<
Context
>
make_arg
(
const
T
&
value
)
{
basic_arg
<
Context
>
make_arg
(
const
T
&
value
)
{
return
fmt
::
internal
::
make_arg
<
Context
>
(
value
);
}
}
// namespace
...
...
@@ -107,24 +107,24 @@ TEST(AllocatorTest, AllocatorRef) {
#if FMT_USE_TYPE_TRAITS
TEST
(
BufferTest
,
Noncopyable
)
{
EXPECT_FALSE
(
std
::
is_copy_constructible
<
B
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_copy_assignable
<
B
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_copy_constructible
<
b
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_copy_assignable
<
b
uffer
<
char
>
>::
value
);
}
TEST
(
BufferTest
,
Nonmoveable
)
{
EXPECT_FALSE
(
std
::
is_move_constructible
<
B
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_move_assignable
<
B
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_move_constructible
<
b
uffer
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_move_assignable
<
b
uffer
<
char
>
>::
value
);
}
#endif
// A test buffer with a dummy grow method.
template
<
typename
T
>
struct
TestBuffer
:
B
uffer
<
T
>
{
struct
TestBuffer
:
b
uffer
<
T
>
{
void
grow
(
std
::
size_t
size
)
{
this
->
capacity_
=
size
;
}
};
template
<
typename
T
>
struct
MockBuffer
:
B
uffer
<
T
>
{
struct
MockBuffer
:
b
uffer
<
T
>
{
MOCK_METHOD1
(
do_grow
,
void
(
std
::
size_t
size
));
void
grow
(
std
::
size_t
size
)
{
...
...
@@ -133,8 +133,8 @@ struct MockBuffer : Buffer<T> {
}
MockBuffer
()
{}
MockBuffer
(
T
*
ptr
)
:
B
uffer
<
T
>
(
ptr
)
{}
MockBuffer
(
T
*
ptr
,
std
::
size_t
capacity
)
:
B
uffer
<
T
>
(
ptr
,
capacity
)
{}
MockBuffer
(
T
*
ptr
)
:
b
uffer
<
T
>
(
ptr
)
{}
MockBuffer
(
T
*
ptr
,
std
::
size_t
capacity
)
:
b
uffer
<
T
>
(
ptr
,
capacity
)
{}
};
TEST
(
BufferTest
,
Ctor
)
{
...
...
@@ -170,7 +170,7 @@ TEST(BufferTest, VirtualDtor) {
typedef
StrictMock
<
DyingBuffer
>
StictMockBuffer
;
StictMockBuffer
*
mock_buffer
=
new
StictMockBuffer
();
EXPECT_CALL
(
*
mock_buffer
,
die
());
B
uffer
<
int
>
*
buffer
=
mock_buffer
;
b
uffer
<
int
>
*
buffer
=
mock_buffer
;
delete
buffer
;
}
...
...
@@ -181,7 +181,7 @@ TEST(BufferTest, Access) {
EXPECT_EQ
(
11
,
buffer
[
0
]);
buffer
[
3
]
=
42
;
EXPECT_EQ
(
42
,
*
(
&
buffer
[
0
]
+
3
));
const
B
uffer
<
char
>
&
const_buffer
=
buffer
;
const
fmt
::
b
uffer
<
char
>
&
const_buffer
=
buffer
;
EXPECT_EQ
(
42
,
const_buffer
[
3
]);
}
...
...
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