Skip to content

Commit 1f00fb1

Browse files
committed
string_format.h: format code
1 parent 7d9f957 commit 1f00fb1

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

Firestore/core/src/util/string_format.h

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ struct FormatChoice<5> {};
6565
class FormatArg : public absl::AlphaNum {
6666
public:
6767
template <typename T>
68-
FormatArg(T&& value, absl::strings_internal::StringifySink&& sink = {}) // NOLINT(runtime/explicit)
69-
: FormatArg{std::forward<T>(value), std::move(sink), internal::FormatChoice<0>{}} {
68+
FormatArg(T&& value,
69+
absl::strings_internal::StringifySink&& sink =
70+
{}) // NOLINT(runtime/explicit)
71+
: FormatArg{std::forward<T>(value), std::move(sink),
72+
internal::FormatChoice<0>{}} {
7073
}
7174

7275
private:
@@ -79,7 +82,9 @@ class FormatArg : public absl::AlphaNum {
7982
*/
8083
template <typename T,
8184
typename = typename std::enable_if<std::is_same<bool, T>{}>::type>
82-
FormatArg(T bool_value, absl::strings_internal::StringifySink&&, internal::FormatChoice<0>)
85+
FormatArg(T bool_value,
86+
absl::strings_internal::StringifySink&&,
87+
internal::FormatChoice<0>)
8388
: AlphaNum(bool_value ? "true" : "false") {
8489
}
8590

@@ -90,15 +95,19 @@ class FormatArg : public absl::AlphaNum {
9095
template <
9196
typename T,
9297
typename = typename std::enable_if<objc::is_objc_pointer<T>{}>::type>
93-
FormatArg(T object, absl::strings_internal::StringifySink&&, internal::FormatChoice<1>)
98+
FormatArg(T object,
99+
absl::strings_internal::StringifySink&&,
100+
internal::FormatChoice<1>)
94101
: AlphaNum(MakeStringView([object description])) {
95102
}
96103

97104
/**
98105
* Creates a FormatArg from any Objective-C Class type. Objective-C Class
99106
* types are a special struct that aren't of a type derived from NSObject.
100107
*/
101-
FormatArg(Class object, absl::strings_internal::StringifySink&&, internal::FormatChoice<1>)
108+
FormatArg(Class object,
109+
absl::strings_internal::StringifySink&&,
110+
internal::FormatChoice<1>)
102111
: AlphaNum(MakeStringView(NSStringFromClass(object))) {
103112
}
104113
#endif
@@ -108,15 +117,20 @@ class FormatArg : public absl::AlphaNum {
108117
* handled specially to avoid ambiguity with generic pointers, which are
109118
* handled differently.
110119
*/
111-
FormatArg(std::nullptr_t, absl::strings_internal::StringifySink&&, internal::FormatChoice<2>) : AlphaNum("null") {
120+
FormatArg(std::nullptr_t,
121+
absl::strings_internal::StringifySink&&,
122+
internal::FormatChoice<2>)
123+
: AlphaNum("null") {
112124
}
113125

114126
/**
115127
* Creates a FormatArg from a character string literal. This is
116128
* handled specially to avoid ambiguity with generic pointers, which are
117129
* handled differently.
118130
*/
119-
FormatArg(const char* string_value, absl::strings_internal::StringifySink&&, internal::FormatChoice<3>)
131+
FormatArg(const char* string_value,
132+
absl::strings_internal::StringifySink&&,
133+
internal::FormatChoice<3>)
120134
: AlphaNum(string_value == nullptr ? "null" : string_value) {
121135
}
122136

@@ -125,16 +139,21 @@ class FormatArg : public absl::AlphaNum {
125139
* hexadecimal integer literal.
126140
*/
127141
template <typename T>
128-
FormatArg(T* pointer_value, absl::strings_internal::StringifySink&& sink, internal::FormatChoice<4>)
129-
: AlphaNum(absl::Hex(reinterpret_cast<uintptr_t>(pointer_value)), std::move(sink)) {
142+
FormatArg(T* pointer_value,
143+
absl::strings_internal::StringifySink&& sink,
144+
internal::FormatChoice<4>)
145+
: AlphaNum(absl::Hex(reinterpret_cast<uintptr_t>(pointer_value)),
146+
std::move(sink)) {
130147
}
131148

132149
/**
133150
* As a final fallback, creates a FormatArg from any type of value that
134151
* absl::AlphaNum accepts.
135152
*/
136153
template <typename T>
137-
FormatArg(T&& value, absl::strings_internal::StringifySink&&, internal::FormatChoice<5>)
154+
FormatArg(T&& value,
155+
absl::strings_internal::StringifySink&&,
156+
internal::FormatChoice<5>)
138157
: AlphaNum(std::forward<T>(value)) {
139158
}
140159
};
@@ -157,7 +176,8 @@ class FormatArg : public absl::AlphaNum {
157176
*/
158177
template <typename... FA>
159178
std::string StringFormat(const char* format, const FA&... args) {
160-
return internal::StringFormatPieces(format, {static_cast<const FormatArg&>(args).Piece()...});
179+
return internal::StringFormatPieces(
180+
format, {static_cast<const FormatArg&>(args).Piece()...});
161181
}
162182

163183
inline std::string StringFormat() {

0 commit comments

Comments
 (0)