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
e0f6a2f8
Commit
e0f6a2f8
authored
Jul 14, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a formatter for folly::StringPiece
parent
ae4a3945
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
2 deletions
+56
-2
CMakeLists.txt
CMakeLists.txt
+2
-2
include/fmt/folly.h
include/fmt/folly.h
+22
-0
test/CMakeLists.txt
test/CMakeLists.txt
+1
-0
test/folly-test.cc
test/folly-test.cc
+14
-0
test/folly/Range.h
test/folly/Range.h
+17
-0
No files found.
CMakeLists.txt
View file @
e0f6a2f8
...
...
@@ -148,8 +148,8 @@ function(add_headers VAR)
endfunction
()
# Define the fmt library, its includes and the needed defines.
add_headers
(
FMT_HEADERS core.h fo
rmat.h format-inl.h ostream.h printf.h time
.h
ranges.h
)
add_headers
(
FMT_HEADERS core.h fo
lly.h format.h format-inl.h ostream.h printf
.h
time.h
ranges.h
)
set
(
FMT_SOURCES src/format.cc
)
if
(
HAVE_OPEN
)
add_headers
(
FMT_HEADERS posix.h
)
...
...
include/fmt/folly.h
0 → 100644
View file @
e0f6a2f8
// Formatting library for C++ - folly::StringPiece formatter
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_FOLLY_H_
#define FMT_FOLLY_H_
#include <folly/Range.h>
#include "core.h"
FMT_BEGIN_NAMESPACE
template
<
typename
Ctx
>
inline
internal
::
typed_value
<
Ctx
,
internal
::
string_type
>
make_value
(
folly
::
StringPiece
s
)
{
return
string_view
(
s
.
data
(),
s
.
size
());
}
FMT_END_NAMESPACE
#endif // FMT_FOLLY_H_
test/CMakeLists.txt
View file @
e0f6a2f8
...
...
@@ -86,6 +86,7 @@ endfunction()
add_fmt_test
(
assert-test
)
add_fmt_test
(
gtest-extra-test
)
add_fmt_test
(
folly-test
)
add_fmt_test
(
format-test
)
add_fmt_test
(
format-impl-test
)
add_fmt_test
(
ostream-test
)
...
...
test/folly-test.cc
0 → 100644
View file @
e0f6a2f8
// Formatting library for C++ - folly::StringPiece formatter tests
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#include <fmt/folly.h>
#include "gtest.h"
TEST
(
FollyTest
,
FormatStringPiece
)
{
EXPECT_EQ
(
fmt
::
format
(
"{}"
,
"foo"
),
"foo"
);
EXPECT_EQ
(
fmt
::
format
(
"{:>5}"
,
"foo"
),
" foo"
);
}
test/folly/Range.h
0 → 100644
View file @
e0f6a2f8
// A folly::StringPiece stub.
#include <cstring>
namespace
folly
{
class
StringPiece
{
public:
explicit
StringPiece
(
const
char
*
s
)
:
data_
(
s
),
size_
(
std
::
strlen
(
s
))
{}
const
char
*
data
()
const
{
return
"foo"
;
}
size_t
size
()
const
{
return
3
;
}
private:
const
char
*
data_
;
size_t
size_
;
};
}
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