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
8428621d
Commit
8428621d
authored
Dec 30, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BasicWriter -> basic_writer
parent
939aff29
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
103 deletions
+101
-103
fmt/format.cc
fmt/format.cc
+8
-8
fmt/format.h
fmt/format.h
+63
-65
fmt/ostream.cc
fmt/ostream.cc
+1
-1
fmt/ostream.h
fmt/ostream.h
+2
-2
fmt/printf.h
fmt/printf.h
+7
-7
fmt/string.h
fmt/string.h
+2
-2
fmt/time.h
fmt/time.h
+1
-1
test/custom-formatter-test.cc
test/custom-formatter-test.cc
+2
-2
test/format-test.cc
test/format-test.cc
+9
-9
test/ostream-test.cc
test/ostream-test.cc
+3
-3
test/util-test.cc
test/util-test.cc
+3
-3
No files found.
fmt/format.cc
View file @
8428621d
...
...
@@ -106,7 +106,7 @@ inline int fmt_snprintf(char *buffer, size_t size, const char *format, ...) {
const
char
RESET_COLOR
[]
=
"
\x1b
[0m"
;
typedef
void
(
*
FormatFunc
)(
W
riter
&
,
int
,
StringRef
);
typedef
void
(
*
FormatFunc
)(
w
riter
&
,
int
,
StringRef
);
// Portable thread-safe version of strerror.
// Sets buffer to point to a string describing the error code.
...
...
@@ -176,7 +176,7 @@ int safe_strerror(
return
StrError
(
error_code
,
buffer
,
buffer_size
).
run
();
}
void
format_error_code
(
W
riter
&
out
,
int
error_code
,
void
format_error_code
(
w
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
// Report error code making sure that the output fits into
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
...
...
@@ -215,7 +215,7 @@ namespace internal {
// This method is used to preserve binary compatibility with fmt 3.0.
// It can be removed in 4.0.
FMT_FUNC
void
format_system_error
(
W
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
w
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
fmt
::
format_system_error
(
out
,
error_code
,
message
);
}
}
// namespace internal
...
...
@@ -354,7 +354,7 @@ FMT_FUNC void WindowsError::init(
}
FMT_FUNC
void
internal
::
format_windows_error
(
W
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
w
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
FMT_TRY
{
MemoryBuffer
<
wchar_t
,
INLINE_BUFFER_SIZE
>
buffer
;
buffer
.
resize
(
INLINE_BUFFER_SIZE
);
...
...
@@ -383,7 +383,7 @@ FMT_FUNC void internal::format_windows_error(
#endif // FMT_USE_WINDOWS_H
FMT_FUNC
void
format_system_error
(
W
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
w
riter
&
out
,
int
error_code
,
StringRef
message
)
FMT_NOEXCEPT
{
FMT_TRY
{
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
buffer
.
resize
(
internal
::
INLINE_BUFFER_SIZE
);
...
...
@@ -440,7 +440,7 @@ FMT_FUNC void vprint_colored(Color c, CStringRef format, format_args args) {
}
template
<
typename
Char
>
void
printf
(
BasicW
riter
<
Char
>
&
w
,
BasicCStringRef
<
Char
>
format
,
void
printf
(
basic_w
riter
<
Char
>
&
w
,
BasicCStringRef
<
Char
>
format
,
format_args
args
);
FMT_FUNC
int
vfprintf
(
std
::
FILE
*
f
,
CStringRef
format
,
printf_args
args
)
{
...
...
@@ -460,7 +460,7 @@ template void internal::FixedBuffer<char>::grow(std::size_t);
template
void
internal
::
ArgMap
<
format_context
>
::
init
(
const
format_args
&
args
);
template
void
printf_context
<
char
>
::
format
(
W
riter
&
writer
);
template
void
printf_context
<
char
>
::
format
(
w
riter
&
writer
);
template
int
internal
::
CharTraits
<
char
>
::
format_float
(
char
*
buffer
,
std
::
size_t
size
,
const
char
*
format
,
...
...
@@ -478,7 +478,7 @@ template void internal::FixedBuffer<wchar_t>::grow(std::size_t);
template
void
internal
::
ArgMap
<
wformat_context
>
::
init
(
const
wformat_args
&
args
);
template
void
printf_context
<
wchar_t
>
::
format
(
WW
riter
&
writer
);
template
void
printf_context
<
wchar_t
>
::
format
(
ww
riter
&
writer
);
template
int
internal
::
CharTraits
<
wchar_t
>
::
format_float
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
...
...
fmt/format.h
View file @
8428621d
...
...
@@ -365,10 +365,10 @@ using std::move;
#endif
template
<
typename
Char
>
class
BasicW
riter
;
class
basic_w
riter
;
typedef
BasicWriter
<
char
>
W
riter
;
typedef
BasicWriter
<
wchar_t
>
WW
riter
;
typedef
basic_writer
<
char
>
w
riter
;
typedef
basic_writer
<
wchar_t
>
ww
riter
;
template
<
typename
Context
>
class
basic_format_arg
;
...
...
@@ -987,7 +987,7 @@ class UTF16ToUTF8 {
FMT_API
int
convert
(
WStringRef
s
);
};
FMT_API
void
format_windows_error
(
fmt
::
W
riter
&
out
,
int
error_code
,
FMT_API
void
format_windows_error
(
fmt
::
w
riter
&
out
,
int
error_code
,
fmt
::
StringRef
message
)
FMT_NOEXCEPT
;
#endif
...
...
@@ -1076,7 +1076,7 @@ enum Type {
};
template
<
typename
Char
>
struct
StringV
alue
{
struct
string_v
alue
{
const
Char
*
value
;
std
::
size_t
size
;
};
...
...
@@ -1084,7 +1084,7 @@ struct StringValue {
template
<
typename
Char
>
struct
CustomValue
{
typedef
void
(
*
FormatFunc
)(
BasicW
riter
<
Char
>
&
writer
,
const
void
*
arg
,
void
*
ctx
);
basic_w
riter
<
Char
>
&
writer
,
const
void
*
arg
,
void
*
ctx
);
const
void
*
value
;
FormatFunc
format
;
...
...
@@ -1161,10 +1161,10 @@ class value {
double
double_value
;
long
double
long_double_value
;
const
void
*
pointer
;
StringV
alue
<
char
>
string
;
StringV
alue
<
signed
char
>
sstring
;
StringV
alue
<
unsigned
char
>
ustring
;
StringV
alue
<
typename
Context
::
char_type
>
tstring
;
string_v
alue
<
char
>
string
;
string_v
alue
<
signed
char
>
sstring
;
string_v
alue
<
unsigned
char
>
ustring
;
string_v
alue
<
typename
Context
::
char_type
>
tstring
;
CustomValue
<
typename
Context
::
char_type
>
custom
;
};
...
...
@@ -1206,7 +1206,7 @@ class value {
// Formats an argument of a custom type, such as a user-defined class.
template
<
typename
T
>
static
void
format_custom_arg
(
BasicW
riter
<
Char
>
&
writer
,
const
void
*
arg
,
void
*
context
)
{
basic_w
riter
<
Char
>
&
writer
,
const
void
*
arg
,
void
*
context
)
{
format_value
(
writer
,
*
static_cast
<
const
T
*>
(
arg
),
*
static_cast
<
Context
*>
(
context
));
}
...
...
@@ -1466,7 +1466,7 @@ inline fmt::StringRef thousands_sep(...) { return ""; }
#endif
template
<
typename
Formatter
,
typename
T
,
typename
Char
>
void
format_value
(
BasicW
riter
<
Char
>
&
,
const
T
&
,
Formatter
&
,
const
Char
*
)
{
void
format_value
(
basic_w
riter
<
Char
>
&
,
const
T
&
,
Formatter
&
,
const
Char
*
)
{
FMT_STATIC_ASSERT
(
False
<
T
>::
value
,
"Cannot format argument. To enable the use of ostream "
"operator<< include fmt/ostream.h. Otherwise provide "
...
...
@@ -1925,7 +1925,7 @@ void ArgMap<Context>::init(const basic_format_args<Context> &args) {
template
<
typename
Char
>
class
ArgFormatterBase
{
private:
BasicW
riter
<
Char
>
&
writer_
;
basic_w
riter
<
Char
>
&
writer_
;
FormatSpec
&
spec_
;
FMT_DISALLOW_COPY_AND_ASSIGN
(
ArgFormatterBase
);
...
...
@@ -1953,7 +1953,7 @@ class ArgFormatterBase {
}
protected:
BasicW
riter
<
Char
>
&
writer
()
{
return
writer_
;
}
basic_w
riter
<
Char
>
&
writer
()
{
return
writer_
;
}
FormatSpec
&
spec
()
{
return
spec_
;
}
void
write
(
bool
value
)
{
...
...
@@ -1968,7 +1968,7 @@ class ArgFormatterBase {
public:
typedef
Char
char_type
;
ArgFormatterBase
(
BasicW
riter
<
Char
>
&
w
,
FormatSpec
&
s
)
ArgFormatterBase
(
basic_w
riter
<
Char
>
&
w
,
FormatSpec
&
s
)
:
writer_
(
w
),
spec_
(
s
)
{}
void
operator
()(
monostate
)
{
...
...
@@ -1997,7 +1997,7 @@ class ArgFormatterBase {
}
if
(
spec_
.
align_
==
ALIGN_NUMERIC
||
spec_
.
flags_
!=
0
)
FMT_THROW
(
format_error
(
"invalid format specifier for char"
));
typedef
typename
BasicW
riter
<
Char
>::
CharPtr
CharPtr
;
typedef
typename
basic_w
riter
<
Char
>::
CharPtr
CharPtr
;
Char
fill
=
internal
::
CharTraits
<
Char
>::
cast
(
spec_
.
fill
());
CharPtr
out
=
CharPtr
();
const
unsigned
CHAR_WIDTH
=
1
;
...
...
@@ -2041,7 +2041,7 @@ class ArgFormatterBase {
};
template
<
typename
Char
>
inline
void
write
(
BasicW
riter
<
Char
>
&
w
,
const
Char
*
start
,
const
Char
*
end
)
{
inline
void
write
(
basic_w
riter
<
Char
>
&
w
,
const
Char
*
start
,
const
Char
*
end
)
{
if
(
start
!=
end
)
w
<<
BasicStringRef
<
Char
>
(
start
,
internal
::
to_unsigned
(
end
-
start
));
}
...
...
@@ -2115,7 +2115,7 @@ class ArgFormatter : public internal::ArgFormatterBase<Char> {
format specifier information for standard argument types.
\endrst
*/
ArgFormatter
(
BasicW
riter
<
Char
>
&
writer
,
basic_format_context
<
Char
>
&
ctx
,
ArgFormatter
(
basic_w
riter
<
Char
>
&
writer
,
basic_format_context
<
Char
>
&
ctx
,
FormatSpec
&
spec
)
:
internal
::
ArgFormatterBase
<
Char
>
(
writer
,
spec
),
ctx_
(
ctx
)
{}
...
...
@@ -2223,7 +2223,7 @@ class SystemError : public internal::RuntimeError {
may look like "Unknown error -1" and is platform-dependent.
\endrst
*/
FMT_API
void
format_system_error
(
fmt
::
W
riter
&
out
,
int
error_code
,
FMT_API
void
format_system_error
(
fmt
::
w
riter
&
out
,
int
error_code
,
fmt
::
StringRef
message
)
FMT_NOEXCEPT
;
/**
...
...
@@ -2234,23 +2234,23 @@ FMT_API void format_system_error(fmt::Writer &out, int error_code,
You can use one of the following typedefs for common character types:
+---------+----------------------+
+---------+----------------------
-
+
| Type | Definition |
+=========+======================+
|
Writer | BasicW
riter<char> |
+---------+----------------------+
|
WWriter | BasicW
riter<wchar_t> |
+---------+----------------------+
+=========+======================
=
+
|
writer | basic_w
riter<char> |
+---------+----------------------
-
+
|
wwriter | basic_w
riter<wchar_t> |
+---------+----------------------
-
+
\endrst
*/
template
<
typename
Char
>
class
BasicW
riter
{
class
basic_w
riter
{
private:
// Output buffer.
Buffer
<
Char
>
&
buffer_
;
FMT_DISALLOW_COPY_AND_ASSIGN
(
BasicW
riter
);
FMT_DISALLOW_COPY_AND_ASSIGN
(
basic_w
riter
);
typedef
typename
internal
::
CharTraits
<
Char
>::
CharPtr
CharPtr
;
...
...
@@ -2349,17 +2349,17 @@ class BasicWriter {
protected:
/**
Constructs a ``
BasicW
riter`` object.
Constructs a ``
basic_w
riter`` object.
*/
explicit
BasicW
riter
(
Buffer
<
Char
>
&
b
)
:
buffer_
(
b
)
{}
explicit
basic_w
riter
(
Buffer
<
Char
>
&
b
)
:
buffer_
(
b
)
{}
public:
/**
\rst
Destroys a ``
BasicW
riter`` object.
Destroys a ``
basic_w
riter`` object.
\endrst
*/
virtual
~
BasicW
riter
()
{}
virtual
~
basic_w
riter
()
{}
/**
Returns the total number of characters written.
...
...
@@ -2424,21 +2424,21 @@ class BasicWriter {
vwrite
(
format
,
make_xformat_args
<
basic_format_context
<
Char
>>
(
args
...));
}
BasicW
riter
&
operator
<<
(
int
value
)
{
basic_w
riter
&
operator
<<
(
int
value
)
{
write_decimal
(
value
);
return
*
this
;
}
BasicW
riter
&
operator
<<
(
unsigned
value
)
{
basic_w
riter
&
operator
<<
(
unsigned
value
)
{
return
*
this
<<
IntFormatSpec
<
unsigned
>
(
value
);
}
BasicW
riter
&
operator
<<
(
long
value
)
{
basic_w
riter
&
operator
<<
(
long
value
)
{
write_decimal
(
value
);
return
*
this
;
}
BasicW
riter
&
operator
<<
(
unsigned
long
value
)
{
basic_w
riter
&
operator
<<
(
unsigned
long
value
)
{
return
*
this
<<
IntFormatSpec
<
unsigned
long
>
(
value
);
}
BasicW
riter
&
operator
<<
(
LongLong
value
)
{
basic_w
riter
&
operator
<<
(
LongLong
value
)
{
write_decimal
(
value
);
return
*
this
;
}
...
...
@@ -2448,11 +2448,11 @@ class BasicWriter {
Formats *value* and writes it to the stream.
\endrst
*/
BasicW
riter
&
operator
<<
(
ULongLong
value
)
{
basic_w
riter
&
operator
<<
(
ULongLong
value
)
{
return
*
this
<<
IntFormatSpec
<
ULongLong
>
(
value
);
}
BasicW
riter
&
operator
<<
(
double
value
)
{
basic_w
riter
&
operator
<<
(
double
value
)
{
write_double
(
value
,
FormatSpec
());
return
*
this
;
}
...
...
@@ -2463,7 +2463,7 @@ class BasicWriter {
(``'g'``) and writes it to the stream.
\endrst
*/
BasicW
riter
&
operator
<<
(
long
double
value
)
{
basic_w
riter
&
operator
<<
(
long
double
value
)
{
write_double
(
value
,
FormatSpec
());
return
*
this
;
}
...
...
@@ -2471,12 +2471,12 @@ class BasicWriter {
/**
Writes a character to the stream.
*/
BasicW
riter
&
operator
<<
(
char
value
)
{
basic_w
riter
&
operator
<<
(
char
value
)
{
buffer_
.
push_back
(
value
);
return
*
this
;
}
BasicW
riter
&
operator
<<
(
basic_w
riter
&
operator
<<
(
typename
internal
::
WCharHelper
<
wchar_t
,
Char
>::
Supported
value
)
{
buffer_
.
push_back
(
value
);
return
*
this
;
...
...
@@ -2487,13 +2487,13 @@ class BasicWriter {
Writes *value* to the stream.
\endrst
*/
BasicW
riter
&
operator
<<
(
fmt
::
BasicStringRef
<
Char
>
value
)
{
basic_w
riter
&
operator
<<
(
fmt
::
BasicStringRef
<
Char
>
value
)
{
const
Char
*
str
=
value
.
data
();
buffer_
.
append
(
str
,
str
+
value
.
size
());
return
*
this
;
}
BasicW
riter
&
operator
<<
(
basic_w
riter
&
operator
<<
(
typename
internal
::
WCharHelper
<
StringRef
,
Char
>::
Supported
value
)
{
const
char
*
str
=
value
.
data
();
buffer_
.
append
(
str
,
str
+
value
.
size
());
...
...
@@ -2501,14 +2501,14 @@ class BasicWriter {
}
template
<
typename
T
,
typename
Spec
,
typename
FillChar
>
BasicW
riter
&
operator
<<
(
IntFormatSpec
<
T
,
Spec
,
FillChar
>
spec
)
{
basic_w
riter
&
operator
<<
(
IntFormatSpec
<
T
,
Spec
,
FillChar
>
spec
)
{
internal
::
CharTraits
<
Char
>::
convert
(
FillChar
());
write_int
(
spec
.
value
(),
spec
);
return
*
this
;
}
template
<
typename
StrChar
>
BasicW
riter
&
operator
<<
(
const
StrFormatSpec
<
StrChar
>
&
spec
)
{
basic_w
riter
&
operator
<<
(
const
StrFormatSpec
<
StrChar
>
&
spec
)
{
const
StrChar
*
s
=
spec
.
str
();
write_str
(
s
,
std
::
char_traits
<
Char
>::
length
(
s
),
spec
);
return
*
this
;
...
...
@@ -2521,7 +2521,7 @@ class BasicWriter {
template
<
typename
Char
>
template
<
typename
StrChar
>
typename
BasicWriter
<
Char
>::
CharPtr
BasicW
riter
<
Char
>::
write_str
(
typename
basic_writer
<
Char
>::
CharPtr
basic_w
riter
<
Char
>::
write_str
(
const
StrChar
*
s
,
std
::
size_t
size
,
const
AlignSpec
&
spec
)
{
CharPtr
out
=
CharPtr
();
if
(
spec
.
width
()
>
size
)
{
...
...
@@ -2544,7 +2544,7 @@ typename BasicWriter<Char>::CharPtr BasicWriter<Char>::write_str(
template
<
typename
Char
>
template
<
typename
StrChar
>
void
BasicW
riter
<
Char
>::
write_str
(
void
basic_w
riter
<
Char
>::
write_str
(
BasicStringRef
<
StrChar
>
s
,
const
FormatSpec
&
spec
)
{
// Check if StrChar is convertible to Char.
internal
::
CharTraits
<
Char
>::
convert
(
StrChar
());
...
...
@@ -2564,8 +2564,7 @@ void BasicWriter<Char>::write_str(
}
template
<
typename
Char
>
typename
BasicWriter
<
Char
>::
CharPtr
BasicWriter
<
Char
>::
fill_padding
(
typename
basic_writer
<
Char
>::
CharPtr
basic_writer
<
Char
>::
fill_padding
(
CharPtr
buffer
,
unsigned
total_size
,
std
::
size_t
content_size
,
wchar_t
fill
)
{
std
::
size_t
padding
=
total_size
-
content_size
;
...
...
@@ -2581,8 +2580,7 @@ typename BasicWriter<Char>::CharPtr
template
<
typename
Char
>
template
<
typename
Spec
>
typename
BasicWriter
<
Char
>::
CharPtr
BasicWriter
<
Char
>::
prepare_int_buffer
(
typename
basic_writer
<
Char
>::
CharPtr
basic_writer
<
Char
>::
prepare_int_buffer
(
unsigned
num_digits
,
const
Spec
&
spec
,
const
char
*
prefix
,
unsigned
prefix_size
)
{
unsigned
width
=
spec
.
width
();
...
...
@@ -2645,7 +2643,7 @@ typename BasicWriter<Char>::CharPtr
template
<
typename
Char
>
template
<
typename
T
,
typename
Spec
>
void
BasicW
riter
<
Char
>::
write_int
(
T
value
,
Spec
spec
)
{
void
basic_w
riter
<
Char
>::
write_int
(
T
value
,
Spec
spec
)
{
unsigned
prefix_size
=
0
;
typedef
typename
internal
::
IntTraits
<
T
>::
MainType
UnsignedType
;
UnsignedType
abs_value
=
static_cast
<
UnsignedType
>
(
value
);
...
...
@@ -2735,7 +2733,7 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
template
<
typename
Char
>
template
<
typename
T
>
void
BasicW
riter
<
Char
>::
write_double
(
T
value
,
const
FormatSpec
&
spec
)
{
void
basic_w
riter
<
Char
>::
write_double
(
T
value
,
const
FormatSpec
&
spec
)
{
// Check type.
char
type
=
spec
.
type
();
bool
upper
=
false
;
...
...
@@ -2923,13 +2921,13 @@ void BasicWriter<Char>::write_double(T value, const FormatSpec &spec) {
\endrst
*/
template
<
typename
Char
,
typename
Allocator
=
std
::
allocator
<
Char
>
>
class
BasicMemoryWriter
:
public
BasicW
riter
<
Char
>
{
class
BasicMemoryWriter
:
public
basic_w
riter
<
Char
>
{
private:
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
,
Allocator
>
buffer_
;
public:
explicit
BasicMemoryWriter
(
const
Allocator
&
alloc
=
Allocator
())
:
BasicW
riter
<
Char
>
(
buffer_
),
buffer_
(
alloc
)
{}
:
basic_w
riter
<
Char
>
(
buffer_
),
buffer_
(
alloc
)
{}
#if FMT_USE_RVALUE_REFERENCES
/**
...
...
@@ -2939,7 +2937,7 @@ class BasicMemoryWriter : public BasicWriter<Char> {
\endrst
*/
BasicMemoryWriter
(
BasicMemoryWriter
&&
other
)
:
BasicW
riter
<
Char
>
(
buffer_
),
buffer_
(
std
::
move
(
other
.
buffer_
))
{
:
basic_w
riter
<
Char
>
(
buffer_
),
buffer_
(
std
::
move
(
other
.
buffer_
))
{
}
/**
...
...
@@ -2978,7 +2976,7 @@ typedef BasicMemoryWriter<wchar_t> WMemoryWriter;
\endrst
*/
template
<
typename
Char
>
class
BasicArrayWriter
:
public
BasicW
riter
<
Char
>
{
class
BasicArrayWriter
:
public
basic_w
riter
<
Char
>
{
private:
internal
::
FixedBuffer
<
Char
>
buffer_
;
...
...
@@ -2990,7 +2988,7 @@ class BasicArrayWriter : public BasicWriter<Char> {
\endrst
*/
BasicArrayWriter
(
Char
*
array
,
std
::
size_t
size
)
:
BasicW
riter
<
Char
>
(
buffer_
),
buffer_
(
array
,
size
)
{}
:
basic_w
riter
<
Char
>
(
buffer_
),
buffer_
(
array
,
size
)
{}
/**
\rst
...
...
@@ -3000,7 +2998,7 @@ class BasicArrayWriter : public BasicWriter<Char> {
*/
template
<
std
::
size_t
SIZE
>
explicit
BasicArrayWriter
(
Char
(
&
array
)[
SIZE
])
:
BasicW
riter
<
Char
>
(
buffer_
),
buffer_
(
array
,
SIZE
)
{}
:
basic_w
riter
<
Char
>
(
buffer_
),
buffer_
(
array
,
SIZE
)
{}
};
typedef
BasicArrayWriter
<
char
>
ArrayWriter
;
...
...
@@ -3349,11 +3347,11 @@ void check_sign(const Char *&s, const basic_format_arg<Context> &arg) {
template
<
typename
Char
,
typename
Context
>
class
CustomFormatter
{
private:
BasicW
riter
<
Char
>
&
writer_
;
basic_w
riter
<
Char
>
&
writer_
;
Context
&
ctx_
;
public:
CustomFormatter
(
BasicW
riter
<
Char
>
&
writer
,
Context
&
ctx
)
CustomFormatter
(
basic_w
riter
<
Char
>
&
writer
,
Context
&
ctx
)
:
writer_
(
writer
),
ctx_
(
ctx
)
{}
bool
operator
()(
internal
::
CustomValue
<
Char
>
custom
)
{
...
...
@@ -3450,7 +3448,7 @@ inline typename basic_format_context<Char>::format_arg
// Formats a single argument.
template
<
typename
ArgFormatter
,
typename
Char
,
typename
Context
>
void
do_format_arg
(
BasicW
riter
<
Char
>
&
writer
,
basic_format_arg
<
Context
>
arg
,
void
do_format_arg
(
basic_w
riter
<
Char
>
&
writer
,
basic_format_arg
<
Context
>
arg
,
Context
&
ctx
)
{
const
Char
*&
s
=
ctx
.
ptr
();
FormatSpec
spec
;
...
...
@@ -3576,7 +3574,7 @@ void do_format_arg(BasicWriter<Char> &writer, basic_format_arg<Context> arg,
/** Formats arguments and writes the output to the writer. */
template
<
typename
ArgFormatter
,
typename
Char
,
typename
Context
>
void
vformat
(
BasicW
riter
<
Char
>
&
writer
,
BasicCStringRef
<
Char
>
format_str
,
void
vformat
(
basic_w
riter
<
Char
>
&
writer
,
BasicCStringRef
<
Char
>
format_str
,
basic_format_args
<
Context
>
args
)
{
basic_format_context
<
Char
>
ctx
(
format_str
.
c_str
(),
args
);
const
Char
*&
s
=
ctx
.
ptr
();
...
...
@@ -3601,7 +3599,7 @@ void vformat(BasicWriter<Char> &writer, BasicCStringRef<Char> format_str,
}
template
<
typename
Char
>
inline
void
BasicW
riter
<
Char
>::
vwrite
(
inline
void
basic_w
riter
<
Char
>::
vwrite
(
BasicCStringRef
<
Char
>
format
,
basic_format_args
<
basic_format_context
<
Char
>>
args
)
{
vformat
<
ArgFormatter
<
Char
>>
(
*
this
,
format
,
args
);
...
...
fmt/ostream.cc
View file @
8428621d
...
...
@@ -12,7 +12,7 @@
namespace
fmt
{
namespace
internal
{
FMT_FUNC
void
write
(
std
::
ostream
&
os
,
W
riter
&
w
)
{
FMT_FUNC
void
write
(
std
::
ostream
&
os
,
w
riter
&
w
)
{
const
char
*
data
=
w
.
data
();
typedef
internal
::
MakeUnsigned
<
std
::
streamsize
>::
Type
UnsignedStreamSize
;
UnsignedStreamSize
size
=
w
.
size
();
...
...
fmt/ostream.h
View file @
8428621d
...
...
@@ -68,7 +68,7 @@ struct ConvertToIntImpl<T, true> {
};
// Write the content of w to os.
void
write
(
std
::
ostream
&
os
,
W
riter
&
w
);
void
write
(
std
::
ostream
&
os
,
w
riter
&
w
);
template
<
typename
Char
,
typename
T
>
BasicStringRef
<
Char
>
format_value
(
...
...
@@ -83,7 +83,7 @@ BasicStringRef<Char> format_value(
// Formats a value.
template
<
typename
Char
,
typename
T
>
void
format_value
(
BasicW
riter
<
Char
>
&
w
,
const
T
&
value
,
void
format_value
(
basic_w
riter
<
Char
>
&
w
,
const
T
&
value
,
basic_format_context
<
Char
>
&
ctx
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
auto
str
=
internal
::
format_value
(
buffer
,
value
);
...
...
fmt/printf.h
View file @
8428621d
...
...
@@ -224,7 +224,7 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
specifier information for standard argument types.
\endrst
*/
PrintfArgFormatter
(
BasicW
riter
<
Char
>
&
writer
,
FormatSpec
&
spec
)
PrintfArgFormatter
(
basic_w
riter
<
Char
>
&
writer
,
FormatSpec
&
spec
)
:
internal
::
ArgFormatterBase
<
Char
>
(
writer
,
spec
)
{}
using
Base
::
operator
();
...
...
@@ -241,10 +241,10 @@ class PrintfArgFormatter : public internal::ArgFormatterBase<Char> {
/** Formats a character. */
void
operator
()(
Char
value
)
{
const
FormatSpec
&
fmt_spec
=
this
->
spec
();
BasicW
riter
<
Char
>
&
w
=
this
->
writer
();
basic_w
riter
<
Char
>
&
w
=
this
->
writer
();
if
(
fmt_spec
.
type_
&&
fmt_spec
.
type_
!=
'c'
)
w
.
write_int
(
value
,
fmt_spec
);
typedef
typename
BasicW
riter
<
Char
>::
CharPtr
CharPtr
;
typedef
typename
basic_w
riter
<
Char
>::
CharPtr
CharPtr
;
CharPtr
out
=
CharPtr
();
if
(
fmt_spec
.
width_
>
1
)
{
Char
fill
=
' '
;
...
...
@@ -326,7 +326,7 @@ class printf_context :
:
Base
(
format_str
.
c_str
(),
args
)
{}
/** Formats stored arguments and writes the output to the writer. */
FMT_API
void
format
(
BasicW
riter
<
Char
>
&
writer
);
FMT_API
void
format
(
basic_w
riter
<
Char
>
&
writer
);
};
template
<
typename
Char
,
typename
AF
>
...
...
@@ -402,7 +402,7 @@ unsigned printf_context<Char, AF>::parse_header(
}
template
<
typename
Char
,
typename
AF
>
void
printf_context
<
Char
,
AF
>::
format
(
BasicW
riter
<
Char
>
&
writer
)
{
void
printf_context
<
Char
,
AF
>::
format
(
basic_w
riter
<
Char
>
&
writer
)
{
const
Char
*
start
=
this
->
ptr
();
const
Char
*
s
=
start
;
while
(
*
s
)
{
...
...
@@ -502,14 +502,14 @@ void printf_context<Char, AF>::format(BasicWriter<Char> &writer) {
// Formats a value.
template
<
typename
Char
,
typename
T
>
void
format_value
(
BasicW
riter
<
Char
>
&
w
,
const
T
&
value
,
void
format_value
(
basic_w
riter
<
Char
>
&
w
,
const
T
&
value
,
printf_context
<
Char
>&
ctx
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
w
<<
internal
::
format_value
(
buffer
,
value
);
}
template
<
typename
Char
>
void
printf
(
BasicW
riter
<
Char
>
&
w
,
BasicCStringRef
<
Char
>
format
,
void
printf
(
basic_w
riter
<
Char
>
&
w
,
BasicCStringRef
<
Char
>
format
,
basic_format_args
<
printf_context
<
Char
>>
args
)
{
printf_context
<
Char
>
(
format
,
args
).
format
(
w
);
}
...
...
fmt/string.h
View file @
8428621d
...
...
@@ -72,7 +72,7 @@ class StringBuffer : public Buffer<Char> {
\endrst
*/
template
<
typename
Char
>
class
BasicStringWriter
:
public
BasicW
riter
<
Char
>
{
class
BasicStringWriter
:
public
basic_w
riter
<
Char
>
{
private:
internal
::
StringBuffer
<
Char
>
buffer_
;
...
...
@@ -82,7 +82,7 @@ class BasicStringWriter : public BasicWriter<Char> {
Constructs a :class:`fmt::BasicStringWriter` object.
\endrst
*/
BasicStringWriter
()
:
BasicW
riter
<
Char
>
(
buffer_
)
{}
BasicStringWriter
()
:
basic_w
riter
<
Char
>
(
buffer_
)
{}
/**
\rst
...
...
fmt/time.h
View file @
8428621d
...
...
@@ -15,7 +15,7 @@
namespace
fmt
{
void
format_value
(
W
riter
&
w
,
const
std
::
tm
&
tm
,
format_context
&
ctx
)
{
void
format_value
(
w
riter
&
w
,
const
std
::
tm
&
tm
,
format_context
&
ctx
)
{
const
char
*&
s
=
ctx
.
ptr
();
if
(
*
s
==
':'
)
++
s
;
...
...
test/custom-formatter-test.cc
View file @
8428621d
...
...
@@ -16,7 +16,7 @@ using fmt::PrintfArgFormatter;
// rounded to 0.
class
CustomArgFormatter
:
public
fmt
::
ArgFormatter
<
char
>
{
public:
CustomArgFormatter
(
fmt
::
W
riter
&
w
,
fmt
::
basic_format_context
<
char
>
&
ctx
,
CustomArgFormatter
(
fmt
::
w
riter
&
w
,
fmt
::
basic_format_context
<
char
>
&
ctx
,
fmt
::
FormatSpec
&
s
)
:
fmt
::
ArgFormatter
<
char
>
(
w
,
ctx
,
s
)
{}
...
...
@@ -33,7 +33,7 @@ class CustomArgFormatter : public fmt::ArgFormatter<char> {
// rounded to 0.
class
CustomPrintfArgFormatter
:
public
PrintfArgFormatter
<
char
>
{
public:
CustomPrintfArgFormatter
(
fmt
::
BasicW
riter
<
char
>
&
w
,
fmt
::
FormatSpec
&
spec
)
CustomPrintfArgFormatter
(
fmt
::
basic_w
riter
<
char
>
&
w
,
fmt
::
FormatSpec
&
spec
)
:
PrintfArgFormatter
<
char
>
(
w
,
spec
)
{}
using
PrintfArgFormatter
<
char
>::
operator
();
...
...
test/format-test.cc
View file @
8428621d
...
...
@@ -70,7 +70,7 @@ lconv *localeconv() {
using
std
::
size_t
;
using
fmt
::
BasicW
riter
;
using
fmt
::
basic_w
riter
;
using
fmt
::
format
;
using
fmt
::
format_error
;
using
fmt
::
StringRef
;
...
...
@@ -165,11 +165,11 @@ TEST(CStringRefTest, Ctor) {
#if FMT_USE_TYPE_TRAITS
TEST
(
WriterTest
,
NotCopyConstructible
)
{
EXPECT_FALSE
(
std
::
is_copy_constructible
<
BasicW
riter
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_copy_constructible
<
basic_w
riter
<
char
>
>::
value
);
}
TEST
(
WriterTest
,
NotCopyAssignable
)
{
EXPECT_FALSE
(
std
::
is_copy_assignable
<
BasicW
riter
<
char
>
>::
value
);
EXPECT_FALSE
(
std
::
is_copy_assignable
<
basic_w
riter
<
char
>
>::
value
);
}
#endif
...
...
@@ -399,7 +399,7 @@ TEST(WriterTest, hexu) {
}
template
<
typename
Char
>
BasicWriter
<
Char
>
&
operator
<<
(
BasicW
riter
<
Char
>
&
f
,
const
Date
&
d
)
{
basic_writer
<
Char
>
&
operator
<<
(
basic_w
riter
<
Char
>
&
f
,
const
Date
&
d
)
{
return
f
<<
d
.
year
()
<<
'-'
<<
d
.
month
()
<<
'-'
<<
d
.
day
();
}
...
...
@@ -410,8 +410,8 @@ public:
ISO8601DateFormatter
(
const
Date
&
d
)
:
date_
(
&
d
)
{}
template
<
typename
Char
>
friend
BasicW
riter
<
Char
>
&
operator
<<
(
BasicW
riter
<
Char
>
&
w
,
const
ISO8601DateFormatter
&
d
)
{
friend
basic_w
riter
<
Char
>
&
operator
<<
(
basic_w
riter
<
Char
>
&
w
,
const
ISO8601DateFormatter
&
d
)
{
return
w
<<
pad
(
d
.
date_
->
year
(),
4
,
'0'
)
<<
'-'
<<
pad
(
d
.
date_
->
month
(),
2
,
'0'
)
<<
'-'
<<
pad
(
d
.
date_
->
day
(),
2
,
'0'
);
}
...
...
@@ -1355,7 +1355,7 @@ TEST(FormatterTest, FormatCStringRef) {
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
CStringRef
(
"test"
)));
}
void
format_value
(
fmt
::
W
riter
&
w
,
const
Date
&
d
,
fmt
::
format_context
&
)
{
void
format_value
(
fmt
::
w
riter
&
w
,
const
Date
&
d
,
fmt
::
format_context
&
)
{
w
<<
d
.
year
()
<<
'-'
<<
d
.
month
()
<<
'-'
<<
d
.
day
();
}
...
...
@@ -1368,7 +1368,7 @@ TEST(FormatterTest, FormatCustom) {
class
Answer
{};
template
<
typename
Char
>
void
format_value
(
BasicW
riter
<
Char
>
&
w
,
Answer
,
fmt
::
format_context
&
)
{
void
format_value
(
basic_w
riter
<
Char
>
&
w
,
Answer
,
fmt
::
format_context
&
)
{
w
<<
"42"
;
}
...
...
@@ -1627,7 +1627,7 @@ class MockArgFormatter : public fmt::internal::ArgFormatterBase<char> {
public:
typedef
fmt
::
internal
::
ArgFormatterBase
<
char
>
Base
;
MockArgFormatter
(
fmt
::
W
riter
&
w
,
fmt
::
format_context
&
ctx
,
MockArgFormatter
(
fmt
::
w
riter
&
w
,
fmt
::
format_context
&
ctx
,
fmt
::
FormatSpec
&
s
)
:
fmt
::
internal
::
ArgFormatterBase
<
char
>
(
w
,
s
)
{
EXPECT_CALL
(
*
this
,
call
(
42
));
...
...
test/ostream-test.cc
View file @
8428621d
...
...
@@ -59,7 +59,7 @@ TEST(OStreamTest, Enum) {
}
struct
TestArgFormatter
:
fmt
::
ArgFormatter
<
char
>
{
TestArgFormatter
(
fmt
::
W
riter
&
w
,
fmt
::
format_context
&
ctx
,
TestArgFormatter
(
fmt
::
w
riter
&
w
,
fmt
::
format_context
&
ctx
,
fmt
::
FormatSpec
&
s
)
:
fmt
::
ArgFormatter
<
char
>
(
w
,
ctx
,
s
)
{}
};
...
...
@@ -134,7 +134,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
if
(
max_size
<=
fmt
::
internal
::
to_unsigned
(
max_streamsize
))
return
;
class
TestWriter
:
public
fmt
::
BasicW
riter
<
char
>
{
class
TestWriter
:
public
fmt
::
basic_w
riter
<
char
>
{
private:
struct
TestBuffer
:
fmt
::
Buffer
<
char
>
{
explicit
TestBuffer
(
std
::
size_t
size
)
{
size_
=
size
;
}
...
...
@@ -142,7 +142,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
}
buffer_
;
public:
explicit
TestWriter
(
std
::
size_t
size
)
:
fmt
::
BasicW
riter
<
char
>
(
buffer_
),
buffer_
(
size
)
{}
:
fmt
::
basic_w
riter
<
char
>
(
buffer_
),
buffer_
(
size
)
{}
}
w
(
max_size
);
struct
MockStreamBuf
:
std
::
streambuf
{
...
...
test/util-test.cc
View file @
8428621d
...
...
@@ -68,7 +68,7 @@ namespace {
struct
Test
{};
template
<
typename
Char
>
void
format_value
(
fmt
::
BasicW
riter
<
Char
>
&
w
,
Test
,
void
format_value
(
fmt
::
basic_w
riter
<
Char
>
&
w
,
Test
,
fmt
::
basic_format_context
<
Char
>
&
)
{
w
<<
"test"
;
}
...
...
@@ -417,7 +417,7 @@ struct CustomContext {
bool
called
;
};
void
format_value
(
fmt
::
W
riter
&
,
const
Test
&
,
CustomContext
&
ctx
)
{
void
format_value
(
fmt
::
w
riter
&
,
const
Test
&
,
CustomContext
&
ctx
)
{
ctx
.
called
=
true
;
}
...
...
@@ -690,7 +690,7 @@ TEST(UtilTest, UTF16ToUTF8Convert) {
#endif // _WIN32
typedef
void
(
*
FormatErrorMessage
)(
fmt
::
W
riter
&
out
,
int
error_code
,
StringRef
message
);
fmt
::
w
riter
&
out
,
int
error_code
,
StringRef
message
);
template
<
typename
Error
>
void
check_throw_error
(
int
error_code
,
FormatErrorMessage
format
)
{
...
...
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