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
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
...
...
@@ -371,7 +371,7 @@ typedef basic_writer<char> writer;
typedef
basic_writer
<
wchar_t
>
wwriter
;
template
<
typename
Context
>
class
basic_
format_
arg
;
class
basic_arg
;
template
<
typename
Char
>
class
ArgFormatter
;
...
...
@@ -587,16 +587,16 @@ inline T *make_ptr(T *ptr, std::size_t) { return ptr; }
\endrst
*/
template
<
typename
T
>
class
B
uffer
{
class
b
uffer
{
private:
FMT_DISALLOW_COPY_AND_ASSIGN
(
B
uffer
);
FMT_DISALLOW_COPY_AND_ASSIGN
(
b
uffer
);
protected:
T
*
ptr_
;
std
::
size_t
size_
;
std
::
size_t
capacity_
;
B
uffer
(
T
*
ptr
=
0
,
std
::
size_t
capacity
=
0
)
b
uffer
(
T
*
ptr
=
0
,
std
::
size_t
capacity
=
0
)
:
ptr_
(
ptr
),
size_
(
0
),
capacity_
(
capacity
)
{}
/**
...
...
@@ -608,7 +608,7 @@ class Buffer {
virtual
void
grow
(
std
::
size_t
size
)
=
0
;
public:
virtual
~
B
uffer
()
{}
virtual
~
b
uffer
()
{}
/** Returns the size of this buffer. */
std
::
size_t
size
()
const
{
return
size_
;
}
...
...
@@ -653,7 +653,7 @@ class Buffer {
template
<
typename
T
>
template
<
typename
U
>
void
B
uffer
<
T
>::
append
(
const
U
*
begin
,
const
U
*
end
)
{
void
b
uffer
<
T
>::
append
(
const
U
*
begin
,
const
U
*
end
)
{
std
::
size_t
new_size
=
size_
+
internal
::
to_unsigned
(
end
-
begin
);
if
(
new_size
>
capacity_
)
grow
(
new_size
);
...
...
@@ -667,7 +667,7 @@ namespace internal {
// A memory buffer for trivially copyable/constructible types with the first
// SIZE elements stored in the object itself.
template
<
typename
T
,
std
::
size_t
SIZE
,
typename
Allocator
=
std
::
allocator
<
T
>
>
class
MemoryBuffer
:
private
Allocator
,
public
B
uffer
<
T
>
{
class
MemoryBuffer
:
private
Allocator
,
public
b
uffer
<
T
>
{
private:
T
data_
[
SIZE
];
...
...
@@ -681,7 +681,7 @@ class MemoryBuffer : private Allocator, public Buffer<T> {
public:
explicit
MemoryBuffer
(
const
Allocator
&
alloc
=
Allocator
())
:
Allocator
(
alloc
),
B
uffer
<
T
>
(
data_
,
SIZE
)
{}
:
Allocator
(
alloc
),
b
uffer
<
T
>
(
data_
,
SIZE
)
{}
~
MemoryBuffer
()
{
deallocate
();
}
#if FMT_USE_RVALUE_REFERENCES
...
...
@@ -743,9 +743,10 @@ void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size) {
// A fixed-size buffer.
template
<
typename
Char
>
class
FixedBuffer
:
public
fmt
::
B
uffer
<
Char
>
{
class
FixedBuffer
:
public
fmt
::
b
uffer
<
Char
>
{
public:
FixedBuffer
(
Char
*
array
,
std
::
size_t
size
)
:
fmt
::
Buffer
<
Char
>
(
array
,
size
)
{}
FixedBuffer
(
Char
*
array
,
std
::
size_t
size
)
:
fmt
::
buffer
<
Char
>
(
array
,
size
)
{}
protected:
FMT_API
void
grow
(
std
::
size_t
size
);
...
...
@@ -1322,34 +1323,34 @@ template <typename Context>
class
ArgMap
;
template
<
typename
Context
,
typename
T
>
basic_
format_
arg
<
Context
>
make_arg
(
const
T
&
value
);
basic_arg
<
Context
>
make_arg
(
const
T
&
value
);
}
// namespace internal
struct
monostate
{};
template
<
typename
Context
>
class
basic_
format_
args
;
class
basic_args
;
// A formatting argument. It is a trivially copyable/constructible type to
// allow storage in internal::MemoryBuffer.
template
<
typename
Context
>
class
basic_
format_
arg
{
class
basic_arg
{
private:
internal
::
value
<
Context
>
value_
;
internal
::
Type
type_
;
template
<
typename
ContextType
,
typename
T
>
friend
basic_
format_
arg
<
ContextType
>
internal
::
make_arg
(
const
T
&
value
);
friend
basic_arg
<
ContextType
>
internal
::
make_arg
(
const
T
&
value
);
template
<
typename
Visitor
,
typename
Ctx
>
friend
typename
std
::
result_of
<
Visitor
(
int
)
>::
type
visit
(
Visitor
&&
vis
,
basic_
format_
arg
<
Ctx
>
arg
);
visit
(
Visitor
&&
vis
,
basic_arg
<
Ctx
>
arg
);
friend
class
basic_
format_
args
<
Context
>
;
friend
class
basic_args
<
Context
>
;
friend
class
internal
::
ArgMap
<
Context
>
;
public:
basic_
format_
arg
()
:
type_
(
internal
::
NONE
)
{}
basic_arg
()
:
type_
(
internal
::
NONE
)
{}
explicit
operator
bool
()
const
noexcept
{
return
type_
!=
internal
::
NONE
;
}
...
...
@@ -1368,8 +1369,8 @@ class basic_format_arg {
}
};
typedef
basic_
format_
arg
<
format_context
>
format_arg
;
typedef
basic_
format_
arg
<
wformat_context
>
wformat_arg
;
typedef
basic_arg
<
format_context
>
format_arg
;
typedef
basic_arg
<
wformat_context
>
wformat_arg
;
/**
\rst
...
...
@@ -1380,7 +1381,7 @@ typedef basic_format_arg<wformat_context> wformat_arg;
*/
template
<
typename
Visitor
,
typename
Context
>
typename
std
::
result_of
<
Visitor
(
int
)
>::
type
visit
(
Visitor
&&
vis
,
basic_
format_
arg
<
Context
>
arg
)
{
visit
(
Visitor
&&
vis
,
basic_arg
<
Context
>
arg
)
{
typedef
typename
Context
::
char_type
Char
;
switch
(
arg
.
type_
)
{
case
internal
:
:
NONE
:
...
...
@@ -1422,8 +1423,8 @@ typename std::result_of<Visitor(int)>::type
namespace
internal
{
template
<
typename
Context
,
typename
T
>
basic_
format_
arg
<
Context
>
make_arg
(
const
T
&
value
)
{
basic_
format_
arg
<
Context
>
arg
;
basic_arg
<
Context
>
make_arg
(
const
T
&
value
)
{
basic_arg
<
Context
>
arg
;
arg
.
type_
=
internal
::
type
<
T
>
();
arg
.
value_
=
value
;
return
arg
;
...
...
@@ -1474,14 +1475,14 @@ void format_value(basic_writer<Char> &, const T &, Formatter &, const Char *) {
}
template
<
typename
Context
>
struct
NamedArg
:
basic_
format_
arg
<
Context
>
{
struct
NamedArg
:
basic_arg
<
Context
>
{
typedef
typename
Context
::
char_type
Char
;
BasicStringRef
<
Char
>
name
;
template
<
typename
T
>
NamedArg
(
BasicStringRef
<
Char
>
argname
,
const
T
&
value
)
:
basic_
format_
arg
<
Context
>
(
make_arg
<
Context
>
(
value
)),
name
(
argname
)
{}
:
basic_arg
<
Context
>
(
make_arg
<
Context
>
(
value
)),
name
(
argname
)
{}
};
class
RuntimeError
:
public
std
::
runtime_error
{
...
...
@@ -1508,7 +1509,7 @@ inline typename std::enable_if<IS_PACKED, value<Context>>::type
}
template
<
bool
IS_PACKED
,
typename
Context
,
typename
T
>
inline
typename
std
::
enable_if
<!
IS_PACKED
,
basic_
format_
arg
<
Context
>>::
type
inline
typename
std
::
enable_if
<!
IS_PACKED
,
basic_arg
<
Context
>>::
type
make_arg
(
const
T
&
value
)
{
return
make_arg
<
Context
>
(
value
);
}
...
...
@@ -1525,7 +1526,7 @@ class format_arg_store {
typedef
typename
Context
::
char_type
char_type
;
typedef
typename
std
::
conditional
<
IS_PACKED
,
internal
::
value
<
Context
>
,
basic_
format_
arg
<
Context
>>::
type
value_type
;
internal
::
value
<
Context
>
,
basic_arg
<
Context
>>::
type
value_type
;
// If the arguments are not packed, add one more element to mark the end.
typedef
std
::
array
<
value_type
,
NUM_ARGS
+
(
IS_PACKED
?
0
:
1
)
>
Array
;
...
...
@@ -1554,10 +1555,10 @@ inline format_arg_store<format_context, Args...>
/** Formatting arguments. */
template
<
typename
Context
>
class
basic_
format_
args
{
class
basic_args
{
public:
typedef
unsigned
size_type
;
typedef
basic_
format_
arg
<
Context
>
format_arg
;
typedef
basic_arg
<
Context
>
format_arg
;
private:
// To reduce compiled code size per formatting function call, types of first
...
...
@@ -1610,10 +1611,10 @@ class basic_format_args {
}
public:
basic_
format_
args
()
:
types_
(
0
)
{}
basic_args
()
:
types_
(
0
)
{}
template
<
typename
...
Args
>
basic_
format_
args
(
const
format_arg_store
<
Context
,
Args
...
>
&
store
)
basic_args
(
const
format_arg_store
<
Context
,
Args
...
>
&
store
)
:
types_
(
store
.
TYPES
)
{
set_data
(
store
.
data
());
}
...
...
@@ -1626,8 +1627,8 @@ class basic_format_args {
}
};
typedef
basic_
format_
args
<
format_context
>
format_args
;
typedef
basic_
format_
args
<
wformat_context
>
wformat_args
;
typedef
basic_args
<
format_context
>
format_args
;
typedef
basic_args
<
wformat_context
>
wformat_args
;
enum
Alignment
{
ALIGN_DEFAULT
,
ALIGN_LEFT
,
ALIGN_RIGHT
,
ALIGN_CENTER
,
ALIGN_NUMERIC
...
...
@@ -1791,15 +1792,15 @@ class ArgMap {
private:
typedef
typename
Context
::
char_type
Char
;
typedef
std
::
vector
<
std
::
pair
<
fmt
::
BasicStringRef
<
Char
>
,
basic_
format_
arg
<
Context
>
>
>
MapType
;
std
::
pair
<
fmt
::
BasicStringRef
<
Char
>
,
basic_arg
<
Context
>
>
>
MapType
;
typedef
typename
MapType
::
value_type
Pair
;
MapType
map_
;
public:
void
init
(
const
basic_
format_
args
<
Context
>
&
args
);
void
init
(
const
basic_args
<
Context
>
&
args
);
const
basic_
format_
arg
<
Context
>
const
basic_arg
<
Context
>
*
find
(
const
fmt
::
BasicStringRef
<
Char
>
&
name
)
const
{
// The list is unsorted, so just return the first matching name.
for
(
typename
MapType
::
const_iterator
it
=
map_
.
begin
(),
end
=
map_
.
end
();
...
...
@@ -1812,7 +1813,7 @@ class ArgMap {
};
template
<
typename
Context
>
void
ArgMap
<
Context
>::
init
(
const
basic_
format_
args
<
Context
>
&
args
)
{
void
ArgMap
<
Context
>::
init
(
const
basic_args
<
Context
>
&
args
)
{
if
(
!
map_
.
empty
())
return
;
typedef
internal
::
NamedArg
<
Context
>
NamedArg
;
...
...
@@ -1987,17 +1988,17 @@ template <typename Char, typename Context>
class
format_context_base
{
private:
const
Char
*
ptr_
;
basic_
format_
args
<
Context
>
args_
;
basic_args
<
Context
>
args_
;
int
next_arg_index_
;
protected:
typedef
basic_
format_
arg
<
Context
>
format_arg
;
typedef
basic_arg
<
Context
>
format_arg
;
format_context_base
(
const
Char
*
format_str
,
basic_
format_
args
<
Context
>
args
)
format_context_base
(
const
Char
*
format_str
,
basic_args
<
Context
>
args
)
:
ptr_
(
format_str
),
args_
(
args
),
next_arg_index_
(
0
)
{}
~
format_context_base
()
{}
basic_
format_
args
<
Context
>
args
()
const
{
return
args_
;
}
basic_args
<
Context
>
args
()
const
{
return
args_
;
}
// Returns the argument with specified index.
format_arg
do_get_arg
(
unsigned
arg_index
,
const
char
*&
error
)
{
...
...
@@ -2097,7 +2098,7 @@ class basic_format_context :
\endrst
*/
basic_format_context
(
const
Char
*
format_str
,
basic_
format_
args
<
basic_format_context
>
args
)
basic_args
<
basic_format_context
>
args
)
:
Base
(
format_str
,
args
)
{}
// Parses argument id and returns corresponding argument.
...
...
@@ -2203,7 +2204,7 @@ class basic_writer {
private:
// Output buffer.
B
uffer
<
Char
>
&
buffer_
;
b
uffer
<
Char
>
&
buffer_
;
FMT_DISALLOW_COPY_AND_ASSIGN
(
basic_writer
);
...
...
@@ -2306,7 +2307,7 @@ class basic_writer {
/**
Constructs a ``basic_writer`` object.
*/
explicit
basic_writer
(
B
uffer
<
Char
>
&
b
)
:
buffer_
(
b
)
{}
explicit
basic_writer
(
b
uffer
<
Char
>
&
b
)
:
buffer_
(
b
)
{}
public:
/**
...
...
@@ -2348,7 +2349,7 @@ class basic_writer {
}
void
vformat
(
BasicCStringRef
<
Char
>
format
,
basic_
format_
args
<
basic_format_context
<
Char
>>
args
);
basic_args
<
basic_format_context
<
Char
>>
args
);
/**
\rst
Writes formatted data.
...
...
@@ -2447,7 +2448,7 @@ class basic_writer {
void
clear
()
FMT_NOEXCEPT
{
buffer_
.
clear
();
}
B
uffer
<
Char
>
&
buffer
()
FMT_NOEXCEPT
{
return
buffer_
;
}
b
uffer
<
Char
>
&
buffer
()
FMT_NOEXCEPT
{
return
buffer_
;
}
};
template
<
typename
Char
>
...
...
@@ -3242,7 +3243,7 @@ unsigned parse_nonnegative_int(const Char *&s) {
template
<
typename
Char
>
inline
void
require_numeric_argument
(
const
basic_
format_
arg
<
Char
>
&
arg
,
char
spec
)
{
const
basic_arg
<
Char
>
&
arg
,
char
spec
)
{
if
(
!
arg
.
is_numeric
())
{
FMT_THROW
(
fmt
::
format_error
(
fmt
::
format
(
"format specifier '{}' requires numeric argument"
,
spec
)));
...
...
@@ -3264,7 +3265,7 @@ struct IsUnsigned {
};
template
<
typename
Char
,
typename
Context
>
void
check_sign
(
const
Char
*&
s
,
const
basic_
format_
arg
<
Context
>
&
arg
)
{
void
check_sign
(
const
Char
*&
s
,
const
basic_arg
<
Context
>
&
arg
)
{
char
sign
=
static_cast
<
char
>
(
*
s
);
require_numeric_argument
(
arg
,
sign
);
if
(
visit
(
IsUnsigned
(),
arg
))
{
...
...
@@ -3378,7 +3379,7 @@ inline typename basic_format_context<Char>::format_arg
// Formats a single argument.
template
<
typename
ArgFormatter
,
typename
Char
,
typename
Context
>
void
do_format_arg
(
basic_writer
<
Char
>
&
writer
,
basic_
format_
arg
<
Context
>
arg
,
void
do_format_arg
(
basic_writer
<
Char
>
&
writer
,
basic_arg
<
Context
>
arg
,
Context
&
ctx
)
{
const
Char
*&
s
=
ctx
.
ptr
();
basic_format_specs
<
Char
>
spec
;
...
...
@@ -3505,7 +3506,7 @@ void do_format_arg(basic_writer<Char> &writer, basic_format_arg<Context> arg,
/** Formats arguments and writes the output to the writer. */
template
<
typename
ArgFormatter
,
typename
Char
,
typename
Context
>
void
vwrite
(
basic_writer
<
Char
>
&
writer
,
BasicCStringRef
<
Char
>
format_str
,
basic_
format_
args
<
Context
>
args
)
{
basic_args
<
Context
>
args
)
{
basic_format_context
<
Char
>
ctx
(
format_str
.
c_str
(),
args
);
const
Char
*&
s
=
ctx
.
ptr
();
const
Char
*
start
=
s
;
...
...
@@ -3531,7 +3532,7 @@ void vwrite(basic_writer<Char> &writer, BasicCStringRef<Char> format_str,
template
<
typename
Char
>
inline
void
basic_writer
<
Char
>::
vformat
(
BasicCStringRef
<
Char
>
format
,
basic_
format_
args
<
basic_format_context
<
Char
>>
args
)
{
basic_args
<
basic_format_context
<
Char
>>
args
)
{
vwrite
<
ArgFormatter
<
Char
>>
(
*
this
,
format
,
args
);
}
}
// namespace fmt
...
...
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