Skip to content

Commit 7fdf7c0

Browse files
authored
Add missing doc comments to Timestamp and GeoPoint to appease linter (#3474)
1 parent a55467a commit 7fdf7c0

File tree

3 files changed

+63
-19
lines changed

3 files changed

+63
-19
lines changed

Firestore/core/include/firebase/firestore/geo_point.h

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,35 @@ namespace firestore {
3232
*/
3333
class GeoPoint {
3434
public:
35-
/**
36-
* Creates a `GeoPoint` with both latitude and longitude being 0.
37-
*/
38-
GeoPoint();
35+
/** Creates a `GeoPoint` with both latitude and longitude set to 0. */
36+
GeoPoint() = default;
3937

4038
/**
41-
* Creates a `GeoPoint` from the provided latitude and longitude degrees.
39+
* Creates a `GeoPoint` from the provided latitude and longitude values.
4240
*
43-
* @param latitude The latitude as number between -90 and 90.
44-
* @param longitude The longitude as number between -180 and 180.
41+
* @param latitude The latitude as number of degrees between -90 and 90.
42+
* @param longitude The longitude as number of degrees between -180 and 180.
4543
*/
4644
GeoPoint(double latitude, double longitude);
4745

46+
/** Copy constructor, `GeoPoint` is trivially copyable. */
4847
GeoPoint(const GeoPoint& other) = default;
48+
49+
/** Move constructor, equivalent to copying. */
4950
GeoPoint(GeoPoint&& other) = default;
51+
52+
/** Copy assignment operator, `GeoPoint` is trivially copyable. */
5053
GeoPoint& operator=(const GeoPoint& other) = default;
54+
55+
/** Move assignment operator, equivalent to copying. */
5156
GeoPoint& operator=(GeoPoint&& other) = default;
5257

58+
/** Returns the latitude value of this `GeoPoint`. */
5359
double latitude() const {
5460
return latitude_;
5561
}
5662

63+
/** Returns the latitude value of this `GeoPoint`. */
5764
double longitude() const {
5865
return longitude_;
5966
}
@@ -62,36 +69,47 @@ class GeoPoint {
6269
* Returns a string representation of this `GeoPoint` for logging/debugging
6370
* purposes.
6471
*
65-
* Note: the exact string representation is unspecified and subject to change;
66-
* don't rely on the format of the string.
72+
* @note: the exact string representation is unspecified and subject to
73+
* change; don't rely on the format of the string.
6774
*/
6875
std::string ToString() const;
76+
77+
/**
78+
* Outputs the string representation of this `GeoPoint` to the given stream.
79+
*
80+
* @see `ToString()` for comments on the representation format.
81+
*/
6982
friend std::ostream& operator<<(std::ostream& out, const GeoPoint& geo_point);
7083

7184
private:
72-
double latitude_;
73-
double longitude_;
85+
double latitude_ = 0.0;
86+
double longitude_ = 0.0;
7487
};
7588

76-
/** Compares against another GeoPoint. */
89+
/** Checks whether `lhs` and `rhs` are in ascending order. */
7790
bool operator<(const GeoPoint& lhs, const GeoPoint& rhs);
7891

92+
/** Checks whether `lhs` and `rhs` are in descending order. */
7993
inline bool operator>(const GeoPoint& lhs, const GeoPoint& rhs) {
8094
return rhs < lhs;
8195
}
8296

97+
/** Checks whether `lhs` and `rhs` are in non-ascending order. */
8398
inline bool operator>=(const GeoPoint& lhs, const GeoPoint& rhs) {
8499
return !(lhs < rhs);
85100
}
86101

102+
/** Checks whether `lhs` and `rhs` are in non-descending order. */
87103
inline bool operator<=(const GeoPoint& lhs, const GeoPoint& rhs) {
88104
return !(lhs > rhs);
89105
}
90106

107+
/** Checks `lhs` and `rhs` for inequality. */
91108
inline bool operator!=(const GeoPoint& lhs, const GeoPoint& rhs) {
92109
return lhs < rhs || lhs > rhs;
93110
}
94111

112+
/** Checks `lhs` and `rhs` for equality. */
95113
inline bool operator==(const GeoPoint& lhs, const GeoPoint& rhs) {
96114
return !(lhs != rhs);
97115
}

Firestore/core/include/firebase/firestore/timestamp.h

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ class Timestamp {
6363
*/
6464
Timestamp(int64_t seconds, int32_t nanoseconds);
6565

66+
/** Copy constructor, `Timestamp` is trivially copyable. */
67+
Timestamp(const Timestamp& other) = default;
68+
69+
/** Move constructor, equivalent to copying. */
70+
Timestamp(Timestamp&& other) = default;
71+
72+
/** Copy assignment operator, `Timestamp` is trivially copyable. */
73+
Timestamp& operator=(const Timestamp& other) = default;
74+
75+
/** Move assignment operator, equivalent to copying. */
76+
Timestamp& operator=(Timestamp&& other) = default;
77+
6678
/**
6779
* Creates a new timestamp with the current date.
6880
*
@@ -145,10 +157,16 @@ class Timestamp {
145157
* Returns a string representation of this `Timestamp` for logging/debugging
146158
* purposes.
147159
*
148-
* Note: the exact string representation is unspecified and subject to change;
149-
* don't rely on the format of the string.
160+
* @note: the exact string representation is unspecified and subject to
161+
* change; don't rely on the format of the string.
150162
*/
151163
std::string ToString() const;
164+
165+
/**
166+
* Outputs the string representation of this `Timestamp` to the given stream.
167+
*
168+
* @see `ToString()` for comments on the representation format.
169+
*/
152170
friend std::ostream& operator<<(std::ostream& out,
153171
const Timestamp& timestamp);
154172

@@ -161,28 +179,34 @@ class Timestamp {
161179
int32_t nanoseconds_ = 0;
162180
};
163181

182+
/** Checks whether `lhs` and `rhs` are in ascending order. */
164183
inline bool operator<(const Timestamp& lhs, const Timestamp& rhs) {
165184
return lhs.seconds() < rhs.seconds() ||
166185
(lhs.seconds() == rhs.seconds() &&
167186
lhs.nanoseconds() < rhs.nanoseconds());
168187
}
169188

189+
/** Checks whether `lhs` and `rhs` are in descending order. */
170190
inline bool operator>(const Timestamp& lhs, const Timestamp& rhs) {
171191
return rhs < lhs;
172192
}
173193

194+
/** Checks whether `lhs` and `rhs` are in non-ascending order. */
174195
inline bool operator>=(const Timestamp& lhs, const Timestamp& rhs) {
175196
return !(lhs < rhs);
176197
}
177198

199+
/** Checks whether `lhs` and `rhs` are in non-descending order. */
178200
inline bool operator<=(const Timestamp& lhs, const Timestamp& rhs) {
179201
return !(lhs > rhs);
180202
}
181203

204+
/** Checks `lhs` and `rhs` for inequality. */
182205
inline bool operator!=(const Timestamp& lhs, const Timestamp& rhs) {
183206
return lhs < rhs || lhs > rhs;
184207
}
185208

209+
/** Checks `lhs` and `rhs` for equality. */
186210
inline bool operator==(const Timestamp& lhs, const Timestamp& rhs) {
187211
return !(lhs != rhs);
188212
}
@@ -213,10 +237,15 @@ std::chrono::time_point<Clock, Duration> Timestamp::ToTimePoint() const {
213237
} // namespace firebase
214238

215239
namespace std {
240+
/** Convenience-only specialization of `std::hash`. */
216241
template <>
217242
struct hash<firebase::Timestamp> {
218-
// Note: specialization of `std::hash` is provided for convenience only. The
219-
// implementation is subject to change.
243+
/**
244+
* Hashes the given `timestamp`.
245+
*
246+
* @note: specialization of `std::hash` is provided for convenience only. The
247+
* implementation is subject to change.
248+
*/
220249
size_t operator()(const firebase::Timestamp& timestamp) const;
221250
};
222251
} // namespace std

Firestore/core/src/firebase/firestore/geo_point.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
namespace firebase {
2626
namespace firestore {
2727

28-
GeoPoint::GeoPoint() : GeoPoint(0, 0) {
29-
}
30-
3128
GeoPoint::GeoPoint(double latitude, double longitude)
3229
: latitude_(latitude), longitude_(longitude) {
3330
HARD_ASSERT(!std::isnan(latitude) && -90 <= latitude && latitude <= 90,

0 commit comments

Comments
 (0)