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
342b76d2
Commit
342b76d2
authored
Jan 01, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement pad for wide strings.
parent
136ee89b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
format.h
format.h
+13
-7
format_test.cc
format_test.cc
+7
-0
No files found.
format.h
View file @
342b76d2
...
...
@@ -504,9 +504,15 @@ DEFINE_INT_FORMATTERS(unsigned long long)
\endrst
*/
inline
StrFormatSpec
<
char
>
pad
(
const
char
*
str
,
unsigned
width
,
wchar_t
fill
=
' '
)
{
return
StrFormatSpec
<
char
>
(
str
,
AlignSpec
(
width
,
fill
));
template
<
typename
Char
>
inline
StrFormatSpec
<
Char
>
pad
(
const
Char
*
str
,
unsigned
width
,
Char
fill
=
' '
)
{
return
StrFormatSpec
<
Char
>
(
str
,
AlignSpec
(
width
,
fill
));
}
inline
StrFormatSpec
<
wchar_t
>
pad
(
const
wchar_t
*
str
,
unsigned
width
,
char
fill
=
' '
)
{
return
StrFormatSpec
<
wchar_t
>
(
str
,
AlignSpec
(
width
,
fill
));
}
template
<
typename
Char
>
...
...
@@ -712,10 +718,10 @@ class BasicWriter {
template
<
typename
T
,
typename
Spec
>
BasicWriter
&
operator
<<
(
const
IntFormatSpec
<
T
,
Spec
>
&
spec
);
template
<
typename
T
>
BasicWriter
&
operator
<<
(
const
StrFormatSpec
<
T
>
&
spec
)
{
const
c
har
*
s
=
spec
.
str
();
FormatString
(
s
,
std
::
strlen
(
s
),
spec
);
template
<
typename
StringChar
>
BasicWriter
&
operator
<<
(
const
StrFormatSpec
<
StringChar
>
&
spec
)
{
const
StringC
har
*
s
=
spec
.
str
();
FormatString
(
s
,
std
::
char_traits
<
Char
>::
length
(
s
),
spec
);
return
*
this
;
}
...
...
format_test.cc
View file @
342b76d2
...
...
@@ -56,6 +56,7 @@ using fmt::Format;
using
fmt
::
FormatError
;
using
fmt
::
StringRef
;
using
fmt
::
Writer
;
using
fmt
::
WWriter
;
using
fmt
::
pad
;
#define FORMAT_TEST_THROW_(statement, expected_exception, message, fail) \
...
...
@@ -447,6 +448,12 @@ TEST(WriterTest, PadString) {
EXPECT_EQ
(
"test******"
,
str
(
Writer
()
<<
pad
(
"test"
,
10
,
'*'
)));
}
TEST
(
WriterTest
,
PadWString
)
{
EXPECT_EQ
(
L"test "
,
str
(
WWriter
()
<<
pad
(
L"test"
,
8
)));
EXPECT_EQ
(
L"test******"
,
str
(
WWriter
()
<<
pad
(
L"test"
,
10
,
'*'
)));
EXPECT_EQ
(
L"test******"
,
str
(
WWriter
()
<<
pad
(
L"test"
,
10
,
L'*'
)));
}
TEST
(
WriterTest
,
NoConflictWithIOManip
)
{
using
namespace
std
;
using
namespace
fmt
;
...
...
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