Skip to content

Commit 420b876

Browse files
authored
fix Firestore C++ g3 build (#1923)
* fix g3 build resolve conflict w.r.t. string and isnan(). * fix lint
1 parent 467354a commit 420b876

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

Firestore/core/src/firebase/firestore/model/field_path.cc

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ bool IsValidIdentifier(const std::string& segment) {
5959
return true;
6060
}
6161

62+
/** A custom formatter to be used with absl::StrJoin(). */
63+
struct JoinEscaped {
64+
static std::string escaped_segment(const std::string& segment) {
65+
auto escaped = absl::StrReplaceAll(segment, {{"\\", "\\\\"}, {"`", "\\`"}});
66+
const bool needs_escaping = !IsValidIdentifier(escaped);
67+
if (needs_escaping) {
68+
escaped.insert(escaped.begin(), '`');
69+
escaped.push_back('`');
70+
}
71+
return escaped;
72+
}
73+
74+
template <typename T>
75+
void operator()(T* out, const std::string& segment) {
76+
out->append(escaped_segment(segment));
77+
}
78+
};
6279
} // namespace
6380

6481
FieldPath FieldPath::FromServerFormat(const absl::string_view path) {
@@ -143,20 +160,7 @@ bool FieldPath::IsKeyFieldPath() const {
143160
}
144161

145162
std::string FieldPath::CanonicalString() const {
146-
const auto escaped_segment = [](const std::string& segment) {
147-
auto escaped = absl::StrReplaceAll(segment, {{"\\", "\\\\"}, {"`", "\\`"}});
148-
const bool needs_escaping = !IsValidIdentifier(escaped);
149-
if (needs_escaping) {
150-
escaped.insert(escaped.begin(), '`');
151-
escaped.push_back('`');
152-
}
153-
return escaped;
154-
};
155-
return absl::StrJoin(
156-
begin(), end(), ".",
157-
[escaped_segment](std::string* out, const std::string& segment) {
158-
out->append(escaped_segment(segment));
159-
});
163+
return absl::StrJoin(begin(), end(), ".", JoinEscaped());
160164
}
161165

162166
} // namespace model

Firestore/core/src/firebase/firestore/util/comparison.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
#include <cmath>
2020
#include <limits>
2121

22-
using std::isnan;
23-
2422
namespace firebase {
2523
namespace firestore {
2624
namespace util {
25+
using std::isnan;
2726

2827
bool Comparator<absl::string_view>::operator()(absl::string_view left,
2928
absl::string_view right) const {

0 commit comments

Comments
 (0)