From 493180356c365c0ea1e08826391f6c3f25bd9875 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 16 Jun 2021 11:45:19 -0400 Subject: [PATCH 1/2] Format Firestore source code with clang-format --- firestore/src/android/blob_android.cc | 7 ++- firestore/src/android/blob_android.h | 3 +- firestore/src/android/converter_android.h | 6 +- .../src/android/document_reference_android.cc | 7 ++- .../src/android/document_reference_android.h | 3 +- .../src/android/document_snapshot_android.h | 3 +- firestore/src/android/exception_android.cc | 3 +- firestore/src/android/exception_android.h | 3 +- firestore/src/android/field_path_portable.h | 15 +++-- firestore/src/android/field_value_android.cc | 16 ++++-- firestore/src/android/field_value_android.h | 4 +- .../android/firestore_exceptions_android.h | 14 +++-- firestore/src/android/geo_point_android.cc | 4 +- firestore/src/android/jni_runnable_android.cc | 3 +- firestore/src/android/jni_runnable_android.h | 7 ++- firestore/src/android/lambda_event_listener.h | 7 ++- .../src/android/lambda_transaction_function.h | 3 +- .../android/listener_registration_android.cc | 19 +++++-- .../android/listener_registration_android.h | 4 +- firestore/src/android/promise_android.h | 32 +++++++---- .../src/android/promise_factory_android.h | 12 +++- firestore/src/android/query_android.cc | 9 ++- firestore/src/android/query_android.h | 12 ++-- firestore/src/android/timestamp_android.cc | 4 +- firestore/src/android/transaction_android.cc | 7 ++- firestore/src/android/transaction_android.h | 18 ++++-- firestore/src/android/wrapper.cc | 4 +- firestore/src/android/wrapper.h | 8 ++- firestore/src/android/write_batch_android.h | 6 +- firestore/src/common/cleanup.h | 11 +++- firestore/src/common/collection_reference.cc | 12 ++-- firestore/src/common/document_change.cc | 3 +- firestore/src/common/document_reference.cc | 3 +- firestore/src/common/document_snapshot.cc | 3 +- firestore/src/common/exception_common.cc | 11 +++- firestore/src/common/exception_common.h | 12 ++-- firestore/src/common/field_path.cc | 15 +++-- firestore/src/common/field_value.cc | 7 ++- firestore/src/common/hard_assert_common.cc | 11 +++- firestore/src/common/hard_assert_common.h | 6 +- firestore/src/common/listener_registration.cc | 3 +- .../src/common/main_for_testing_build.cc | 3 +- firestore/src/common/query.cc | 3 +- firestore/src/common/query_snapshot.cc | 3 +- firestore/src/common/set_options.cc | 6 +- firestore/src/common/settings.cc | 15 +++-- firestore/src/common/transaction.cc | 3 +- firestore/src/common/write_batch.cc | 3 +- .../firebase/firestore/document_reference.h | 4 +- .../firebase/firestore/event_listener.h | 3 +- .../include/firebase/firestore/field_value.h | 48 ++++++++++++---- .../firebase/firestore/query_snapshot.h | 4 +- .../src/include/firebase/firestore/settings.h | 16 ++++-- .../firebase/firestore/snapshot_metadata.h | 12 ++-- .../include/firebase/firestore/transaction.h | 9 ++- firestore/src/jni/array.h | 11 +++- firestore/src/jni/array_list.cc | 4 +- firestore/src/jni/boolean.cc | 4 +- firestore/src/jni/class.cc | 4 +- firestore/src/jni/class.h | 7 ++- firestore/src/jni/collection.cc | 4 +- firestore/src/jni/declaration.h | 56 +++++++++++++------ firestore/src/jni/double.cc | 4 +- firestore/src/jni/env.cc | 19 +++++-- firestore/src/jni/env.h | 35 ++++++++---- firestore/src/jni/hash_map.cc | 4 +- firestore/src/jni/integer.cc | 8 ++- firestore/src/jni/iterator.cc | 8 ++- firestore/src/jni/jni.cc | 4 +- firestore/src/jni/list.cc | 4 +- firestore/src/jni/loader.cc | 7 ++- firestore/src/jni/loader.h | 13 +++-- firestore/src/jni/long.cc | 8 ++- firestore/src/jni/map.cc | 12 +++- firestore/src/jni/object.cc | 4 +- firestore/src/jni/object.h | 11 +++- firestore/src/jni/ownership.h | 27 ++++++--- firestore/src/jni/string.cc | 15 +++-- firestore/src/jni/string.h | 10 +++- firestore/src/jni/task.cc | 8 ++- firestore/src/jni/throwable.h | 7 ++- firestore/src/jni/traits.h | 4 +- .../src/main/collection_reference_main.cc | 3 +- firestore/src/main/converter_main.h | 6 +- .../src/main/credentials_provider_desktop.h | 3 +- firestore/src/main/document_change_main.cc | 3 +- firestore/src/main/document_reference_main.cc | 3 +- firestore/src/main/document_reference_main.h | 12 +++- firestore/src/main/document_snapshot_main.cc | 7 ++- firestore/src/main/field_value_main.cc | 31 ++++++---- firestore/src/main/field_value_main.h | 7 ++- .../src/main/listener_registration_main.cc | 4 +- .../src/main/listener_registration_main.h | 8 ++- firestore/src/main/promise_factory_main.h | 8 ++- firestore/src/main/promise_main.h | 11 +++- firestore/src/main/query_main.cc | 13 +++-- firestore/src/main/query_main.h | 18 ++++-- firestore/src/main/query_snapshot_main.cc | 7 ++- firestore/src/main/set_options_main.h | 13 +++-- firestore/src/main/transaction_main.cc | 6 +- firestore/src/main/transaction_main.h | 6 +- .../src/main/user_data_converter_main.cc | 3 +- firestore/src/main/user_data_converter_main.h | 3 +- firestore/src/main/write_batch_main.cc | 7 ++- firestore/src/main/write_batch_main.h | 3 +- 105 files changed, 677 insertions(+), 282 deletions(-) diff --git a/firestore/src/android/blob_android.cc b/firestore/src/android/blob_android.cc index ac68a1d173..f69c45146e 100644 --- a/firestore/src/android/blob_android.cc +++ b/firestore/src/android/blob_android.cc @@ -32,9 +32,12 @@ void BlobInternal::Initialize(jni::Loader& loader) { loader.LoadAll(kConstructor, kFromBytes, kToBytes); } -Class BlobInternal::GetClass() { return Class(g_class); } +Class BlobInternal::GetClass() { + return Class(g_class); +} -Local BlobInternal::Create(Env& env, const uint8_t* value, +Local BlobInternal::Create(Env& env, + const uint8_t* value, size_t size) { Local> byte_array = env.NewArray(size); env.SetArrayRegion(byte_array, 0, size, value); diff --git a/firestore/src/android/blob_android.h b/firestore/src/android/blob_android.h index 187072a4c4..0a3b6c5125 100644 --- a/firestore/src/android/blob_android.h +++ b/firestore/src/android/blob_android.h @@ -15,7 +15,8 @@ class BlobInternal : public jni::Object { static jni::Class GetClass(); - static jni::Local Create(jni::Env& env, const uint8_t* value, + static jni::Local Create(jni::Env& env, + const uint8_t* value, size_t size); jni::Local> ToBytes(jni::Env& env) const; diff --git a/firestore/src/android/converter_android.h b/firestore/src/android/converter_android.h index b982f4f231..472aedb566 100644 --- a/firestore/src/android/converter_android.h +++ b/firestore/src/android/converter_android.h @@ -32,7 +32,8 @@ struct ConverterImpl { } template > - static PublicT MakePublicFromJava(jni::Env& env, FirestoreInternal* firestore, + static PublicT MakePublicFromJava(jni::Env& env, + FirestoreInternal* firestore, const jni::Object& object) { if (!env.ok() || !object) return {}; @@ -62,7 +63,8 @@ PublicT MakePublic(jni::Env& env, const jni::Object& object) { } template > -PublicT MakePublic(jni::Env& env, FirestoreInternal* firestore, +PublicT MakePublic(jni::Env& env, + FirestoreInternal* firestore, const jni::Object& object) { return ConverterImpl::MakePublicFromJava(env, firestore, object); diff --git a/firestore/src/android/document_reference_android.cc b/firestore/src/android/document_reference_android.cc index 0b28a70bc5..b4d969d455 100644 --- a/firestore/src/android/document_reference_android.cc +++ b/firestore/src/android/document_reference_android.cc @@ -176,7 +176,8 @@ ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( #endif // defined(FIREBASE_USE_STD_FUNCTION) ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( - MetadataChanges metadata_changes, EventListener* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership) { Env env = GetEnv(); Local java_metadata = @@ -193,7 +194,9 @@ ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( firestore_, listener, passing_listener_ownership, java_registration)); } -Class DocumentReferenceInternal::GetClass() { return Class(clazz); } +Class DocumentReferenceInternal::GetClass() { + return Class(clazz); +} } // namespace firestore } // namespace firebase diff --git a/firestore/src/android/document_reference_android.h b/firestore/src/android/document_reference_android.h index db7d3d95f2..4345197cf3 100644 --- a/firestore/src/android/document_reference_android.h +++ b/firestore/src/android/document_reference_android.h @@ -37,7 +37,8 @@ class DocumentReferenceInternal : public Wrapper { DocumentReferenceInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) {} + : Wrapper(firestore, object), promises_(firestore) { + } /** Gets the Firestore instance associated with this document reference. */ Firestore* firestore(); diff --git a/firestore/src/android/document_snapshot_android.h b/firestore/src/android/document_snapshot_android.h index db16642b4c..069c6bfd08 100644 --- a/firestore/src/android/document_snapshot_android.h +++ b/firestore/src/android/document_snapshot_android.h @@ -20,7 +20,8 @@ class DocumentSnapshotInternal : public Wrapper { static void Initialize(jni::Loader& loader); - ~DocumentSnapshotInternal() override {} + ~DocumentSnapshotInternal() override { + } /** Gets the Firestore instance associated with this document snapshot. */ Firestore* firestore() const; diff --git a/firestore/src/android/exception_android.cc b/firestore/src/android/exception_android.cc index a866985be2..b79fb6f213 100644 --- a/firestore/src/android/exception_android.cc +++ b/firestore/src/android/exception_android.cc @@ -98,7 +98,8 @@ std::string ExceptionInternal::ToString(Env& env, const Object& exception) { return exception.CastTo().GetMessage(env); } -Local ExceptionInternal::Create(Env& env, Error code, +Local ExceptionInternal::Create(Env& env, + Error code, const std::string& message) { if (code == Error::kErrorOk) { return {}; diff --git a/firestore/src/android/exception_android.h b/firestore/src/android/exception_android.h index f1708098ea..3b497dc802 100644 --- a/firestore/src/android/exception_android.h +++ b/firestore/src/android/exception_android.h @@ -21,7 +21,8 @@ class ExceptionInternal { static Error GetErrorCode(jni::Env& env, const jni::Object& exception); static std::string ToString(jni::Env& env, const jni::Object& exception); - static jni::Local Create(jni::Env& env, Error code, + static jni::Local Create(jni::Env& env, + Error code, const std::string& message); static jni::Local Wrap( jni::Env& env, jni::Local&& exception); diff --git a/firestore/src/android/field_path_portable.h b/firestore/src/android/field_path_portable.h index ca3b420e96..03eafacca1 100644 --- a/firestore/src/android/field_path_portable.h +++ b/firestore/src/android/field_path_portable.h @@ -23,7 +23,8 @@ class FieldPathPortable { static constexpr const char* kDocumentKeyPath = "__name__"; explicit FieldPathPortable(std::vector&& segments) - : segments_(firebase::Move(segments)) {} + : segments_(firebase::Move(segments)) { + } /** Returns i-th segment of the path. */ const std::string& operator[](const size_t i) const { @@ -31,11 +32,17 @@ class FieldPathPortable { return segments_[i]; } - const_iterator begin() const { return segments_.begin(); } + const_iterator begin() const { + return segments_.begin(); + } - const_iterator end() const { return segments_.end(); } + const_iterator end() const { + return segments_.end(); + } - size_t size() const { return segments_.size(); } + size_t size() const { + return segments_.size(); + } std::string CanonicalString() const; diff --git a/firestore/src/android/field_value_android.cc b/firestore/src/android/field_value_android.cc index 7f634424d6..de69b161a3 100644 --- a/firestore/src/android/field_value_android.cc +++ b/firestore/src/android/field_value_android.cc @@ -71,19 +71,23 @@ FieldValue FieldValueInternal::Create(Env& env, const Object& object) { return FieldValue(new FieldValueInternal(Type::kNull, object)); } -FieldValue FieldValueInternal::Create(Env& env, Type type, +FieldValue FieldValueInternal::Create(Env& env, + Type type, const Object& object) { if (!env.ok() || !object) return {}; return FieldValue(new FieldValueInternal(type, object)); } -FieldValueInternal::FieldValueInternal() : cached_type_(Type::kNull) {} +FieldValueInternal::FieldValueInternal() : cached_type_(Type::kNull) { +} FieldValueInternal::FieldValueInternal(const Object& object) - : object_(object), cached_type_(Type::kNull) {} + : object_(object), cached_type_(Type::kNull) { +} FieldValueInternal::FieldValueInternal(Type type, const Object& object) - : object_(object), cached_type_(type) {} + : object_(object), cached_type_(type) { +} FieldValueInternal::FieldValueInternal(bool value) : cached_type_(Type::kBoolean) { @@ -401,7 +405,9 @@ Local> FieldValueInternal::MakeArray( return result; } -Env FieldValueInternal::GetEnv() { return FirestoreInternal::GetEnv(); } +Env FieldValueInternal::GetEnv() { + return FirestoreInternal::GetEnv(); +} Object FieldValueInternal::ToJava(const FieldValue& value) { return value.internal_ ? value.internal_->object_ : Object(); diff --git a/firestore/src/android/field_value_android.h b/firestore/src/android/field_value_android.h index 79fd8e16b3..2beaa2fe5e 100644 --- a/firestore/src/android/field_value_android.h +++ b/firestore/src/android/field_value_android.h @@ -65,7 +65,9 @@ class FieldValueInternal { std::vector array_value() const; MapFieldValue map_value() const; - const jni::Global& ToJava() const { return object_; } + const jni::Global& ToJava() const { + return object_; + } static FieldValue Delete(); static FieldValue ServerTimestamp(); diff --git a/firestore/src/android/firestore_exceptions_android.h b/firestore/src/android/firestore_exceptions_android.h index 9404d061f0..91d140b3dd 100644 --- a/firestore/src/android/firestore_exceptions_android.h +++ b/firestore/src/android/firestore_exceptions_android.h @@ -34,11 +34,16 @@ namespace firestore { class FirestoreException : public std::exception { public: FirestoreException(const std::string& message, Error code) - : message_(message), code_(code) {} + : message_(message), code_(code) { + } - const char* what() const noexcept override { return message_.c_str(); } + const char* what() const noexcept override { + return message_.c_str(); + } - Error code() const { return code_; } + Error code() const { + return code_; + } private: std::string message_; @@ -52,7 +57,8 @@ class FirestoreInternalError : public FirestoreException { public: FirestoreInternalError(const std::string& message, Error code = Error::kErrorInternal) - : FirestoreException(message, code) {} + : FirestoreException(message, code) { + } }; #endif // FIRESTORE_HAVE_EXCEPTIONS diff --git a/firestore/src/android/geo_point_android.cc b/firestore/src/android/geo_point_android.cc index 5d7800e52e..f0ef7c181d 100644 --- a/firestore/src/android/geo_point_android.cc +++ b/firestore/src/android/geo_point_android.cc @@ -28,7 +28,9 @@ void GeoPointInternal::Initialize(jni::Loader& loader) { loader.LoadClass(kClassName, kConstructor, kGetLatitude, kGetLongitude); } -Class GeoPointInternal::GetClass() { return Class(g_clazz); } +Class GeoPointInternal::GetClass() { + return Class(g_clazz); +} Local GeoPointInternal::Create(Env& env, const GeoPoint& point) { diff --git a/firestore/src/android/jni_runnable_android.cc b/firestore/src/android/jni_runnable_android.cc index 50a590b34d..26a7156c95 100644 --- a/firestore/src/android/jni_runnable_android.cc +++ b/firestore/src/android/jni_runnable_android.cc @@ -47,7 +47,8 @@ void JniRunnableBase::Initialize(jni::Loader& loader) { } JniRunnableBase::JniRunnableBase(Env& env) - : java_runnable_(env.New(kConstructor, reinterpret_cast(this))) {} + : java_runnable_(env.New(kConstructor, reinterpret_cast(this))) { +} JniRunnableBase::~JniRunnableBase() { Env env; diff --git a/firestore/src/android/jni_runnable_android.h b/firestore/src/android/jni_runnable_android.h index 8ee9439424..d357a5347c 100644 --- a/firestore/src/android/jni_runnable_android.h +++ b/firestore/src/android/jni_runnable_android.h @@ -116,9 +116,12 @@ template class JniRunnable : public JniRunnableBase { public: JniRunnable(jni::Env& env, CallbackT callback) - : JniRunnableBase(env), callback_(firebase::Move(callback)) {} + : JniRunnableBase(env), callback_(firebase::Move(callback)) { + } - void Run() override { Run(*this, callback_); } + void Run() override { + Run(*this, callback_); + } private: // These two static overloads of `Run()` use SFINAE to invoke the callback diff --git a/firestore/src/android/lambda_event_listener.h b/firestore/src/android/lambda_event_listener.h index b7594f5915..c2b057deac 100644 --- a/firestore/src/android/lambda_event_listener.h +++ b/firestore/src/android/lambda_event_listener.h @@ -24,7 +24,8 @@ class LambdaEventListener : public EventListener { FIREBASE_ASSERT(callback_); } - void OnEvent(const T& value, Error error_code, + void OnEvent(const T& value, + Error error_code, const std::string& error_message) override { callback_(value, error_code, error_message); } @@ -41,7 +42,9 @@ class LambdaEventListener : public EventListener { FIREBASE_ASSERT(callback_); } - void OnEvent(Error, const std::string&) override { callback_(); } + void OnEvent(Error, const std::string&) override { + callback_(); + } private: std::function callback_; diff --git a/firestore/src/android/lambda_transaction_function.h b/firestore/src/android/lambda_transaction_function.h index 326d2e1111..c9ef3bcd4b 100644 --- a/firestore/src/android/lambda_transaction_function.h +++ b/firestore/src/android/lambda_transaction_function.h @@ -40,7 +40,8 @@ class LambdaTransactionFunction } // Override Promise::Completion::CompleteWith(). - void CompleteWith(Error error_code, const char* error_message, + void CompleteWith(Error error_code, + const char* error_message, void* result) override { delete this; } diff --git a/firestore/src/android/listener_registration_android.cc b/firestore/src/android/listener_registration_android.cc index 5e782820d5..cdaed158cd 100644 --- a/firestore/src/android/listener_registration_android.cc +++ b/firestore/src/android/listener_registration_android.cc @@ -26,7 +26,8 @@ void ListenerRegistrationInternal::Initialize(jni::Loader& loader) { ListenerRegistrationInternal::ListenerRegistrationInternal( FirestoreInternal* firestore, - EventListener* event_listener, bool owning_event_listener, + EventListener* event_listener, + bool owning_event_listener, const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), @@ -40,8 +41,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( } ListenerRegistrationInternal::ListenerRegistrationInternal( - FirestoreInternal* firestore, EventListener* event_listener, - bool owning_event_listener, const Object& listener_registration) + FirestoreInternal* firestore, + EventListener* event_listener, + bool owning_event_listener, + const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), query_event_listener_(event_listener), @@ -54,8 +57,10 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( } ListenerRegistrationInternal::ListenerRegistrationInternal( - FirestoreInternal* firestore, EventListener* event_listener, - bool owning_event_listener, const Object& listener_registration) + FirestoreInternal* firestore, + EventListener* event_listener, + bool owning_event_listener, + const Object& listener_registration) : firestore_(firestore), listener_registration_(listener_registration), void_event_listener_(event_listener), @@ -88,7 +93,9 @@ ListenerRegistrationInternal::~ListenerRegistrationInternal() { } } -jni::Env ListenerRegistrationInternal::GetEnv() { return firestore_->GetEnv(); } +jni::Env ListenerRegistrationInternal::GetEnv() { + return firestore_->GetEnv(); +} } // namespace firestore } // namespace firebase diff --git a/firestore/src/android/listener_registration_android.h b/firestore/src/android/listener_registration_android.h index d2377193f5..4edff69646 100644 --- a/firestore/src/android/listener_registration_android.h +++ b/firestore/src/android/listener_registration_android.h @@ -55,7 +55,9 @@ class ListenerRegistrationInternal { ListenerRegistrationInternal& operator=( ListenerRegistrationInternal&& another) = delete; - FirestoreInternal* firestore_internal() { return firestore_; } + FirestoreInternal* firestore_internal() { + return firestore_; + } private: friend class DocumentReferenceInternal; diff --git a/firestore/src/android/promise_android.h b/firestore/src/android/promise_android.h index 6cbafdae00..000a4d5ade 100644 --- a/firestore/src/android/promise_android.h +++ b/firestore/src/android/promise_android.h @@ -43,11 +43,13 @@ class Promise { class Completion { public: virtual ~Completion() = default; - virtual void CompleteWith(Error error_code, const char* error_message, + virtual void CompleteWith(Error error_code, + const char* error_message, PublicType* result) = 0; }; - ~Promise() {} + ~Promise() { + } Promise(const Promise&) = delete; Promise& operator=(const Promise&) = delete; @@ -65,27 +67,35 @@ class Promise { completer, kApiIdentifier); } - Future GetFuture() { return MakeFuture(impl_, handle_); } + Future GetFuture() { + return MakeFuture(impl_, handle_); + } private: // The constructor is intentionally private. // Create instances with `PromiseFactory`. - Promise(ReferenceCountedFutureImpl* impl, FirestoreInternal* firestore, + Promise(ReferenceCountedFutureImpl* impl, + FirestoreInternal* firestore, Completion* completion) : completer_(MakeUnique>( impl, firestore, completion)), - impl_(impl) {} + impl_(impl) { + } template class CompleterBase { public: CompleterBase(ReferenceCountedFutureImpl* impl, - FirestoreInternal* firestore, Completion* completion) - : impl_{impl}, firestore_{firestore}, completion_(completion) {} + FirestoreInternal* firestore, + Completion* completion) + : impl_{impl}, firestore_{firestore}, completion_(completion) { + } virtual ~CompleterBase() = default; - FirestoreInternal* firestore() { return firestore_; } + FirestoreInternal* firestore() { + return firestore_; + } SafeFutureHandle Alloc(int fn_index) { handle_ = impl_->SafeAlloc(fn_index); @@ -174,9 +184,11 @@ class Promise { } }; - static void ResultCallback(JNIEnv* env, jobject result, + static void ResultCallback(JNIEnv* env, + jobject result, util::FutureResult result_code, - const char* status_message, void* callback_data) { + const char* status_message, + void* callback_data) { if (callback_data != nullptr) { auto* data = static_cast*>(callback_data); diff --git a/firestore/src/android/promise_factory_android.h b/firestore/src/android/promise_factory_android.h index d0c564dc99..747c5b5cda 100644 --- a/firestore/src/android/promise_factory_android.h +++ b/firestore/src/android/promise_factory_android.h @@ -28,7 +28,9 @@ class PromiseFactory { firestore_->future_manager().MoveFutureApi(&rhs, this); } - ~PromiseFactory() { firestore_->future_manager().ReleaseFutureApi(this); } + ~PromiseFactory() { + firestore_->future_manager().ReleaseFutureApi(this); + } PromiseFactory& operator=(const PromiseFactory&) = delete; PromiseFactory& operator=(PromiseFactory&&) = delete; @@ -46,7 +48,9 @@ class PromiseFactory { template > Future NewFuture( - jni::Env& env, EnumT op, const jni::Task& task, + jni::Env& env, + EnumT op, + const jni::Task& task, typename Promise::Completion* completion = nullptr) { if (!env.ok()) return {}; @@ -63,7 +67,9 @@ class PromiseFactory { return firestore_->future_manager().GetFutureApi(this); } - constexpr int ApiCount() const { return static_cast(EnumT::kCount); } + constexpr int ApiCount() const { + return static_cast(EnumT::kCount); + } FirestoreInternal* firestore_ = nullptr; }; diff --git a/firestore/src/android/query_android.cc b/firestore/src/android/query_android.cc index c3992b59fc..c2b2046f0e 100644 --- a/firestore/src/android/query_android.cc +++ b/firestore/src/android/query_android.cc @@ -249,7 +249,8 @@ Future QueryInternal::Get(Source source) { return promises_.NewFuture(env, AsyncFn::kGet, task); } -Query QueryInternal::Where(const FieldPath& field, const Method& method, +Query QueryInternal::Where(const FieldPath& field, + const Method& method, const FieldValue& value) const { Env env = GetEnv(); Local java_field = FieldPathConverter::Create(env, field); @@ -257,7 +258,8 @@ Query QueryInternal::Where(const FieldPath& field, const Method& method, return firestore_->NewQuery(env, query); } -Query QueryInternal::Where(const FieldPath& field, const Method& method, +Query QueryInternal::Where(const FieldPath& field, + const Method& method, const std::vector& values) const { Env env = GetEnv(); @@ -300,7 +302,8 @@ ListenerRegistration QueryInternal::AddSnapshotListener( #endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN) ListenerRegistration QueryInternal::AddSnapshotListener( - MetadataChanges metadata_changes, EventListener* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership) { Env env = GetEnv(); diff --git a/firestore/src/android/query_android.h b/firestore/src/android/query_android.h index 2c2b898910..b84c723a58 100644 --- a/firestore/src/android/query_android.h +++ b/firestore/src/android/query_android.h @@ -34,7 +34,8 @@ class QueryInternal : public Wrapper { static void Initialize(jni::Loader& loader); QueryInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) {} + : Wrapper(firestore, object), promises_(firestore) { + } /** Gets the Firestore instance associated with this query. */ Firestore* firestore(); @@ -365,7 +366,8 @@ class QueryInternal : public Wrapper { * @return A registration object that can be used to remove the listener. */ ListenerRegistration AddSnapshotListener( - MetadataChanges metadata_changes, EventListener* listener, + MetadataChanges metadata_changes, + EventListener* listener, bool passing_listener_ownership = false); protected: @@ -375,9 +377,11 @@ class QueryInternal : public Wrapper { friend class FirestoreInternal; // A generalized function for all WhereFoo calls. - Query Where(const FieldPath& field, const jni::Method& method, + Query Where(const FieldPath& field, + const jni::Method& method, const FieldValue& value) const; - Query Where(const FieldPath& field, const jni::Method& method, + Query Where(const FieldPath& field, + const jni::Method& method, const std::vector& values) const; // A generalized function for all {Start|End}{Before|After|At} calls. diff --git a/firestore/src/android/timestamp_android.cc b/firestore/src/android/timestamp_android.cc index db72af0081..98998285cb 100644 --- a/firestore/src/android/timestamp_android.cc +++ b/firestore/src/android/timestamp_android.cc @@ -28,7 +28,9 @@ void TimestampInternal::Initialize(jni::Loader& loader) { loader.LoadClass(kClassName, kConstructor, kGetSeconds, kGetNanoseconds); } -Class TimestampInternal::GetClass() { return Class(g_clazz); } +Class TimestampInternal::GetClass() { + return Class(g_clazz); +} Local TimestampInternal::Create(Env& env, const Timestamp& timestamp) { diff --git a/firestore/src/android/transaction_android.cc b/firestore/src/android/transaction_android.cc index c31f27f122..992e81ebd6 100644 --- a/firestore/src/android/transaction_android.cc +++ b/firestore/src/android/transaction_android.cc @@ -193,8 +193,11 @@ Local TransactionInternal::Create(Env& env, } jobject TransactionInternal::TransactionFunctionNativeApply( - JNIEnv* raw_env, jclass clazz, jlong firestore_ptr, - jlong transaction_function_ptr, jobject java_transaction) { + JNIEnv* raw_env, + jclass clazz, + jlong firestore_ptr, + jlong transaction_function_ptr, + jobject java_transaction) { if (firestore_ptr == 0 || transaction_function_ptr == 0) { return nullptr; } diff --git a/firestore/src/android/transaction_android.h b/firestore/src/android/transaction_android.h index e37849a7be..76d090bd25 100644 --- a/firestore/src/android/transaction_android.h +++ b/firestore/src/android/transaction_android.h @@ -24,16 +24,20 @@ class TransactionInternal : public Wrapper { TransactionInternal(FirestoreInternal* firestore, const jni::Object& obj) : Wrapper(firestore, obj), - first_exception_(MakeShared>()) {} + first_exception_(MakeShared>()) { + } TransactionInternal(const TransactionInternal& rhs) - : Wrapper(rhs), first_exception_(rhs.first_exception_) {} + : Wrapper(rhs), first_exception_(rhs.first_exception_) { + } TransactionInternal(TransactionInternal&& rhs) : Wrapper(firebase::Move(rhs)), - first_exception_(Move(rhs.first_exception_)) {} + first_exception_(Move(rhs.first_exception_)) { + } - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options); void Update(const DocumentReference& document, const MapFieldValue& data); @@ -42,14 +46,16 @@ class TransactionInternal : public Wrapper { void Delete(const DocumentReference& document); - DocumentSnapshot Get(const DocumentReference& document, Error* error_code, + DocumentSnapshot Get(const DocumentReference& document, + Error* error_code, std::string* error_message); static jni::Local Create(jni::Env& env, FirestoreInternal* firestore, TransactionFunction* function); - static jobject TransactionFunctionNativeApply(JNIEnv* env, jclass clazz, + static jobject TransactionFunctionNativeApply(JNIEnv* env, + jclass clazz, jlong firestore_ptr, jlong transaction_function_ptr, jobject transaction); diff --git a/firestore/src/android/wrapper.cc b/firestore/src/android/wrapper.cc index 1ef2a54813..267cc03166 100644 --- a/firestore/src/android/wrapper.cc +++ b/firestore/src/android/wrapper.cc @@ -40,7 +40,9 @@ Wrapper::Wrapper(Wrapper* rhs) : Wrapper() { Wrapper::~Wrapper() = default; -jni::Env Wrapper::GetEnv() const { return firestore_->GetEnv(); } +jni::Env Wrapper::GetEnv() const { + return firestore_->GetEnv(); +} Object Wrapper::ToJava(const FieldValue& value) { return FieldValueInternal::ToJava(value); diff --git a/firestore/src/android/wrapper.h b/firestore/src/android/wrapper.h index 65d3faec2d..7f7256c2f2 100644 --- a/firestore/src/android/wrapper.h +++ b/firestore/src/android/wrapper.h @@ -27,8 +27,12 @@ class Wrapper { Wrapper& operator=(const Wrapper& wrapper) = delete; Wrapper& operator=(Wrapper&& wrapper) = delete; - FirestoreInternal* firestore_internal() { return firestore_; } - const jni::Object& ToJava() const { return obj_; } + FirestoreInternal* firestore_internal() { + return firestore_; + } + const jni::Object& ToJava() const { + return obj_; + } static jni::Object ToJava(const FieldValue& value); diff --git a/firestore/src/android/write_batch_android.h b/firestore/src/android/write_batch_android.h index f38493d31e..b8f813a473 100644 --- a/firestore/src/android/write_batch_android.h +++ b/firestore/src/android/write_batch_android.h @@ -24,9 +24,11 @@ class WriteBatchInternal : public Wrapper { static void Initialize(jni::Loader& loader); WriteBatchInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) {} + : Wrapper(firestore, object), promises_(firestore) { + } - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options); void Update(const DocumentReference& document, const MapFieldValue& data); diff --git a/firestore/src/common/cleanup.h b/firestore/src/common/cleanup.h index 957bfc9913..62ec9c75db 100644 --- a/firestore/src/common/cleanup.h +++ b/firestore/src/common/cleanup.h @@ -23,10 +23,13 @@ class FirestoreInternal; // F is almost always FirestoreInternal unless one wants something else to // manage the cleanup process. We define type F to make this CleanupFn // implementation platform-independent. -template , +template , typename F = FirestoreInternal> struct CleanupFn { - static void Cleanup(void* obj_void) { DoCleanup(static_cast(obj_void)); } + static void Cleanup(void* obj_void) { + DoCleanup(static_cast(obj_void)); + } static void Register(T* obj, F* firestore) { if (firestore) { @@ -71,7 +74,9 @@ struct CleanupFn { } // `ListenerRegistration` objects differ from the common pattern. - static void DoCleanup(ListenerRegistration* obj) { obj->Cleanup(); } + static void DoCleanup(ListenerRegistration* obj) { + obj->Cleanup(); + } }; } // namespace firestore diff --git a/firestore/src/common/collection_reference.cc b/firestore/src/common/collection_reference.cc index cf4eb36bc4..335efd1cbd 100644 --- a/firestore/src/common/collection_reference.cc +++ b/firestore/src/common/collection_reference.cc @@ -25,18 +25,22 @@ namespace firestore { // Java CollectionReference) be subclass of QueryInternal (resp. Java Query), // which is already the case. -CollectionReference::CollectionReference() {} +CollectionReference::CollectionReference() { +} CollectionReference::CollectionReference(const CollectionReference& reference) : Query(reference.internal() ? new CollectionReferenceInternal(*reference.internal()) - : nullptr) {} + : nullptr) { +} CollectionReference::CollectionReference(CollectionReference&& reference) - : Query(firebase::Move(reference)) {} + : Query(firebase::Move(reference)) { +} CollectionReference::CollectionReference(CollectionReferenceInternal* internal) - : Query(internal) {} + : Query(internal) { +} CollectionReference& CollectionReference::operator=( const CollectionReference& reference) { diff --git a/firestore/src/common/document_change.cc b/firestore/src/common/document_change.cc index 9908b679cb..dd3c87c305 100644 --- a/firestore/src/common/document_change.cc +++ b/firestore/src/common/document_change.cc @@ -25,7 +25,8 @@ using Type = DocumentChange::Type; const std::size_t DocumentChange::npos = static_cast(-1); #endif // defined(ANDROID) -DocumentChange::DocumentChange() {} +DocumentChange::DocumentChange() { +} DocumentChange::DocumentChange(const DocumentChange& value) { if (value.internal_) { diff --git a/firestore/src/common/document_reference.cc b/firestore/src/common/document_reference.cc index d966ee3a54..db21652f0e 100644 --- a/firestore/src/common/document_reference.cc +++ b/firestore/src/common/document_reference.cc @@ -25,7 +25,8 @@ namespace firestore { using CleanupFnDocumentReference = CleanupFn; -DocumentReference::DocumentReference() {} +DocumentReference::DocumentReference() { +} DocumentReference::DocumentReference(const DocumentReference& reference) { if (reference.internal_) { diff --git a/firestore/src/common/document_snapshot.cc b/firestore/src/common/document_snapshot.cc index 4b3db14ab5..0d5057dfc0 100644 --- a/firestore/src/common/document_snapshot.cc +++ b/firestore/src/common/document_snapshot.cc @@ -23,7 +23,8 @@ namespace firestore { using CleanupFnDocumentSnapshot = CleanupFn; -DocumentSnapshot::DocumentSnapshot() {} +DocumentSnapshot::DocumentSnapshot() { +} DocumentSnapshot::DocumentSnapshot(const DocumentSnapshot& snapshot) { if (snapshot.internal_) { diff --git a/firestore/src/common/exception_common.cc b/firestore/src/common/exception_common.cc index e86f87bc6c..de2c6d063f 100644 --- a/firestore/src/common/exception_common.cc +++ b/firestore/src/common/exception_common.cc @@ -34,7 +34,10 @@ const char* ExceptionName(ExceptionType exception) { } FIRESTORE_ATTRIBUTE_NORETURN void DefaultThrowHandler( - ExceptionType type, const char* file, const char* func, int line, + ExceptionType type, + const char* file, + const char* func, + int line, const std::string& message) { std::ostringstream what; what << ExceptionName(type) << ": "; @@ -82,8 +85,10 @@ ThrowHandler SetThrowHandler(ThrowHandler handler) { } FIRESTORE_ATTRIBUTE_NORETURN void Throw(ExceptionType exception, - const char* file, const char* func, - int line, const std::string& message) { + const char* file, + const char* func, + int line, + const std::string& message) { throw_handler(exception, file, func, line, message); // It's expected that the throw handler above does not return. If it does, diff --git a/firestore/src/common/exception_common.h b/firestore/src/common/exception_common.h index ab685453ad..42c651dad5 100644 --- a/firestore/src/common/exception_common.h +++ b/firestore/src/common/exception_common.h @@ -52,8 +52,10 @@ enum class ExceptionType { * platform. Implementations of `ThrowHandler` must tolerate null/zero values * for `file`, `func`, and `line`. */ -using ThrowHandler = void (*)(ExceptionType type, const char* file, - const char* func, int line, +using ThrowHandler = void (*)(ExceptionType type, + const char* file, + const char* func, + int line, const std::string& message); /** @@ -72,8 +74,10 @@ using ThrowHandler = void (*)(ExceptionType type, const char* file, ThrowHandler SetThrowHandler(ThrowHandler handler); FIRESTORE_ATTRIBUTE_NORETURN void Throw(ExceptionType exception, - const char* file, const char* func, - int line, const std::string& message); + const char* file, + const char* func, + int line, + const std::string& message); } // namespace util diff --git a/firestore/src/common/field_path.cc b/firestore/src/common/field_path.cc index 1de85336fe..7efcd06063 100644 --- a/firestore/src/common/field_path.cc +++ b/firestore/src/common/field_path.cc @@ -36,24 +36,29 @@ namespace firebase { namespace firestore { -FieldPath::FieldPath() {} +FieldPath::FieldPath() { +} #if !defined(_STLPORT_VERSION) FieldPath::FieldPath(std::initializer_list field_names) - : internal_(InternalFromSegments(std::vector(field_names))) {} + : internal_(InternalFromSegments(std::vector(field_names))) { +} #endif // !defined(_STLPORT_VERSION) FieldPath::FieldPath(const std::vector& field_names) - : internal_(InternalFromSegments(field_names)) {} + : internal_(InternalFromSegments(field_names)) { +} FieldPath::FieldPath(const FieldPath& path) - : internal_(new FieldPathInternal{*path.internal_}) {} + : internal_(new FieldPathInternal{*path.internal_}) { +} FieldPath::FieldPath(FieldPath&& path) noexcept : internal_(path.internal_) { path.internal_ = nullptr; } -FieldPath::FieldPath(FieldPathInternal* internal) : internal_(internal) {} +FieldPath::FieldPath(FieldPathInternal* internal) : internal_(internal) { +} FieldPath::~FieldPath() { delete internal_; diff --git a/firestore/src/common/field_value.cc b/firestore/src/common/field_value.cc index 7053163edb..56b51cb2a1 100644 --- a/firestore/src/common/field_value.cc +++ b/firestore/src/common/field_value.cc @@ -74,7 +74,8 @@ std::string ValueToString(const uint8_t* blob, size_t size) { } // namespace -FieldValue::FieldValue() {} +FieldValue::FieldValue() { +} FieldValue::FieldValue(const FieldValue& value) { if (value.internal_) { @@ -238,7 +239,9 @@ FieldValue FieldValue::Null() { } /* static */ -FieldValue FieldValue::Delete() { return FieldValueInternal::Delete(); } +FieldValue FieldValue::Delete() { + return FieldValueInternal::Delete(); +} /* static */ FieldValue FieldValue::ServerTimestamp() { diff --git a/firestore/src/common/hard_assert_common.cc b/firestore/src/common/hard_assert_common.cc index 83124d9edb..017b664034 100644 --- a/firestore/src/common/hard_assert_common.cc +++ b/firestore/src/common/hard_assert_common.cc @@ -9,13 +9,18 @@ namespace internal { #if defined(__ANDROID__) -void FailAssertion(const char* file, const char* func, const int line, +void FailAssertion(const char* file, + const char* func, + const int line, const std::string& message) { Throw(ExceptionType::AssertionFailure, file, func, line, message); } -void FailAssertion(const char* file, const char* func, const int line, - const std::string& message, const char* condition) { +void FailAssertion(const char* file, + const char* func, + const int line, + const std::string& message, + const char* condition) { std::string failure; if (message.empty()) { failure = condition; diff --git a/firestore/src/common/hard_assert_common.h b/firestore/src/common/hard_assert_common.h index 2ab824253d..ff0c35a5f4 100644 --- a/firestore/src/common/hard_assert_common.h +++ b/firestore/src/common/hard_assert_common.h @@ -106,11 +106,13 @@ namespace internal { // These symbols are in the util::internal namespace to match their iOS // equivalents. FIRESTORE_ATTRIBUTE_NORETURN void FailAssertion(const char* file, - const char* func, int line, + const char* func, + int line, const std::string& message); FIRESTORE_ATTRIBUTE_NORETURN void FailAssertion(const char* file, - const char* func, int line, + const char* func, + int line, const std::string& message, const char* condition); diff --git a/firestore/src/common/listener_registration.cc b/firestore/src/common/listener_registration.cc index 52e90828d6..ffddd42cf0 100644 --- a/firestore/src/common/listener_registration.cc +++ b/firestore/src/common/listener_registration.cc @@ -23,7 +23,8 @@ namespace firestore { using CleanupFnListenerRegistration = CleanupFn; -ListenerRegistration::ListenerRegistration() : ListenerRegistration(nullptr) {} +ListenerRegistration::ListenerRegistration() : ListenerRegistration(nullptr) { +} ListenerRegistration::ListenerRegistration( const ListenerRegistration& registration) diff --git a/firestore/src/common/main_for_testing_build.cc b/firestore/src/common/main_for_testing_build.cc index 237c8ce181..b2f997621b 100644 --- a/firestore/src/common/main_for_testing_build.cc +++ b/firestore/src/common/main_for_testing_build.cc @@ -1 +1,2 @@ -int main() {} +int main() { +} diff --git a/firestore/src/common/query.cc b/firestore/src/common/query.cc index fc06f9d612..5897ef37d0 100644 --- a/firestore/src/common/query.cc +++ b/firestore/src/common/query.cc @@ -24,7 +24,8 @@ namespace firestore { using CleanupFnQuery = CleanupFn; -Query::Query() {} +Query::Query() { +} Query::Query(const Query& query) { if (query.internal_) { diff --git a/firestore/src/common/query_snapshot.cc b/firestore/src/common/query_snapshot.cc index 85ac8d446c..65a71860fa 100644 --- a/firestore/src/common/query_snapshot.cc +++ b/firestore/src/common/query_snapshot.cc @@ -20,7 +20,8 @@ namespace firestore { using CleanupFnQuerySnapshot = CleanupFn; -QuerySnapshot::QuerySnapshot() {} +QuerySnapshot::QuerySnapshot() { +} QuerySnapshot::QuerySnapshot(const QuerySnapshot& snapshot) { if (snapshot.internal_) { diff --git a/firestore/src/common/set_options.cc b/firestore/src/common/set_options.cc index 70916fabf4..b6707838b0 100644 --- a/firestore/src/common/set_options.cc +++ b/firestore/src/common/set_options.cc @@ -22,9 +22,11 @@ namespace firebase { namespace firestore { SetOptions::SetOptions(Type type, std::vector fields) - : type_(type), fields_(firebase::Move(fields)) {} + : type_(type), fields_(firebase::Move(fields)) { +} -SetOptions::~SetOptions() {} +SetOptions::~SetOptions() { +} /* static */ SetOptions SetOptions::Merge() { diff --git a/firestore/src/common/settings.cc b/firestore/src/common/settings.cc index d7a8fb73b0..57affb954c 100644 --- a/firestore/src/common/settings.cc +++ b/firestore/src/common/settings.cc @@ -16,7 +16,9 @@ namespace { const char kDefaultHost[] = "firestore.googleapis.com"; -std::string ToStr(bool v) { return v ? "true" : "false"; } +std::string ToStr(bool v) { + return v ? "true" : "false"; +} std::string ToStr(int64_t v) { // TODO(b/163140650): use `std::to_string` (which will make this function @@ -29,12 +31,17 @@ std::string ToStr(int64_t v) { } // namespace #if !defined(__APPLE__) -Settings::Settings() : host_(kDefaultHost) {} +Settings::Settings() : host_(kDefaultHost) { +} #endif -void Settings::set_host(std::string host) { host_ = firebase::Move(host); } +void Settings::set_host(std::string host) { + host_ = firebase::Move(host); +} -void Settings::set_ssl_enabled(bool enabled) { ssl_enabled_ = enabled; } +void Settings::set_ssl_enabled(bool enabled) { + ssl_enabled_ = enabled; +} void Settings::set_persistence_enabled(bool enabled) { persistence_enabled_ = enabled; diff --git a/firestore/src/common/transaction.cc b/firestore/src/common/transaction.cc index be28061c6f..46faf4ce75 100644 --- a/firestore/src/common/transaction.cc +++ b/firestore/src/common/transaction.cc @@ -29,7 +29,8 @@ Transaction::~Transaction() { } void Transaction::Set(const DocumentReference& document, - const MapFieldValue& data, const SetOptions& options) { + const MapFieldValue& data, + const SetOptions& options) { if (!internal_) return; internal_->Set(document, data, options); } diff --git a/firestore/src/common/write_batch.cc b/firestore/src/common/write_batch.cc index 02b503fb9b..ad65a5c4b9 100644 --- a/firestore/src/common/write_batch.cc +++ b/firestore/src/common/write_batch.cc @@ -20,7 +20,8 @@ namespace firestore { using CleanupFnWriteBatch = CleanupFn; -WriteBatch::WriteBatch() {} +WriteBatch::WriteBatch() { +} WriteBatch::WriteBatch(const WriteBatch& value) { if (value.internal_) { diff --git a/firestore/src/include/firebase/firestore/document_reference.h b/firestore/src/include/firebase/firestore/document_reference.h index 4b98673037..385f2101dc 100644 --- a/firestore/src/include/firebase/firestore/document_reference.h +++ b/firestore/src/include/firebase/firestore/document_reference.h @@ -355,7 +355,9 @@ class DocumentReference { * @return true if this DocumentReference is valid, false if this * DocumentReference is invalid. */ - bool is_valid() const { return internal_ != nullptr; } + bool is_valid() const { + return internal_ != nullptr; + } /** * Returns a string representation of this `DocumentReference` for diff --git a/firestore/src/include/firebase/firestore/event_listener.h b/firestore/src/include/firebase/firestore/event_listener.h index bfe5657fde..e813694234 100644 --- a/firestore/src/include/firebase/firestore/event_listener.h +++ b/firestore/src/include/firebase/firestore/event_listener.h @@ -52,7 +52,8 @@ class EventListener { * @param error_message The error message if there was an error. An empty * string otherwise. */ - virtual void OnEvent(const T& value, Error error_code, + virtual void OnEvent(const T& value, + Error error_code, const std::string& error_message) = 0; }; diff --git a/firestore/src/include/firebase/firestore/field_value.h b/firestore/src/include/firebase/firestore/field_value.h index 6718705a87..971b82cee6 100644 --- a/firestore/src/include/firebase/firestore/field_value.h +++ b/firestore/src/include/firebase/firestore/field_value.h @@ -202,41 +202,63 @@ class FieldValue final { Type type() const; /** @brief Gets whether this FieldValue is currently null. */ - bool is_null() const { return type() == Type::kNull; } + bool is_null() const { + return type() == Type::kNull; + } /** @brief Gets whether this FieldValue contains a boolean value. */ - bool is_boolean() const { return type() == Type::kBoolean; } + bool is_boolean() const { + return type() == Type::kBoolean; + } /** @brief Gets whether this FieldValue contains an integer value. */ - bool is_integer() const { return type() == Type::kInteger; } + bool is_integer() const { + return type() == Type::kInteger; + } /** @brief Gets whether this FieldValue contains a double value. */ - bool is_double() const { return type() == Type::kDouble; } + bool is_double() const { + return type() == Type::kDouble; + } /** @brief Gets whether this FieldValue contains a timestamp. */ - bool is_timestamp() const { return type() == Type::kTimestamp; } + bool is_timestamp() const { + return type() == Type::kTimestamp; + } /** @brief Gets whether this FieldValue contains a string. */ - bool is_string() const { return type() == Type::kString; } + bool is_string() const { + return type() == Type::kString; + } /** @brief Gets whether this FieldValue contains a blob. */ - bool is_blob() const { return type() == Type::kBlob; } + bool is_blob() const { + return type() == Type::kBlob; + } /** * @brief Gets whether this FieldValue contains a reference to a document in * the same Firestore. */ - bool is_reference() const { return type() == Type::kReference; } + bool is_reference() const { + return type() == Type::kReference; + } /** @brief Gets whether this FieldValue contains a GeoPoint. */ - bool is_geo_point() const { return type() == Type::kGeoPoint; } + bool is_geo_point() const { + return type() == Type::kGeoPoint; + } /** @brief Gets whether this FieldValue contains an array of FieldValues. */ - bool is_array() const { return type() == Type::kArray; } + bool is_array() const { + return type() == Type::kArray; + } /** @brief Gets whether this FieldValue contains a map of std::string to * FieldValue. */ - bool is_map() const { return type() == Type::kMap; } + bool is_map() const { + return type() == Type::kMap; + } /** @brief Gets the boolean value contained in this FieldValue. */ bool boolean_value() const; @@ -283,7 +305,9 @@ class FieldValue final { * @return `true` if this `FieldValue` is valid, `false` if this `FieldValue` * is invalid. */ - bool is_valid() const { return internal_ != nullptr; } + bool is_valid() const { + return internal_ != nullptr; + } /** @brief Constructs a null. */ static FieldValue Null(); diff --git a/firestore/src/include/firebase/firestore/query_snapshot.h b/firestore/src/include/firebase/firestore/query_snapshot.h index 71718e0854..0103b29b6f 100644 --- a/firestore/src/include/firebase/firestore/query_snapshot.h +++ b/firestore/src/include/firebase/firestore/query_snapshot.h @@ -141,7 +141,9 @@ class QuerySnapshot { * * @return True if there are no documents in the QuerySnapshot. */ - bool empty() const { return size() == 0; } + bool empty() const { + return size() == 0; + } /** * @brief Checks the size of the QuerySnapshot. diff --git a/firestore/src/include/firebase/firestore/settings.h b/firestore/src/include/firebase/firestore/settings.h index 5daa2ec1bb..d67eafd3bb 100644 --- a/firestore/src/include/firebase/firestore/settings.h +++ b/firestore/src/include/firebase/firestore/settings.h @@ -106,20 +106,28 @@ class Settings final { /** * Gets the host of the Firestore backend to connect to. */ - const std::string& host() const { return host_; } + const std::string& host() const { + return host_; + } /** * Returns whether to use SSL when communicating. */ - bool is_ssl_enabled() const { return ssl_enabled_; } + bool is_ssl_enabled() const { + return ssl_enabled_; + } /** * Returns whether to enable local persistent storage. */ - bool is_persistence_enabled() const { return persistence_enabled_; } + bool is_persistence_enabled() const { + return persistence_enabled_; + } /** Returns cache size for on-disk data. */ - int64_t cache_size_bytes() const { return cache_size_bytes_; } + int64_t cache_size_bytes() const { + return cache_size_bytes_; + } /** * Sets the host of the Firestore backend. The default is diff --git a/firestore/src/include/firebase/firestore/snapshot_metadata.h b/firestore/src/include/firebase/firestore/snapshot_metadata.h index e394f5459e..11f3968d3b 100644 --- a/firestore/src/include/firebase/firestore/snapshot_metadata.h +++ b/firestore/src/include/firebase/firestore/snapshot_metadata.h @@ -41,8 +41,8 @@ class SnapshotMetadata final { * @param is_from_cache Whether the snapshot is from cache instead of backend. */ SnapshotMetadata(bool has_pending_writes, bool is_from_cache) - : has_pending_writes_(has_pending_writes), - is_from_cache_(is_from_cache) {} + : has_pending_writes_(has_pending_writes), is_from_cache_(is_from_cache) { + } /** * @brief Copy constructor. @@ -104,7 +104,9 @@ class SnapshotMetadata final { * has_pending_writes() equal to false once the writes have been committed to * the backend. */ - bool has_pending_writes() const { return has_pending_writes_; } + bool has_pending_writes() const { + return has_pending_writes_; + } /** * Returns whether the snapshot was created from cached data. @@ -115,7 +117,9 @@ class SnapshotMetadata final { * with is_from_cache() equal to false once the client has received up-to-date * data from the backend. */ - bool is_from_cache() const { return is_from_cache_; } + bool is_from_cache() const { + return is_from_cache_; + } /** * Returns a string representation of this `SnapshotMetadata` for diff --git a/firestore/src/include/firebase/firestore/transaction.h b/firestore/src/include/firebase/firestore/transaction.h index 5343921994..310328ea2b 100644 --- a/firestore/src/include/firebase/firestore/transaction.h +++ b/firestore/src/include/firebase/firestore/transaction.h @@ -72,7 +72,8 @@ class Transaction { * @param[in] data A map of the fields and values to write to the document. * @param[in] options An object to configure the Set() behavior (optional). */ - virtual void Set(const DocumentReference& document, const MapFieldValue& data, + virtual void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options = SetOptions()); /** @@ -115,7 +116,8 @@ class Transaction { * DocumentSnapshot if there is any error. */ virtual DocumentSnapshot Get(const DocumentReference& document, - Error* error_code, std::string* error_message); + Error* error_code, + std::string* error_message); protected: /** @@ -143,7 +145,8 @@ class Transaction { */ class TransactionFunction { public: - virtual ~TransactionFunction() {} + virtual ~TransactionFunction() { + } /** * Subclass should override this method and put the transaction logic here. diff --git a/firestore/src/jni/array.h b/firestore/src/jni/array.h index 9923b14613..dfe892b2b5 100644 --- a/firestore/src/jni/array.h +++ b/firestore/src/jni/array.h @@ -16,11 +16,16 @@ class Array : public Object { using jni_type = JniType>; Array() = default; - explicit Array(jni_type array) : Object(array) {} + explicit Array(jni_type array) : Object(array) { + } - jni_type get() const override { return static_cast(Object::get()); } + jni_type get() const override { + return static_cast(Object::get()); + } - size_t Size(Env& env) const { return env.GetArrayLength(*this); } + size_t Size(Env& env) const { + return env.GetArrayLength(*this); + } Local Get(Env& env, size_t i) const { return env.GetArrayElement(*this, i); diff --git a/firestore/src/jni/array_list.cc b/firestore/src/jni/array_list.cc index aeb75f4fc2..f9f651ade3 100644 --- a/firestore/src/jni/array_list.cc +++ b/firestore/src/jni/array_list.cc @@ -20,7 +20,9 @@ void ArrayList::Initialize(Loader& loader) { kConstructorWithSize); } -Local ArrayList::Create(Env& env) { return env.New(kConstructor); } +Local ArrayList::Create(Env& env) { + return env.New(kConstructor); +} Local ArrayList::Create(Env& env, size_t size) { return env.New(kConstructorWithSize, size); diff --git a/firestore/src/jni/boolean.cc b/firestore/src/jni/boolean.cc index 72293cee36..386320548a 100644 --- a/firestore/src/jni/boolean.cc +++ b/firestore/src/jni/boolean.cc @@ -22,7 +22,9 @@ void Boolean::Initialize(Loader& loader) { kBooleanValue); } -Class Boolean::GetClass() { return Class(g_clazz); } +Class Boolean::GetClass() { + return Class(g_clazz); +} Local Boolean::Create(Env& env, bool value) { return env.New(kConstructor, value); diff --git a/firestore/src/jni/class.cc b/firestore/src/jni/class.cc index 4a79a9680c..4d11d62043 100644 --- a/firestore/src/jni/class.cc +++ b/firestore/src/jni/class.cc @@ -28,7 +28,9 @@ std::string Class::GetClassName(Env& env, const Object& object) { return util::JObjectClassName(env.get(), object.get()); } -bool Class::IsArray(Env& env) const { return env.Call(*this, kIsArray); } +bool Class::IsArray(Env& env) const { + return env.Call(*this, kIsArray); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/class.h b/firestore/src/jni/class.h index 9892a3839c..528ed4d371 100644 --- a/firestore/src/jni/class.h +++ b/firestore/src/jni/class.h @@ -21,9 +21,12 @@ namespace jni { class Class : public Object { public: Class() = default; - explicit Class(jclass clazz) : Object(clazz) {} + explicit Class(jclass clazz) : Object(clazz) { + } - jclass get() const override { return static_cast(object_); } + jclass get() const override { + return static_cast(object_); + } /** * Returns the name of the class, as returned by the Java `Class.name` method. diff --git a/firestore/src/jni/collection.cc b/firestore/src/jni/collection.cc index a3ca074398..2515ca42a1 100644 --- a/firestore/src/jni/collection.cc +++ b/firestore/src/jni/collection.cc @@ -29,7 +29,9 @@ Local Collection::Iterator(Env& env) { return env.Call(*this, kIterator); } -size_t Collection::Size(Env& env) const { return env.Call(*this, kSize); } +size_t Collection::Size(Env& env) const { + return env.Call(*this, kSize); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/declaration.h b/firestore/src/jni/declaration.h index 88a9f78a5b..0ef16c76c1 100644 --- a/firestore/src/jni/declaration.h +++ b/firestore/src/jni/declaration.h @@ -22,12 +22,18 @@ class ConstructorBase { * the string. The internal method ID should be populated later with a call to * `Loader::Load`. */ - constexpr explicit ConstructorBase(const char* sig) : sig_(sig) {} + constexpr explicit ConstructorBase(const char* sig) : sig_(sig) { + } - ConstructorBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) {} + ConstructorBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) { + } - jclass clazz() const { return clazz_; } - jmethodID id() const { return id_; } + jclass clazz() const { + return clazz_; + } + jmethodID id() const { + return id_; + } private: friend class Loader; @@ -62,11 +68,15 @@ class MethodBase { * to `Loader::Load`. */ constexpr MethodBase(const char* name, const char* sig) - : name_(name), sig_(sig) {} + : name_(name), sig_(sig) { + } - explicit MethodBase(jmethodID id) : id_(id) {} + explicit MethodBase(jmethodID id) : id_(id) { + } - jmethodID id() const { return id_; } + jmethodID id() const { + return id_; + } private: friend class Loader; @@ -102,13 +112,19 @@ class StaticFieldBase { * with a call to `Loader::Load`. */ constexpr StaticFieldBase(const char* name, const char* sig) - : name_(name), sig_(sig) {} + : name_(name), sig_(sig) { + } - explicit StaticFieldBase(jfieldID id) : id_(id) {} + explicit StaticFieldBase(jfieldID id) : id_(id) { + } - jclass clazz() const { return clazz_; } + jclass clazz() const { + return clazz_; + } - jfieldID id() const { return id_; } + jfieldID id() const { + return id_; + } private: friend class Loader; @@ -145,12 +161,18 @@ class StaticMethodBase { * with a call to `Loader::Load`. */ constexpr StaticMethodBase(const char* name, const char* sig) - : name_(name), sig_(sig) {} - - StaticMethodBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) {} - - jclass clazz() const { return clazz_; } - jmethodID id() const { return id_; } + : name_(name), sig_(sig) { + } + + StaticMethodBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) { + } + + jclass clazz() const { + return clazz_; + } + jmethodID id() const { + return id_; + } private: friend class Loader; diff --git a/firestore/src/jni/double.cc b/firestore/src/jni/double.cc index 4bfd0e1c3f..0e95e53076 100644 --- a/firestore/src/jni/double.cc +++ b/firestore/src/jni/double.cc @@ -21,7 +21,9 @@ void Double::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kDoubleValue); } -Class Double::GetClass() { return Class(g_clazz); } +Class Double::GetClass() { + return Class(g_clazz); +} Local Double::Create(Env& env, double value) { return env.New(kConstructor, value); diff --git a/firestore/src/jni/env.cc b/firestore/src/jni/env.cc index 0a0b0ce8e5..bea2ac6ff2 100644 --- a/firestore/src/jni/env.cc +++ b/firestore/src/jni/env.cc @@ -37,10 +37,12 @@ int CurrentExceptionCount() { } // namespace -Env::Env() : Env(GetEnv()) {} +Env::Env() : Env(GetEnv()) { +} Env::Env(JNIEnv* env) - : env_(env), initial_pending_exceptions_(CurrentExceptionCount()) {} + : env_(env), initial_pending_exceptions_(CurrentExceptionCount()) { +} Env::~Env() noexcept(false) { if (ok()) return; @@ -87,7 +89,9 @@ Local Env::ExceptionOccurred() { return Local(env_, exception); } -void Env::ExceptionClear() { env_->ExceptionClear(); } +void Env::ExceptionClear() { + env_->ExceptionClear(); +} Local Env::ClearExceptionOccurred() { Local result = ExceptionOccurred(); @@ -119,7 +123,8 @@ bool Env::IsSameObject(const Object& object1, const Object& object2) { return result; } -jmethodID Env::GetMethodId(const Class& clazz, const char* name, +jmethodID Env::GetMethodId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; @@ -128,7 +133,8 @@ jmethodID Env::GetMethodId(const Class& clazz, const char* name, return result; } -jfieldID Env::GetStaticFieldId(const Class& clazz, const char* name, +jfieldID Env::GetStaticFieldId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; @@ -137,7 +143,8 @@ jfieldID Env::GetStaticFieldId(const Class& clazz, const char* name, return result; } -jmethodID Env::GetStaticMethodId(const Class& clazz, const char* name, +jmethodID Env::GetStaticMethodId(const Class& clazz, + const char* name, const char* sig) { if (!ok()) return nullptr; diff --git a/firestore/src/jni/env.h b/firestore/src/jni/env.h index b93c035aaa..331a42a758 100644 --- a/firestore/src/jni/env.h +++ b/firestore/src/jni/env.h @@ -75,10 +75,14 @@ class Env { Env& operator=(Env&&) noexcept = default; /** Returns true if the Env has not encountered an exception. */ - bool ok() const { return !env_->ExceptionCheck(); } + bool ok() const { + return !env_->ExceptionCheck(); + } /** Returns the underlying JNIEnv pointer. */ - JNIEnv* get() const { return env_; } + JNIEnv* get() const { + return env_; + } // MARK: Class Operations @@ -207,7 +211,8 @@ class Env { } template - ResultType Call(const Object& object, const Method& method, + ResultType Call(const Object& object, + const Method& method, Args&&... args) { auto env_method = CallTraits>::kCall; return CallHelper(env_method, object.get(), method.id(), @@ -225,7 +230,8 @@ class Env { // MARK: Accessing Static Fields - jfieldID GetStaticFieldId(const Class& clazz, const char* name, + jfieldID GetStaticFieldId(const Class& clazz, + const char* name, const char* sig); /** @@ -263,7 +269,8 @@ class Env { * Finds the method on the given class that's associated with the method name * and signature. */ - jmethodID GetStaticMethodId(const Class& clazz, const char* name, + jmethodID GetStaticMethodId(const Class& clazz, + const char* name, const char* sig); /** @@ -280,7 +287,8 @@ class Env { * or a local reference to the returned object. */ template - ResultType CallStatic(const Class& clazz, jmethodID method, + ResultType CallStatic(const Class& clazz, + jmethodID method, Args&&... args) { auto env_method = CallTraits>::kCallStatic; return CallHelper(env_method, clazz.get(), method, @@ -397,7 +405,8 @@ class Env { * Sets the value at the given index in the Java object array. */ template - EnableForReference SetArrayElement(Array& array, size_t index, + EnableForReference SetArrayElement(Array& array, + size_t index, const Object& value) { if (!ok()) return; @@ -412,7 +421,8 @@ class Env { */ template EnableForPrimitive GetArrayRegion(const Array& array, - size_t start, size_t len, + size_t start, + size_t len, T* buffer) { if (!ok()) return; @@ -440,8 +450,10 @@ class Env { * elements. */ template - EnableForPrimitive SetArrayRegion(Array& array, size_t start, - size_t len, const T* buffer) { + EnableForPrimitive SetArrayRegion(Array& array, + size_t start, + size_t len, + const T* buffer) { if (!ok()) return; auto env_method = CallTraits>::kSetArrayRegion; @@ -533,7 +545,8 @@ class Env { class ExceptionClearGuard { public: explicit ExceptionClearGuard(Env& env) - : env_(env), exception_(env.ClearExceptionOccurred()) {} + : env_(env), exception_(env.ClearExceptionOccurred()) { + } ~ExceptionClearGuard() { if (exception_) { diff --git a/firestore/src/jni/hash_map.cc b/firestore/src/jni/hash_map.cc index 8fb06f1de7..6221efde61 100644 --- a/firestore/src/jni/hash_map.cc +++ b/firestore/src/jni/hash_map.cc @@ -19,7 +19,9 @@ void HashMap::Initialize(Loader& loader) { kConstructor); } -Local HashMap::Create(Env& env) { return env.New(kConstructor); } +Local HashMap::Create(Env& env) { + return env.New(kConstructor); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/integer.cc b/firestore/src/jni/integer.cc index 34ad7cb810..8f0f9a538f 100644 --- a/firestore/src/jni/integer.cc +++ b/firestore/src/jni/integer.cc @@ -21,13 +21,17 @@ void Integer::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kIntValue); } -Class Integer::GetClass() { return Class(g_clazz); } +Class Integer::GetClass() { + return Class(g_clazz); +} Local Integer::Create(Env& env, int32_t value) { return env.New(kConstructor, value); } -int32_t Integer::IntValue(Env& env) const { return env.Call(*this, kIntValue); } +int32_t Integer::IntValue(Env& env) const { + return env.Call(*this, kIntValue); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/iterator.cc b/firestore/src/jni/iterator.cc index e0d63b0955..d24e27b67c 100644 --- a/firestore/src/jni/iterator.cc +++ b/firestore/src/jni/iterator.cc @@ -20,9 +20,13 @@ void Iterator::Initialize(Loader& loader) { kNext); } -bool Iterator::HasNext(Env& env) const { return env.Call(*this, kHasNext); } +bool Iterator::HasNext(Env& env) const { + return env.Call(*this, kHasNext); +} -Local Iterator::Next(Env& env) { return env.Call(*this, kNext); } +Local Iterator::Next(Env& env) { + return env.Call(*this, kNext); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/jni.cc b/firestore/src/jni/jni.cc index 6f070c9921..9b14f5e3ee 100644 --- a/firestore/src/jni/jni.cc +++ b/firestore/src/jni/jni.cc @@ -17,7 +17,9 @@ JavaVM* g_jvm = nullptr; * Reinterprets `JNIEnv**` out parameters to `void**` on platforms where that's * required. */ -void** EnvOut(JNIEnv** env) { return reinterpret_cast(env); } +void** EnvOut(JNIEnv** env) { + return reinterpret_cast(env); +} JavaVM* GetGlobalJavaVM() { // TODO(mcg): Use dlsym to call JNI_GetCreatedJavaVMs. diff --git a/firestore/src/jni/list.cc b/firestore/src/jni/list.cc index b4de125fb3..d94fefba76 100644 --- a/firestore/src/jni/list.cc +++ b/firestore/src/jni/list.cc @@ -20,7 +20,9 @@ void List::Initialize(Loader& loader) { loader.LoadFromExistingClass("java/util/List", g_clazz, kGet, kSet); } -Class List::GetClass() { return Class(g_clazz); } +Class List::GetClass() { + return Class(g_clazz); +} Local List::Get(Env& env, size_t i) const { return env.Call(*this, kGet, i); diff --git a/firestore/src/jni/loader.cc b/firestore/src/jni/loader.cc index e34952080e..f6715b2330 100644 --- a/firestore/src/jni/loader.cc +++ b/firestore/src/jni/loader.cc @@ -24,9 +24,12 @@ Loader::Loader(App* app) : app_(app), env_(app->GetJNIEnv()) { Class::Initialize(*this); } -Loader::~Loader() { Unload(); } +Loader::~Loader() { + Unload(); +} -void Loader::AddEmbeddedFile(const char* name, const unsigned char* data, +void Loader::AddEmbeddedFile(const char* name, + const unsigned char* data, size_t size) { #if defined(_STLPORT_VERSION) embedded_files_.push_back(EmbeddedFile(name, data, size)); diff --git a/firestore/src/jni/loader.h b/firestore/src/jni/loader.h index cf194a16c3..fecdb07e8e 100644 --- a/firestore/src/jni/loader.h +++ b/firestore/src/jni/loader.h @@ -44,12 +44,15 @@ class Loader { * Returns true if the loader has succeeded. If not, any errors have already * been logged. */ - bool ok() const { return ok_ && !env_->ExceptionCheck(); } + bool ok() const { + return ok_ && !env_->ExceptionCheck(); + } /** * Adds metadata about embedded class files in the binary distribution. */ - void AddEmbeddedFile(const char* name, const unsigned char* data, + void AddEmbeddedFile(const char* name, + const unsigned char* data, size_t size); /** * Unpacks any embedded files added above and writes them out to a temporary @@ -82,7 +85,8 @@ class Loader { * param existing_ref An existing local or global reference to a Java class. */ template - void LoadFromExistingClass(const char* class_name, jclass existing_ref, + void LoadFromExistingClass(const char* class_name, + jclass existing_ref, Members&&... members) { UsingExistingClass(class_name, existing_ref); LoadAll(Forward(members)...); @@ -132,7 +136,8 @@ class Loader { Load(Forward(first)); LoadAll(Forward(rest)...); } - void LoadAll() {} + void LoadAll() { + } /** * Registers the given native methods with the JVM. diff --git a/firestore/src/jni/long.cc b/firestore/src/jni/long.cc index dbe8865847..2858263014 100644 --- a/firestore/src/jni/long.cc +++ b/firestore/src/jni/long.cc @@ -21,13 +21,17 @@ void Long::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kLongValue); } -Class Long::GetClass() { return Class(g_clazz); } +Class Long::GetClass() { + return Class(g_clazz); +} Local Long::Create(Env& env, int64_t value) { return env.New(kConstructor, value); } -int64_t Long::LongValue(Env& env) const { return env.Call(*this, kLongValue); } +int64_t Long::LongValue(Env& env) const { + return env.Call(*this, kLongValue); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/map.cc b/firestore/src/jni/map.cc index ddc8be22ee..8f6281e7ed 100644 --- a/firestore/src/jni/map.cc +++ b/firestore/src/jni/map.cc @@ -26,9 +26,13 @@ void Map::Initialize(Loader& loader) { kRemove, kKeySet); } -Class Map::GetClass() { return Class(g_clazz); } +Class Map::GetClass() { + return Class(g_clazz); +} -size_t Map::Size(Env& env) const { return env.Call(*this, kSize); } +size_t Map::Size(Env& env) const { + return env.Call(*this, kSize); +} Local Map::Get(Env& env, const Object& key) { return env.Call(*this, kGet, key); @@ -42,7 +46,9 @@ Local Map::Remove(Env& env, const Object& key) { return env.Call(*this, kRemove, key); } -Local Map::KeySet(Env& env) { return env.Call(*this, kKeySet); } +Local Map::KeySet(Env& env) { + return env.Call(*this, kKeySet); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/object.cc b/firestore/src/jni/object.cc index 0e7f961fcd..5ff301aa13 100644 --- a/firestore/src/jni/object.cc +++ b/firestore/src/jni/object.cc @@ -22,7 +22,9 @@ void Object::Initialize(Loader& loader) { kToString); } -Class Object::GetClass() { return Class(object_class); } +Class Object::GetClass() { + return Class(object_class); +} std::string Object::ToString(Env& env) const { Local java_string = env.Call(*this, kToString); diff --git a/firestore/src/jni/object.h b/firestore/src/jni/object.h index f5735dc332..c2f1eeac7d 100644 --- a/firestore/src/jni/object.h +++ b/firestore/src/jni/object.h @@ -25,12 +25,17 @@ class Loader; class Object { public: Object() = default; - constexpr explicit Object(jobject object) : object_(object) {} + constexpr explicit Object(jobject object) : object_(object) { + } virtual ~Object() = default; - explicit operator bool() const { return object_ != nullptr; } + explicit operator bool() const { + return object_ != nullptr; + } - virtual jobject get() const { return object_; } + virtual jobject get() const { + return object_; + } static void Initialize(Loader& loader); diff --git a/firestore/src/jni/ownership.h b/firestore/src/jni/ownership.h index e7ff211a27..8b1037e101 100644 --- a/firestore/src/jni/ownership.h +++ b/firestore/src/jni/ownership.h @@ -29,7 +29,8 @@ class Local : public T { /** * Adopts a local reference that is the result of a JNI invocation. */ - Local(JNIEnv* env, jni_type value) : T(value), env_(env) {} + Local(JNIEnv* env, jni_type value) : T(value), env_(env) { + } /** * An explicit copy constructor, which prevents accidental copies at function @@ -53,7 +54,8 @@ class Local : public T { return *this; } - Local(Local&& other) noexcept : T(other.release()), env_(other.env_) {} + Local(Local&& other) noexcept : T(other.release()), env_(other.env_) { + } Local& operator=(Local&& other) noexcept { if (T::object_ != other.get()) { @@ -112,7 +114,9 @@ class Local : public T { return Local(env_, release()); } - jni_type get() const override { return static_cast(T::object_); } + jni_type get() const override { + return static_cast(T::object_); + } jni_type release() { jobject result = T::object_; @@ -127,7 +131,9 @@ class Local : public T { } } - JNIEnv* env() const { return env_; } + JNIEnv* env() const { + return env_; + } private: void EnsureEnv(JNIEnv* other = nullptr) { @@ -166,7 +172,8 @@ class Global : public T { Global() = default; - Global(jni_type object, AdoptExisting) : T(object) {} + Global(jni_type object, AdoptExisting) : T(object) { + } Global(const Local& other) { JNIEnv* env = EnsureEnv(other.env()); @@ -200,14 +207,16 @@ class Global : public T { // Without this, the implicitly-defined copy constructor would be deleted, and // during overload resolution the deleted copy constructor would take priority // over the looser match above that takes `const T&`. - Global(const Global& other) : Global(static_cast(other)) {} + Global(const Global& other) : Global(static_cast(other)) { + } Global& operator=(const Global& other) { *this = static_cast(other); return *this; } - Global(Global&& other) noexcept : T(other.release()) {} + Global(Global&& other) noexcept : T(other.release()) { + } Global& operator=(Global&& other) noexcept { if (T::object_ != other.get()) { @@ -241,7 +250,9 @@ class Global : public T { } } - jni_type get() const override { return static_cast(T::object_); } + jni_type get() const override { + return static_cast(T::object_); + } jni_type release() { jobject result = T::object_; diff --git a/firestore/src/jni/string.cc b/firestore/src/jni/string.cc index 83b8b60767..6253858a75 100644 --- a/firestore/src/jni/string.cc +++ b/firestore/src/jni/string.cc @@ -40,11 +40,16 @@ void String::Terminate(Env& env) { } } -Class String::GetClass() { return Class(string_class); } +Class String::GetClass() { + return Class(string_class); +} -String String::GetUtf8() { return String(utf8_string); } +String String::GetUtf8() { + return String(utf8_string); +} -Local String::Create(Env& env, const Array& bytes, +Local String::Create(Env& env, + const Array& bytes, const String& encoding) { return env.New(kNewFromBytes, bytes, encoding); } @@ -53,7 +58,9 @@ Local> String::GetBytes(Env& env, const String& encoding) const { return env.Call(*this, kGetBytes, encoding); } -std::string String::ToString(Env& env) const { return env.ToStringUtf(*this); } +std::string String::ToString(Env& env) const { + return env.ToStringUtf(*this); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/string.h b/firestore/src/jni/string.h index 80c6b9b40b..8368e09865 100644 --- a/firestore/src/jni/string.h +++ b/firestore/src/jni/string.h @@ -20,7 +20,8 @@ class Class; class String : public Object { public: String() = default; - explicit String(jstring string) : Object(string) {} + explicit String(jstring string) : Object(string) { + } /** * Creates a new Java String from the given bytes, using the given encoding. @@ -29,10 +30,13 @@ class String : public Object { * @param bytes A Java array of encoded bytes. * @param encoding A Java string naming the encoding of the bytes. */ - static Local Create(Env& env, const Array& bytes, + static Local Create(Env& env, + const Array& bytes, const String& encoding); - jstring get() const override { return static_cast(object_); } + jstring get() const override { + return static_cast(object_); + } static void Initialize(Env& env, Loader& loader); static void Terminate(Env& env); diff --git a/firestore/src/jni/task.cc b/firestore/src/jni/task.cc index 6608c11432..57e8137d64 100644 --- a/firestore/src/jni/task.cc +++ b/firestore/src/jni/task.cc @@ -32,13 +32,17 @@ Local Task::GetException(Env& env) const { return env.Call(*this, kGetException); } -bool Task::IsComplete(Env& env) const { return env.Call(*this, kIsComplete); } +bool Task::IsComplete(Env& env) const { + return env.Call(*this, kIsComplete); +} bool Task::IsSuccessful(Env& env) const { return env.Call(*this, kIsSuccessful); } -bool Task::IsCanceled(Env& env) const { return env.Call(*this, kIsCanceled); } +bool Task::IsCanceled(Env& env) const { + return env.Call(*this, kIsCanceled); +} } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/throwable.h b/firestore/src/jni/throwable.h index 98091f2fb5..56b7ff0be3 100644 --- a/firestore/src/jni/throwable.h +++ b/firestore/src/jni/throwable.h @@ -18,9 +18,12 @@ namespace jni { class Throwable : public Object { public: Throwable() = default; - explicit Throwable(jthrowable throwable) : Object(throwable) {} + explicit Throwable(jthrowable throwable) : Object(throwable) { + } - jthrowable get() const override { return static_cast(object_); } + jthrowable get() const override { + return static_cast(object_); + } /** * Gets the message associated with this throwable. diff --git a/firestore/src/jni/traits.h b/firestore/src/jni/traits.h index de05698d74..83be3693e5 100644 --- a/firestore/src/jni/traits.h +++ b/firestore/src/jni/traits.h @@ -191,7 +191,9 @@ using nullptr_t = decltype(nullptr); using nullptr_t = std::nullptr_t; #endif -inline jobject RankedToJni(nullptr_t, ConverterChoice<2>) { return nullptr; } +inline jobject RankedToJni(nullptr_t, ConverterChoice<2>) { + return nullptr; +} /** * Converts wrapper types to JNI references by unwrapping them. diff --git a/firestore/src/main/collection_reference_main.cc b/firestore/src/main/collection_reference_main.cc index b4ba34d57b..543f118a94 100644 --- a/firestore/src/main/collection_reference_main.cc +++ b/firestore/src/main/collection_reference_main.cc @@ -16,7 +16,8 @@ using core::ParsedSetData; CollectionReferenceInternal::CollectionReferenceInternal( api::CollectionReference&& collection) - : QueryInternal{std::move(collection)} {} + : QueryInternal{std::move(collection)} { +} const api::CollectionReference& CollectionReferenceInternal::collection_core_api() const { diff --git a/firestore/src/main/converter_main.h b/firestore/src/main/converter_main.h index ab869f8767..de8d6e3b0e 100644 --- a/firestore/src/main/converter_main.h +++ b/firestore/src/main/converter_main.h @@ -45,8 +45,10 @@ struct ConverterImpl { return PublicT{internal}; } - template , typename... Args> + template , + typename... Args> static PublicT MakePublicFromCore(CoreT&& from, Args... args) { auto* internal = new InternalT(std::move(from), std::move(args)...); return PublicT{internal}; diff --git a/firestore/src/main/credentials_provider_desktop.h b/firestore/src/main/credentials_provider_desktop.h index 35d743a7a3..03074f6b49 100644 --- a/firestore/src/main/credentials_provider_desktop.h +++ b/firestore/src/main/credentials_provider_desktop.h @@ -59,7 +59,8 @@ class FirebaseCppCredentialsProvider // the `GetToken` callback might be invoked after this credentials provider // has already been destroyed (Auth may outlive Firestore). struct Contents { - explicit Contents(App& app) : app(app) {} + explicit Contents(App& app) : app(app) { + } // FirebaseCppCredentialsProvider may be used by more than one thread. The // mutex is locked in all public member functions and none of the private diff --git a/firestore/src/main/document_change_main.cc b/firestore/src/main/document_change_main.cc index 58700c6b0a..3a61a42762 100644 --- a/firestore/src/main/document_change_main.cc +++ b/firestore/src/main/document_change_main.cc @@ -14,7 +14,8 @@ namespace firestore { using Type = DocumentChange::Type; DocumentChangeInternal::DocumentChangeInternal(api::DocumentChange&& change) - : change_{std::move(change)} {} + : change_{std::move(change)} { +} FirestoreInternal* DocumentChangeInternal::firestore_internal() { return GetFirestoreInternal(&change_); diff --git a/firestore/src/main/document_reference_main.cc b/firestore/src/main/document_reference_main.cc index 9532693e9a..5c69faa918 100644 --- a/firestore/src/main/document_reference_main.cc +++ b/firestore/src/main/document_reference_main.cc @@ -21,7 +21,8 @@ DocumentReferenceInternal::DocumentReferenceInternal( api::DocumentReference&& reference) : reference_{std::move(reference)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} {} + user_data_converter_{&firestore_internal()->database_id()} { +} Firestore* DocumentReferenceInternal::firestore() { return GetFirestore(&reference_); diff --git a/firestore/src/main/document_reference_main.h b/firestore/src/main/document_reference_main.h index bf2e71bafb..351c443013 100644 --- a/firestore/src/main/document_reference_main.h +++ b/firestore/src/main/document_reference_main.h @@ -31,9 +31,15 @@ class DocumentReferenceInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - const std::string& id() const { return reference_.document_id(); } - std::string path() const { return reference_.Path(); } - const model::DocumentKey& key() const { return reference_.key(); } + const std::string& id() const { + return reference_.document_id(); + } + std::string path() const { + return reference_.Path(); + } + const model::DocumentKey& key() const { + return reference_.key(); + } CollectionReference Parent(); CollectionReference Collection(const std::string& collection_path); diff --git a/firestore/src/main/document_snapshot_main.cc b/firestore/src/main/document_snapshot_main.cc index 084542cef2..5ff26de28a 100644 --- a/firestore/src/main/document_snapshot_main.cc +++ b/firestore/src/main/document_snapshot_main.cc @@ -23,7 +23,8 @@ using model::DocumentKey; DocumentSnapshotInternal::DocumentSnapshotInternal( api::DocumentSnapshot&& snapshot) - : snapshot_{std::move(snapshot)} {} + : snapshot_{std::move(snapshot)} { +} Firestore* DocumentSnapshotInternal::firestore() { return GetFirestore(&snapshot_); @@ -50,7 +51,9 @@ SnapshotMetadata DocumentSnapshotInternal::metadata() const { return SnapshotMetadata{result.pending_writes(), result.from_cache()}; } -bool DocumentSnapshotInternal::exists() const { return snapshot_.exists(); } +bool DocumentSnapshotInternal::exists() const { + return snapshot_.exists(); +} MapFieldValue DocumentSnapshotInternal::GetData( ServerTimestampBehavior stb) const { diff --git a/firestore/src/main/field_value_main.cc b/firestore/src/main/field_value_main.cc index f09530d73d..38680d3929 100644 --- a/firestore/src/main/field_value_main.cc +++ b/firestore/src/main/field_value_main.cc @@ -22,37 +22,46 @@ using Type = FieldValue::Type; // Constructors FieldValueInternal::FieldValueInternal(bool value) - : type_{Type::kBoolean}, value_{model::FieldValue::FromBoolean(value)} {} + : type_{Type::kBoolean}, value_{model::FieldValue::FromBoolean(value)} { +} FieldValueInternal::FieldValueInternal(int64_t value) - : type_{Type::kInteger}, value_{model::FieldValue::FromInteger(value)} {} + : type_{Type::kInteger}, value_{model::FieldValue::FromInteger(value)} { +} FieldValueInternal::FieldValueInternal(double value) - : type_{Type::kDouble}, value_{model::FieldValue::FromDouble(value)} {} + : type_{Type::kDouble}, value_{model::FieldValue::FromDouble(value)} { +} FieldValueInternal::FieldValueInternal(Timestamp value) - : type_{Type::kTimestamp}, - value_{model::FieldValue::FromTimestamp(value)} {} + : type_{Type::kTimestamp}, value_{model::FieldValue::FromTimestamp(value)} { +} FieldValueInternal::FieldValueInternal(std::string value) : type_{Type::kString}, - value_{model::FieldValue::FromString(std::move(value))} {} + value_{model::FieldValue::FromString(std::move(value))} { +} FieldValueInternal::FieldValueInternal(const uint8_t* value, size_t size) : type_{Type::kBlob}, - value_{model::FieldValue::FromBlob(ByteString{value, size})} {} + value_{model::FieldValue::FromBlob(ByteString{value, size})} { +} FieldValueInternal::FieldValueInternal(DocumentReference value) - : type_{Type::kReference}, value_{std::move(value)} {} + : type_{Type::kReference}, value_{std::move(value)} { +} FieldValueInternal::FieldValueInternal(GeoPoint value) - : type_{Type::kGeoPoint}, value_{model::FieldValue::FromGeoPoint(value)} {} + : type_{Type::kGeoPoint}, value_{model::FieldValue::FromGeoPoint(value)} { +} FieldValueInternal::FieldValueInternal(std::vector value) - : type_{Type::kArray}, value_{std::move(value)} {} + : type_{Type::kArray}, value_{std::move(value)} { +} FieldValueInternal::FieldValueInternal(MapFieldValue value) - : type_{Type::kMap}, value_{std::move(value)} {} + : type_{Type::kMap}, value_{std::move(value)} { +} // Accessors diff --git a/firestore/src/main/field_value_main.h b/firestore/src/main/field_value_main.h index 93b52e9faa..0461b466e3 100644 --- a/firestore/src/main/field_value_main.h +++ b/firestore/src/main/field_value_main.h @@ -32,7 +32,9 @@ class FieldValueInternal { explicit FieldValueInternal(std::vector value); explicit FieldValueInternal(MapFieldValue value); - FieldValue::Type type() const { return type_; } + FieldValue::Type type() const { + return type_; + } bool boolean_value() const; int64_t integer_value() const; @@ -68,7 +70,8 @@ class FieldValueInternal { template explicit FieldValueInternal(FieldValue::Type type, T value) - : type_{type}, value_{std::move(value)} {} + : type_{type}, value_{std::move(value)} { + } FieldValue::Type type_ = FieldValue::Type::kNull; // Note: it's impossible to roundtrip between a `DocumentReference` and diff --git a/firestore/src/main/listener_registration_main.cc b/firestore/src/main/listener_registration_main.cc index c8d3bfdcd1..8ce9cce6c2 100644 --- a/firestore/src/main/listener_registration_main.cc +++ b/firestore/src/main/listener_registration_main.cc @@ -14,7 +14,9 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( firestore->RegisterListenerRegistration(this); } -ListenerRegistrationInternal::~ListenerRegistrationInternal() { Remove(); } +ListenerRegistrationInternal::~ListenerRegistrationInternal() { + Remove(); +} } // namespace firestore } // namespace firebase diff --git a/firestore/src/main/listener_registration_main.h b/firestore/src/main/listener_registration_main.h index a3e904dc54..d9350e98df 100644 --- a/firestore/src/main/listener_registration_main.h +++ b/firestore/src/main/listener_registration_main.h @@ -20,12 +20,16 @@ class ListenerRegistrationInternal { ListenerRegistrationInternal& operator=(const ListenerRegistrationInternal&) = delete; - FirestoreInternal* firestore_internal() { return firestore_; } + FirestoreInternal* firestore_internal() { + return firestore_; + } private: friend class FirestoreInternal; - void Remove() { registration_->Remove(); } + void Remove() { + registration_->Remove(); + } std::unique_ptr registration_; FirestoreInternal* firestore_ = nullptr; diff --git a/firestore/src/main/promise_factory_main.h b/firestore/src/main/promise_factory_main.h index 4ca6108a84..6cc4125905 100644 --- a/firestore/src/main/promise_factory_main.h +++ b/firestore/src/main/promise_factory_main.h @@ -34,7 +34,9 @@ class PromiseFactory { future_manager_->AllocFutureApi(this, ApisCount()); } - ~PromiseFactory() { future_manager_->ReleaseFutureApi(this); } + ~PromiseFactory() { + future_manager_->ReleaseFutureApi(this); + } PromiseFactory(const PromiseFactory& rhs) : cleanup_{rhs.cleanup_}, future_manager_{rhs.future_manager_} { @@ -59,7 +61,9 @@ class PromiseFactory { return future_manager_->GetFutureApi(this); } - int ApisCount() const { return static_cast(ApiEnum::kCount); } + int ApisCount() const { + return static_cast(ApiEnum::kCount); + } CleanupNotifier* cleanup_ = nullptr; FutureManager* future_manager_ = nullptr; diff --git a/firestore/src/main/promise_main.h b/firestore/src/main/promise_main.h index 8d08e9348f..51a12bd6bf 100644 --- a/firestore/src/main/promise_main.h +++ b/firestore/src/main/promise_main.h @@ -30,7 +30,8 @@ template class Promise { public: // Creates a future backed by `LastResults` cache. - Promise(CleanupNotifier* cleanup, ReferenceCountedFutureImpl* future_api, + Promise(CleanupNotifier* cleanup, + ReferenceCountedFutureImpl* future_api, int identifier) : cleanup_{NOT_NULL(cleanup)}, future_api_{NOT_NULL(future_api)}, @@ -146,7 +147,9 @@ class Promise { private: Promise() = default; - int NoError() const { return static_cast(Error::kErrorOk); } + int NoError() const { + return static_cast(Error::kErrorOk); + } void Reset() { cleanup_ = nullptr; @@ -186,7 +189,9 @@ class Promise { cleanup_->UnregisterObject(this); } - bool IsCleanedUp() const { return cleanup_ == nullptr; } + bool IsCleanedUp() const { + return cleanup_ == nullptr; + } CleanupNotifier* cleanup_ = nullptr; ReferenceCountedFutureImpl* future_api_ = nullptr; diff --git a/firestore/src/main/query_main.cc b/firestore/src/main/query_main.cc index bdd0aabc6b..1b0665bfd9 100644 --- a/firestore/src/main/query_main.cc +++ b/firestore/src/main/query_main.cc @@ -31,9 +31,12 @@ using model::ResourcePath; QueryInternal::QueryInternal(api::Query&& query) : query_{std::move(query)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} {} + user_data_converter_{&firestore_internal()->database_id()} { +} -Firestore* QueryInternal::firestore() { return GetFirestore(&query_); } +Firestore* QueryInternal::firestore() { + return GetFirestore(&query_); +} FirestoreInternal* QueryInternal::firestore_internal() { return GetFirestoreInternal(&query_); @@ -65,7 +68,8 @@ Future QueryInternal::Get(Source source) { return promise.future(); } -Query QueryInternal::Where(const FieldPath& field_path, Operator op, +Query QueryInternal::Where(const FieldPath& field_path, + Operator op, const FieldValue& value) const { const model::FieldPath& path = GetInternal(field_path); model::FieldValue parsed = user_data_converter_.ParseQueryValue(value); @@ -75,7 +79,8 @@ Query QueryInternal::Where(const FieldPath& field_path, Operator op, return MakePublic(std::move(decorated)); } -Query QueryInternal::Where(const FieldPath& field_path, Operator op, +Query QueryInternal::Where(const FieldPath& field_path, + Operator op, const std::vector& values) const { const model::FieldPath& path = GetInternal(field_path); auto array_value = FieldValue::Array(values); diff --git a/firestore/src/main/query_main.h b/firestore/src/main/query_main.h index 2a4d4d0b41..558de84c5b 100644 --- a/firestore/src/main/query_main.h +++ b/firestore/src/main/query_main.h @@ -146,9 +146,15 @@ class QueryInternal { kCount, }; - const api::Query& query_core_api() const { return query_; } - const UserDataConverter& converter() const { return user_data_converter_; } - PromiseFactory& promise_factory() { return promise_factory_; } + const api::Query& query_core_api() const { + return query_; + } + const UserDataConverter& converter() const { + return user_data_converter_; + } + PromiseFactory& promise_factory() { + return promise_factory_; + } private: enum class BoundPosition { @@ -160,9 +166,11 @@ class QueryInternal { using Operator = core::Filter::Operator; - Query Where(const FieldPath& field, Operator op, + Query Where(const FieldPath& field, + Operator op, const FieldValue& value) const; - Query Where(const FieldPath& field, Operator op, + Query Where(const FieldPath& field, + Operator op, const std::vector& values) const; Query WithBound(BoundPosition bound_pos, diff --git a/firestore/src/main/query_snapshot_main.cc b/firestore/src/main/query_snapshot_main.cc index 1fac6da602..51240a83dd 100644 --- a/firestore/src/main/query_snapshot_main.cc +++ b/firestore/src/main/query_snapshot_main.cc @@ -12,7 +12,8 @@ namespace firebase { namespace firestore { QuerySnapshotInternal::QuerySnapshotInternal(api::QuerySnapshot&& snapshot) - : snapshot_{std::move(snapshot)} {} + : snapshot_{std::move(snapshot)} { +} FirestoreInternal* QuerySnapshotInternal::firestore_internal() { return GetFirestoreInternal(&snapshot_); @@ -27,7 +28,9 @@ SnapshotMetadata QuerySnapshotInternal::metadata() const { return SnapshotMetadata{result.pending_writes(), result.from_cache()}; } -std::size_t QuerySnapshotInternal::size() const { return snapshot_.size(); } +std::size_t QuerySnapshotInternal::size() const { + return snapshot_.size(); +} std::vector QuerySnapshotInternal::DocumentChanges( MetadataChanges metadata_changes) const { diff --git a/firestore/src/main/set_options_main.h b/firestore/src/main/set_options_main.h index 95460d3d93..0baa18b3c3 100644 --- a/firestore/src/main/set_options_main.h +++ b/firestore/src/main/set_options_main.h @@ -18,10 +18,15 @@ class SetOptionsInternal { using Type = SetOptions::Type; explicit SetOptionsInternal(SetOptions options) - : options_{std::move(options)} {} - - Type type() const { return options_.type_; } - const std::vector& field_mask() const { return options_.fields_; } + : options_{std::move(options)} { + } + + Type type() const { + return options_.type_; + } + const std::vector& field_mask() const { + return options_.fields_; + } private: SetOptions options_; diff --git a/firestore/src/main/transaction_main.cc b/firestore/src/main/transaction_main.cc index b6e61af5f1..11acfbcf8d 100644 --- a/firestore/src/main/transaction_main.cc +++ b/firestore/src/main/transaction_main.cc @@ -35,7 +35,8 @@ const model::DocumentKey& GetKey(const DocumentReference& document) { } DocumentSnapshot ConvertToSingleSnapshot( - const std::shared_ptr& firestore, model::DocumentKey key, + const std::shared_ptr& firestore, + model::DocumentKey key, const std::vector& documents) { SIMPLE_HARD_ASSERT( documents.size() == 1, @@ -77,7 +78,8 @@ TransactionInternal::TransactionInternal( FirestoreInternal* firestore_internal) : transaction_{std::move(NOT_NULL(transaction))}, firestore_internal_{NOT_NULL(firestore_internal)}, - user_data_converter_{&firestore_internal->database_id()} {} + user_data_converter_{&firestore_internal->database_id()} { +} Firestore* TransactionInternal::firestore() { return Firestore::GetInstance(firestore_internal_->app()); diff --git a/firestore/src/main/transaction_main.h b/firestore/src/main/transaction_main.h index 3ae676eef9..a59aacf4f7 100644 --- a/firestore/src/main/transaction_main.h +++ b/firestore/src/main/transaction_main.h @@ -24,7 +24,8 @@ class TransactionInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options); void Update(const DocumentReference& document, const MapFieldValue& data); @@ -32,7 +33,8 @@ class TransactionInternal { void Delete(const DocumentReference& document); - DocumentSnapshot Get(const DocumentReference& document, Error* error_code, + DocumentSnapshot Get(const DocumentReference& document, + Error* error_code, std::string* error_message); void MarkPermanentlyFailed(); diff --git a/firestore/src/main/user_data_converter_main.cc b/firestore/src/main/user_data_converter_main.cc index 677bd4771f..f507bb8d68 100644 --- a/firestore/src/main/user_data_converter_main.cc +++ b/firestore/src/main/user_data_converter_main.cc @@ -72,7 +72,8 @@ void ParseServerTimestamp(ParseContext&& context) { context.AddToFieldTransforms(*context.path(), ServerTimestampTransform{}); } -void ParseArrayTransform(Type type, const model::FieldValue::Array& elements, +void ParseArrayTransform(Type type, + const model::FieldValue::Array& elements, ParseContext&& context) { auto transform_type = [type] { switch (type) { diff --git a/firestore/src/main/user_data_converter_main.h b/firestore/src/main/user_data_converter_main.h index 8285598d62..96a0c6f3f4 100644 --- a/firestore/src/main/user_data_converter_main.h +++ b/firestore/src/main/user_data_converter_main.h @@ -27,7 +27,8 @@ class ParseContext; class UserDataConverter { public: explicit UserDataConverter(const model::DatabaseId* database_id) - : database_id_{database_id} {} + : database_id_{database_id} { + } /** Parse document data from a non-merge `SetData` call. */ core::ParsedSetData ParseSetData(const MapFieldValue& input) const; diff --git a/firestore/src/main/write_batch_main.cc b/firestore/src/main/write_batch_main.cc index 0028f0ad5f..7f8c6ee7aa 100644 --- a/firestore/src/main/write_batch_main.cc +++ b/firestore/src/main/write_batch_main.cc @@ -20,9 +20,12 @@ using core::ParsedUpdateData; WriteBatchInternal::WriteBatchInternal(api::WriteBatch&& batch) : batch_{std::move(batch)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} {} + user_data_converter_{&firestore_internal()->database_id()} { +} -Firestore* WriteBatchInternal::firestore() { return GetFirestore(&batch_); } +Firestore* WriteBatchInternal::firestore() { + return GetFirestore(&batch_); +} FirestoreInternal* WriteBatchInternal::firestore_internal() { return GetFirestoreInternal(&batch_); diff --git a/firestore/src/main/write_batch_main.h b/firestore/src/main/write_batch_main.h index 068c84dc14..9ae83dc554 100644 --- a/firestore/src/main/write_batch_main.h +++ b/firestore/src/main/write_batch_main.h @@ -19,7 +19,8 @@ class WriteBatchInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options); void Update(const DocumentReference& document, const MapFieldValue& data); From 90ddc524b3badc97b5db5ace08a1005631f2229b Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 16 Jun 2021 15:11:08 -0400 Subject: [PATCH 2/2] Put short functions on a single line --- firestore/.clang-format | 1 - firestore/src/android/blob_android.cc | 4 +- .../src/android/document_reference_android.cc | 4 +- .../src/android/document_reference_android.h | 3 +- .../src/android/document_snapshot_android.h | 3 +- firestore/src/android/field_path_portable.h | 15 ++--- firestore/src/android/field_value_android.cc | 13 ++--- firestore/src/android/field_value_android.h | 4 +- firestore/src/android/firestore_android.h | 24 ++------ .../android/firestore_exceptions_android.h | 14 ++--- firestore/src/android/geo_point_android.cc | 4 +- firestore/src/android/jni_runnable_android.cc | 3 +- firestore/src/android/jni_runnable_android.h | 7 +-- firestore/src/android/lambda_event_listener.h | 4 +- .../android/listener_registration_android.cc | 4 +- .../android/listener_registration_android.h | 4 +- .../load_bundle_task_progress_android.cc | 4 +- .../load_bundle_task_progress_android.h | 3 +- firestore/src/android/promise_android.h | 17 ++---- .../src/android/promise_factory_android.h | 8 +-- firestore/src/android/query_android.h | 3 +- firestore/src/android/timestamp_android.cc | 4 +- firestore/src/android/transaction_android.h | 9 +-- firestore/src/android/wrapper.cc | 4 +- firestore/src/android/wrapper.h | 8 +-- firestore/src/android/write_batch_android.h | 3 +- firestore/src/common/cleanup.h | 8 +-- firestore/src/common/collection_reference.cc | 12 ++-- firestore/src/common/document_change.cc | 3 +- firestore/src/common/document_reference.cc | 3 +- firestore/src/common/document_snapshot.cc | 3 +- firestore/src/common/field_path.cc | 15 ++--- firestore/src/common/field_value.cc | 7 +-- firestore/src/common/firestore.cc | 7 +-- firestore/src/common/listener_registration.cc | 3 +- .../src/common/load_bundle_task_progress.cc | 3 +- .../src/common/main_for_testing_build.cc | 3 +- firestore/src/common/query.cc | 3 +- firestore/src/common/query_snapshot.cc | 3 +- firestore/src/common/set_options.cc | 6 +- firestore/src/common/settings.cc | 15 ++--- firestore/src/common/write_batch.cc | 3 +- .../firebase/firestore/document_reference.h | 4 +- .../include/firebase/firestore/field_value.h | 48 ++++------------ .../firestore/load_bundle_task_progress.h | 20 ++----- .../firebase/firestore/query_snapshot.h | 4 +- .../src/include/firebase/firestore/settings.h | 16 ++---- .../firebase/firestore/snapshot_metadata.h | 12 ++-- .../include/firebase/firestore/transaction.h | 3 +- firestore/src/jni/array.h | 11 +--- firestore/src/jni/array_list.cc | 4 +- firestore/src/jni/boolean.cc | 4 +- firestore/src/jni/class.cc | 4 +- firestore/src/jni/class.h | 7 +-- firestore/src/jni/collection.cc | 4 +- firestore/src/jni/declaration.h | 56 ++++++------------- firestore/src/jni/double.cc | 4 +- firestore/src/jni/env.cc | 10 +--- firestore/src/jni/env.h | 11 +--- firestore/src/jni/hash_map.cc | 4 +- firestore/src/jni/integer.cc | 8 +-- firestore/src/jni/iterator.cc | 8 +-- firestore/src/jni/jni.cc | 4 +- firestore/src/jni/list.cc | 4 +- firestore/src/jni/loader.cc | 4 +- firestore/src/jni/loader.h | 7 +-- firestore/src/jni/long.cc | 8 +-- firestore/src/jni/map.cc | 12 +--- firestore/src/jni/object.cc | 4 +- firestore/src/jni/object.h | 11 +--- firestore/src/jni/ownership.h | 27 +++------ firestore/src/jni/string.cc | 12 +--- firestore/src/jni/string.h | 7 +-- firestore/src/jni/task.cc | 8 +-- firestore/src/jni/throwable.h | 7 +-- firestore/src/jni/traits.h | 4 +- .../src/main/collection_reference_main.cc | 3 +- .../src/main/credentials_provider_desktop.cc | 3 +- .../src/main/credentials_provider_desktop.h | 3 +- firestore/src/main/document_change_main.cc | 3 +- firestore/src/main/document_reference_main.cc | 3 +- firestore/src/main/document_reference_main.h | 12 +--- firestore/src/main/document_snapshot_main.cc | 7 +-- firestore/src/main/field_value_main.cc | 31 ++++------ firestore/src/main/field_value_main.h | 7 +-- firestore/src/main/firestore_main.cc | 3 +- firestore/src/main/firestore_main.h | 24 ++------ .../src/main/listener_registration_main.cc | 4 +- .../src/main/listener_registration_main.h | 8 +-- firestore/src/main/promise_factory_main.h | 8 +-- firestore/src/main/promise_main.h | 8 +-- firestore/src/main/query_main.cc | 7 +-- firestore/src/main/query_main.h | 12 +--- firestore/src/main/query_snapshot_main.cc | 7 +-- firestore/src/main/set_options_main.h | 13 ++--- firestore/src/main/transaction_main.cc | 3 +- firestore/src/main/user_data_converter_main.h | 3 +- firestore/src/main/write_batch_main.cc | 7 +-- firestore/src/stub/transaction_stub.h | 6 +- firestore/src/stub/write_batch_stub.h | 3 +- 100 files changed, 234 insertions(+), 586 deletions(-) diff --git a/firestore/.clang-format b/firestore/.clang-format index c6701e8850..e241231928 100644 --- a/firestore/.clang-format +++ b/firestore/.clang-format @@ -6,5 +6,4 @@ AllowAllParametersOfDeclarationOnNextLine: true SpacesInContainerLiterals: true DerivePointerAlignment: false PointerAlignment: Left -AllowShortFunctionsOnASingleLine: None IncludeBlocks: Preserve diff --git a/firestore/src/android/blob_android.cc b/firestore/src/android/blob_android.cc index f69c45146e..caa9ee4ecc 100644 --- a/firestore/src/android/blob_android.cc +++ b/firestore/src/android/blob_android.cc @@ -32,9 +32,7 @@ void BlobInternal::Initialize(jni::Loader& loader) { loader.LoadAll(kConstructor, kFromBytes, kToBytes); } -Class BlobInternal::GetClass() { - return Class(g_class); -} +Class BlobInternal::GetClass() { return Class(g_class); } Local BlobInternal::Create(Env& env, const uint8_t* value, diff --git a/firestore/src/android/document_reference_android.cc b/firestore/src/android/document_reference_android.cc index b4d969d455..5a113b7eee 100644 --- a/firestore/src/android/document_reference_android.cc +++ b/firestore/src/android/document_reference_android.cc @@ -194,9 +194,7 @@ ListenerRegistration DocumentReferenceInternal::AddSnapshotListener( firestore_, listener, passing_listener_ownership, java_registration)); } -Class DocumentReferenceInternal::GetClass() { - return Class(clazz); -} +Class DocumentReferenceInternal::GetClass() { return Class(clazz); } } // namespace firestore } // namespace firebase diff --git a/firestore/src/android/document_reference_android.h b/firestore/src/android/document_reference_android.h index 4345197cf3..db7d3d95f2 100644 --- a/firestore/src/android/document_reference_android.h +++ b/firestore/src/android/document_reference_android.h @@ -37,8 +37,7 @@ class DocumentReferenceInternal : public Wrapper { DocumentReferenceInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) { - } + : Wrapper(firestore, object), promises_(firestore) {} /** Gets the Firestore instance associated with this document reference. */ Firestore* firestore(); diff --git a/firestore/src/android/document_snapshot_android.h b/firestore/src/android/document_snapshot_android.h index 069c6bfd08..db16642b4c 100644 --- a/firestore/src/android/document_snapshot_android.h +++ b/firestore/src/android/document_snapshot_android.h @@ -20,8 +20,7 @@ class DocumentSnapshotInternal : public Wrapper { static void Initialize(jni::Loader& loader); - ~DocumentSnapshotInternal() override { - } + ~DocumentSnapshotInternal() override {} /** Gets the Firestore instance associated with this document snapshot. */ Firestore* firestore() const; diff --git a/firestore/src/android/field_path_portable.h b/firestore/src/android/field_path_portable.h index 03eafacca1..ca3b420e96 100644 --- a/firestore/src/android/field_path_portable.h +++ b/firestore/src/android/field_path_portable.h @@ -23,8 +23,7 @@ class FieldPathPortable { static constexpr const char* kDocumentKeyPath = "__name__"; explicit FieldPathPortable(std::vector&& segments) - : segments_(firebase::Move(segments)) { - } + : segments_(firebase::Move(segments)) {} /** Returns i-th segment of the path. */ const std::string& operator[](const size_t i) const { @@ -32,17 +31,11 @@ class FieldPathPortable { return segments_[i]; } - const_iterator begin() const { - return segments_.begin(); - } + const_iterator begin() const { return segments_.begin(); } - const_iterator end() const { - return segments_.end(); - } + const_iterator end() const { return segments_.end(); } - size_t size() const { - return segments_.size(); - } + size_t size() const { return segments_.size(); } std::string CanonicalString() const; diff --git a/firestore/src/android/field_value_android.cc b/firestore/src/android/field_value_android.cc index de69b161a3..85172840ff 100644 --- a/firestore/src/android/field_value_android.cc +++ b/firestore/src/android/field_value_android.cc @@ -78,16 +78,13 @@ FieldValue FieldValueInternal::Create(Env& env, return FieldValue(new FieldValueInternal(type, object)); } -FieldValueInternal::FieldValueInternal() : cached_type_(Type::kNull) { -} +FieldValueInternal::FieldValueInternal() : cached_type_(Type::kNull) {} FieldValueInternal::FieldValueInternal(const Object& object) - : object_(object), cached_type_(Type::kNull) { -} + : object_(object), cached_type_(Type::kNull) {} FieldValueInternal::FieldValueInternal(Type type, const Object& object) - : object_(object), cached_type_(type) { -} + : object_(object), cached_type_(type) {} FieldValueInternal::FieldValueInternal(bool value) : cached_type_(Type::kBoolean) { @@ -405,9 +402,7 @@ Local> FieldValueInternal::MakeArray( return result; } -Env FieldValueInternal::GetEnv() { - return FirestoreInternal::GetEnv(); -} +Env FieldValueInternal::GetEnv() { return FirestoreInternal::GetEnv(); } Object FieldValueInternal::ToJava(const FieldValue& value) { return value.internal_ ? value.internal_->object_ : Object(); diff --git a/firestore/src/android/field_value_android.h b/firestore/src/android/field_value_android.h index 2beaa2fe5e..79fd8e16b3 100644 --- a/firestore/src/android/field_value_android.h +++ b/firestore/src/android/field_value_android.h @@ -65,9 +65,7 @@ class FieldValueInternal { std::vector array_value() const; MapFieldValue map_value() const; - const jni::Global& ToJava() const { - return object_; - } + const jni::Global& ToJava() const { return object_; } static FieldValue Delete(); static FieldValue ServerTimestamp(); diff --git a/firestore/src/android/firestore_android.h b/firestore/src/android/firestore_android.h index 9ceedb7e96..3403276974 100644 --- a/firestore/src/android/firestore_android.h +++ b/firestore/src/android/firestore_android.h @@ -65,25 +65,17 @@ class FirestoreInternal { explicit FirestoreInternal(App* app); ~FirestoreInternal(); - App* app() const { - return app_; - } + App* app() const { return app_; } // Whether this object was successfully initialized by the constructor. - bool initialized() const { - return app_ != nullptr; - } + bool initialized() const { return app_ != nullptr; } // Manages all Future objects returned from Firestore API. - FutureManager& future_manager() { - return future_manager_; - } + FutureManager& future_manager() { return future_manager_; } // When this is deleted, it will clean up all DatabaseReferences, // DataSnapshots, and other such objects. - CleanupNotifier& cleanup() { - return cleanup_; - } + CleanupNotifier& cleanup() { return cleanup_; } // Returns a CollectionReference that refers to the specific path. CollectionReference Collection(const char* collection_path) const; @@ -159,12 +151,8 @@ class FirestoreInternal { firestore_public_ = firestore_public; } - Firestore* firestore_public() { - return firestore_public_; - } - const Firestore* firestore_public() const { - return firestore_public_; - } + Firestore* firestore_public() { return firestore_public_; } + const Firestore* firestore_public() const { return firestore_public_; } /** * Finds the FirestoreInternal instance for the given Java Firestore instance. diff --git a/firestore/src/android/firestore_exceptions_android.h b/firestore/src/android/firestore_exceptions_android.h index 91d140b3dd..9404d061f0 100644 --- a/firestore/src/android/firestore_exceptions_android.h +++ b/firestore/src/android/firestore_exceptions_android.h @@ -34,16 +34,11 @@ namespace firestore { class FirestoreException : public std::exception { public: FirestoreException(const std::string& message, Error code) - : message_(message), code_(code) { - } + : message_(message), code_(code) {} - const char* what() const noexcept override { - return message_.c_str(); - } + const char* what() const noexcept override { return message_.c_str(); } - Error code() const { - return code_; - } + Error code() const { return code_; } private: std::string message_; @@ -57,8 +52,7 @@ class FirestoreInternalError : public FirestoreException { public: FirestoreInternalError(const std::string& message, Error code = Error::kErrorInternal) - : FirestoreException(message, code) { - } + : FirestoreException(message, code) {} }; #endif // FIRESTORE_HAVE_EXCEPTIONS diff --git a/firestore/src/android/geo_point_android.cc b/firestore/src/android/geo_point_android.cc index f0ef7c181d..5d7800e52e 100644 --- a/firestore/src/android/geo_point_android.cc +++ b/firestore/src/android/geo_point_android.cc @@ -28,9 +28,7 @@ void GeoPointInternal::Initialize(jni::Loader& loader) { loader.LoadClass(kClassName, kConstructor, kGetLatitude, kGetLongitude); } -Class GeoPointInternal::GetClass() { - return Class(g_clazz); -} +Class GeoPointInternal::GetClass() { return Class(g_clazz); } Local GeoPointInternal::Create(Env& env, const GeoPoint& point) { diff --git a/firestore/src/android/jni_runnable_android.cc b/firestore/src/android/jni_runnable_android.cc index 26a7156c95..50a590b34d 100644 --- a/firestore/src/android/jni_runnable_android.cc +++ b/firestore/src/android/jni_runnable_android.cc @@ -47,8 +47,7 @@ void JniRunnableBase::Initialize(jni::Loader& loader) { } JniRunnableBase::JniRunnableBase(Env& env) - : java_runnable_(env.New(kConstructor, reinterpret_cast(this))) { -} + : java_runnable_(env.New(kConstructor, reinterpret_cast(this))) {} JniRunnableBase::~JniRunnableBase() { Env env; diff --git a/firestore/src/android/jni_runnable_android.h b/firestore/src/android/jni_runnable_android.h index d357a5347c..8ee9439424 100644 --- a/firestore/src/android/jni_runnable_android.h +++ b/firestore/src/android/jni_runnable_android.h @@ -116,12 +116,9 @@ template class JniRunnable : public JniRunnableBase { public: JniRunnable(jni::Env& env, CallbackT callback) - : JniRunnableBase(env), callback_(firebase::Move(callback)) { - } + : JniRunnableBase(env), callback_(firebase::Move(callback)) {} - void Run() override { - Run(*this, callback_); - } + void Run() override { Run(*this, callback_); } private: // These two static overloads of `Run()` use SFINAE to invoke the callback diff --git a/firestore/src/android/lambda_event_listener.h b/firestore/src/android/lambda_event_listener.h index c2b057deac..347906cb2a 100644 --- a/firestore/src/android/lambda_event_listener.h +++ b/firestore/src/android/lambda_event_listener.h @@ -42,9 +42,7 @@ class LambdaEventListener : public EventListener { FIREBASE_ASSERT(callback_); } - void OnEvent(Error, const std::string&) override { - callback_(); - } + void OnEvent(Error, const std::string&) override { callback_(); } private: std::function callback_; diff --git a/firestore/src/android/listener_registration_android.cc b/firestore/src/android/listener_registration_android.cc index cdaed158cd..b81fb70e39 100644 --- a/firestore/src/android/listener_registration_android.cc +++ b/firestore/src/android/listener_registration_android.cc @@ -93,9 +93,7 @@ ListenerRegistrationInternal::~ListenerRegistrationInternal() { } } -jni::Env ListenerRegistrationInternal::GetEnv() { - return firestore_->GetEnv(); -} +jni::Env ListenerRegistrationInternal::GetEnv() { return firestore_->GetEnv(); } } // namespace firestore } // namespace firebase diff --git a/firestore/src/android/listener_registration_android.h b/firestore/src/android/listener_registration_android.h index 4edff69646..d2377193f5 100644 --- a/firestore/src/android/listener_registration_android.h +++ b/firestore/src/android/listener_registration_android.h @@ -55,9 +55,7 @@ class ListenerRegistrationInternal { ListenerRegistrationInternal& operator=( ListenerRegistrationInternal&& another) = delete; - FirestoreInternal* firestore_internal() { - return firestore_; - } + FirestoreInternal* firestore_internal() { return firestore_; } private: friend class DocumentReferenceInternal; diff --git a/firestore/src/android/load_bundle_task_progress_android.cc b/firestore/src/android/load_bundle_task_progress_android.cc index 124e490d2d..cc47887300 100644 --- a/firestore/src/android/load_bundle_task_progress_android.cc +++ b/firestore/src/android/load_bundle_task_progress_android.cc @@ -63,9 +63,7 @@ void LoadBundleTaskProgressInternal::Initialize(jni::Loader& loader) { loader.LoadClass(kStateEnumName, kTaskStateSuccess, kTaskStateRunning); } -Class LoadBundleTaskProgressInternal::GetClass() { - return Class(g_clazz); -} +Class LoadBundleTaskProgressInternal::GetClass() { return Class(g_clazz); } int32_t LoadBundleTaskProgressInternal::documents_loaded() const { Env env = GetEnv(); diff --git a/firestore/src/android/load_bundle_task_progress_android.h b/firestore/src/android/load_bundle_task_progress_android.h index b8910ae7a3..4597374a8a 100644 --- a/firestore/src/android/load_bundle_task_progress_android.h +++ b/firestore/src/android/load_bundle_task_progress_android.h @@ -38,8 +38,7 @@ class LoadBundleTaskProgressInternal : public Wrapper { LoadBundleTaskProgressInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object) { - } + : Wrapper(firestore, object) {} int32_t documents_loaded() const; diff --git a/firestore/src/android/promise_android.h b/firestore/src/android/promise_android.h index 000a4d5ade..d9b3e76a5c 100644 --- a/firestore/src/android/promise_android.h +++ b/firestore/src/android/promise_android.h @@ -48,8 +48,7 @@ class Promise { PublicType* result) = 0; }; - ~Promise() { - } + ~Promise() {} Promise(const Promise&) = delete; Promise& operator=(const Promise&) = delete; @@ -67,9 +66,7 @@ class Promise { completer, kApiIdentifier); } - Future GetFuture() { - return MakeFuture(impl_, handle_); - } + Future GetFuture() { return MakeFuture(impl_, handle_); } private: // The constructor is intentionally private. @@ -79,8 +76,7 @@ class Promise { Completion* completion) : completer_(MakeUnique>( impl, firestore, completion)), - impl_(impl) { - } + impl_(impl) {} template class CompleterBase { @@ -88,14 +84,11 @@ class Promise { CompleterBase(ReferenceCountedFutureImpl* impl, FirestoreInternal* firestore, Completion* completion) - : impl_{impl}, firestore_{firestore}, completion_(completion) { - } + : impl_{impl}, firestore_{firestore}, completion_(completion) {} virtual ~CompleterBase() = default; - FirestoreInternal* firestore() { - return firestore_; - } + FirestoreInternal* firestore() { return firestore_; } SafeFutureHandle Alloc(int fn_index) { handle_ = impl_->SafeAlloc(fn_index); diff --git a/firestore/src/android/promise_factory_android.h b/firestore/src/android/promise_factory_android.h index 747c5b5cda..913b6180cb 100644 --- a/firestore/src/android/promise_factory_android.h +++ b/firestore/src/android/promise_factory_android.h @@ -28,9 +28,7 @@ class PromiseFactory { firestore_->future_manager().MoveFutureApi(&rhs, this); } - ~PromiseFactory() { - firestore_->future_manager().ReleaseFutureApi(this); - } + ~PromiseFactory() { firestore_->future_manager().ReleaseFutureApi(this); } PromiseFactory& operator=(const PromiseFactory&) = delete; PromiseFactory& operator=(PromiseFactory&&) = delete; @@ -67,9 +65,7 @@ class PromiseFactory { return firestore_->future_manager().GetFutureApi(this); } - constexpr int ApiCount() const { - return static_cast(EnumT::kCount); - } + constexpr int ApiCount() const { return static_cast(EnumT::kCount); } FirestoreInternal* firestore_ = nullptr; }; diff --git a/firestore/src/android/query_android.h b/firestore/src/android/query_android.h index b84c723a58..a42a3b1f12 100644 --- a/firestore/src/android/query_android.h +++ b/firestore/src/android/query_android.h @@ -34,8 +34,7 @@ class QueryInternal : public Wrapper { static void Initialize(jni::Loader& loader); QueryInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) { - } + : Wrapper(firestore, object), promises_(firestore) {} /** Gets the Firestore instance associated with this query. */ Firestore* firestore(); diff --git a/firestore/src/android/timestamp_android.cc b/firestore/src/android/timestamp_android.cc index 98998285cb..db72af0081 100644 --- a/firestore/src/android/timestamp_android.cc +++ b/firestore/src/android/timestamp_android.cc @@ -28,9 +28,7 @@ void TimestampInternal::Initialize(jni::Loader& loader) { loader.LoadClass(kClassName, kConstructor, kGetSeconds, kGetNanoseconds); } -Class TimestampInternal::GetClass() { - return Class(g_clazz); -} +Class TimestampInternal::GetClass() { return Class(g_clazz); } Local TimestampInternal::Create(Env& env, const Timestamp& timestamp) { diff --git a/firestore/src/android/transaction_android.h b/firestore/src/android/transaction_android.h index 76d090bd25..485077e5c8 100644 --- a/firestore/src/android/transaction_android.h +++ b/firestore/src/android/transaction_android.h @@ -24,17 +24,14 @@ class TransactionInternal : public Wrapper { TransactionInternal(FirestoreInternal* firestore, const jni::Object& obj) : Wrapper(firestore, obj), - first_exception_(MakeShared>()) { - } + first_exception_(MakeShared>()) {} TransactionInternal(const TransactionInternal& rhs) - : Wrapper(rhs), first_exception_(rhs.first_exception_) { - } + : Wrapper(rhs), first_exception_(rhs.first_exception_) {} TransactionInternal(TransactionInternal&& rhs) : Wrapper(firebase::Move(rhs)), - first_exception_(Move(rhs.first_exception_)) { - } + first_exception_(Move(rhs.first_exception_)) {} void Set(const DocumentReference& document, const MapFieldValue& data, diff --git a/firestore/src/android/wrapper.cc b/firestore/src/android/wrapper.cc index 267cc03166..1ef2a54813 100644 --- a/firestore/src/android/wrapper.cc +++ b/firestore/src/android/wrapper.cc @@ -40,9 +40,7 @@ Wrapper::Wrapper(Wrapper* rhs) : Wrapper() { Wrapper::~Wrapper() = default; -jni::Env Wrapper::GetEnv() const { - return firestore_->GetEnv(); -} +jni::Env Wrapper::GetEnv() const { return firestore_->GetEnv(); } Object Wrapper::ToJava(const FieldValue& value) { return FieldValueInternal::ToJava(value); diff --git a/firestore/src/android/wrapper.h b/firestore/src/android/wrapper.h index 7f7256c2f2..65d3faec2d 100644 --- a/firestore/src/android/wrapper.h +++ b/firestore/src/android/wrapper.h @@ -27,12 +27,8 @@ class Wrapper { Wrapper& operator=(const Wrapper& wrapper) = delete; Wrapper& operator=(Wrapper&& wrapper) = delete; - FirestoreInternal* firestore_internal() { - return firestore_; - } - const jni::Object& ToJava() const { - return obj_; - } + FirestoreInternal* firestore_internal() { return firestore_; } + const jni::Object& ToJava() const { return obj_; } static jni::Object ToJava(const FieldValue& value); diff --git a/firestore/src/android/write_batch_android.h b/firestore/src/android/write_batch_android.h index b8f813a473..84e5213949 100644 --- a/firestore/src/android/write_batch_android.h +++ b/firestore/src/android/write_batch_android.h @@ -24,8 +24,7 @@ class WriteBatchInternal : public Wrapper { static void Initialize(jni::Loader& loader); WriteBatchInternal(FirestoreInternal* firestore, const jni::Object& object) - : Wrapper(firestore, object), promises_(firestore) { - } + : Wrapper(firestore, object), promises_(firestore) {} void Set(const DocumentReference& document, const MapFieldValue& data, diff --git a/firestore/src/common/cleanup.h b/firestore/src/common/cleanup.h index 62ec9c75db..3c6ef74d46 100644 --- a/firestore/src/common/cleanup.h +++ b/firestore/src/common/cleanup.h @@ -27,9 +27,7 @@ template , typename F = FirestoreInternal> struct CleanupFn { - static void Cleanup(void* obj_void) { - DoCleanup(static_cast(obj_void)); - } + static void Cleanup(void* obj_void) { DoCleanup(static_cast(obj_void)); } static void Register(T* obj, F* firestore) { if (firestore) { @@ -74,9 +72,7 @@ struct CleanupFn { } // `ListenerRegistration` objects differ from the common pattern. - static void DoCleanup(ListenerRegistration* obj) { - obj->Cleanup(); - } + static void DoCleanup(ListenerRegistration* obj) { obj->Cleanup(); } }; } // namespace firestore diff --git a/firestore/src/common/collection_reference.cc b/firestore/src/common/collection_reference.cc index 335efd1cbd..cf4eb36bc4 100644 --- a/firestore/src/common/collection_reference.cc +++ b/firestore/src/common/collection_reference.cc @@ -25,22 +25,18 @@ namespace firestore { // Java CollectionReference) be subclass of QueryInternal (resp. Java Query), // which is already the case. -CollectionReference::CollectionReference() { -} +CollectionReference::CollectionReference() {} CollectionReference::CollectionReference(const CollectionReference& reference) : Query(reference.internal() ? new CollectionReferenceInternal(*reference.internal()) - : nullptr) { -} + : nullptr) {} CollectionReference::CollectionReference(CollectionReference&& reference) - : Query(firebase::Move(reference)) { -} + : Query(firebase::Move(reference)) {} CollectionReference::CollectionReference(CollectionReferenceInternal* internal) - : Query(internal) { -} + : Query(internal) {} CollectionReference& CollectionReference::operator=( const CollectionReference& reference) { diff --git a/firestore/src/common/document_change.cc b/firestore/src/common/document_change.cc index dd3c87c305..9908b679cb 100644 --- a/firestore/src/common/document_change.cc +++ b/firestore/src/common/document_change.cc @@ -25,8 +25,7 @@ using Type = DocumentChange::Type; const std::size_t DocumentChange::npos = static_cast(-1); #endif // defined(ANDROID) -DocumentChange::DocumentChange() { -} +DocumentChange::DocumentChange() {} DocumentChange::DocumentChange(const DocumentChange& value) { if (value.internal_) { diff --git a/firestore/src/common/document_reference.cc b/firestore/src/common/document_reference.cc index db21652f0e..d966ee3a54 100644 --- a/firestore/src/common/document_reference.cc +++ b/firestore/src/common/document_reference.cc @@ -25,8 +25,7 @@ namespace firestore { using CleanupFnDocumentReference = CleanupFn; -DocumentReference::DocumentReference() { -} +DocumentReference::DocumentReference() {} DocumentReference::DocumentReference(const DocumentReference& reference) { if (reference.internal_) { diff --git a/firestore/src/common/document_snapshot.cc b/firestore/src/common/document_snapshot.cc index 0d5057dfc0..4b3db14ab5 100644 --- a/firestore/src/common/document_snapshot.cc +++ b/firestore/src/common/document_snapshot.cc @@ -23,8 +23,7 @@ namespace firestore { using CleanupFnDocumentSnapshot = CleanupFn; -DocumentSnapshot::DocumentSnapshot() { -} +DocumentSnapshot::DocumentSnapshot() {} DocumentSnapshot::DocumentSnapshot(const DocumentSnapshot& snapshot) { if (snapshot.internal_) { diff --git a/firestore/src/common/field_path.cc b/firestore/src/common/field_path.cc index 7efcd06063..1de85336fe 100644 --- a/firestore/src/common/field_path.cc +++ b/firestore/src/common/field_path.cc @@ -36,29 +36,24 @@ namespace firebase { namespace firestore { -FieldPath::FieldPath() { -} +FieldPath::FieldPath() {} #if !defined(_STLPORT_VERSION) FieldPath::FieldPath(std::initializer_list field_names) - : internal_(InternalFromSegments(std::vector(field_names))) { -} + : internal_(InternalFromSegments(std::vector(field_names))) {} #endif // !defined(_STLPORT_VERSION) FieldPath::FieldPath(const std::vector& field_names) - : internal_(InternalFromSegments(field_names)) { -} + : internal_(InternalFromSegments(field_names)) {} FieldPath::FieldPath(const FieldPath& path) - : internal_(new FieldPathInternal{*path.internal_}) { -} + : internal_(new FieldPathInternal{*path.internal_}) {} FieldPath::FieldPath(FieldPath&& path) noexcept : internal_(path.internal_) { path.internal_ = nullptr; } -FieldPath::FieldPath(FieldPathInternal* internal) : internal_(internal) { -} +FieldPath::FieldPath(FieldPathInternal* internal) : internal_(internal) {} FieldPath::~FieldPath() { delete internal_; diff --git a/firestore/src/common/field_value.cc b/firestore/src/common/field_value.cc index 56b51cb2a1..7053163edb 100644 --- a/firestore/src/common/field_value.cc +++ b/firestore/src/common/field_value.cc @@ -74,8 +74,7 @@ std::string ValueToString(const uint8_t* blob, size_t size) { } // namespace -FieldValue::FieldValue() { -} +FieldValue::FieldValue() {} FieldValue::FieldValue(const FieldValue& value) { if (value.internal_) { @@ -239,9 +238,7 @@ FieldValue FieldValue::Null() { } /* static */ -FieldValue FieldValue::Delete() { - return FieldValueInternal::Delete(); -} +FieldValue FieldValue::Delete() { return FieldValueInternal::Delete(); } /* static */ FieldValue FieldValue::ServerTimestamp() { diff --git a/firestore/src/common/firestore.cc b/firestore/src/common/firestore.cc index 302a4843fc..6affc8e2da 100644 --- a/firestore/src/common/firestore.cc +++ b/firestore/src/common/firestore.cc @@ -138,8 +138,7 @@ Firestore* Firestore::AddFirestoreToCache(Firestore* firestore, } Firestore::Firestore(::firebase::App* app) - : Firestore{new FirestoreInternal{app}} { -} + : Firestore{new FirestoreInternal{app}} {} Firestore::Firestore(FirestoreInternal* internal) // TODO(wuandy): use make_unique once it is supported for our build here. @@ -167,9 +166,7 @@ Firestore::Firestore(FirestoreInternal* internal) } } -Firestore::~Firestore() { - DeleteInternal(); -} +Firestore::~Firestore() { DeleteInternal(); } void Firestore::DeleteInternal() { MutexLock lock(*g_firestores_lock); diff --git a/firestore/src/common/listener_registration.cc b/firestore/src/common/listener_registration.cc index ffddd42cf0..52e90828d6 100644 --- a/firestore/src/common/listener_registration.cc +++ b/firestore/src/common/listener_registration.cc @@ -23,8 +23,7 @@ namespace firestore { using CleanupFnListenerRegistration = CleanupFn; -ListenerRegistration::ListenerRegistration() : ListenerRegistration(nullptr) { -} +ListenerRegistration::ListenerRegistration() : ListenerRegistration(nullptr) {} ListenerRegistration::ListenerRegistration( const ListenerRegistration& registration) diff --git a/firestore/src/common/load_bundle_task_progress.cc b/firestore/src/common/load_bundle_task_progress.cc index c17b8dfd62..e50cee7a58 100644 --- a/firestore/src/common/load_bundle_task_progress.cc +++ b/firestore/src/common/load_bundle_task_progress.cc @@ -34,8 +34,7 @@ LoadBundleTaskProgress::LoadBundleTaskProgress(int32_t documents_loaded, total_documents_(total_documents), bytes_loaded_(bytes_loaded), total_bytes_(total_bytes), - state_(state) { -} + state_(state) {} // Android requires below constructor to create this object from internal // objects in a promise. See promise_android.h diff --git a/firestore/src/common/main_for_testing_build.cc b/firestore/src/common/main_for_testing_build.cc index b2f997621b..237c8ce181 100644 --- a/firestore/src/common/main_for_testing_build.cc +++ b/firestore/src/common/main_for_testing_build.cc @@ -1,2 +1 @@ -int main() { -} +int main() {} diff --git a/firestore/src/common/query.cc b/firestore/src/common/query.cc index 5897ef37d0..fc06f9d612 100644 --- a/firestore/src/common/query.cc +++ b/firestore/src/common/query.cc @@ -24,8 +24,7 @@ namespace firestore { using CleanupFnQuery = CleanupFn; -Query::Query() { -} +Query::Query() {} Query::Query(const Query& query) { if (query.internal_) { diff --git a/firestore/src/common/query_snapshot.cc b/firestore/src/common/query_snapshot.cc index 65a71860fa..85ac8d446c 100644 --- a/firestore/src/common/query_snapshot.cc +++ b/firestore/src/common/query_snapshot.cc @@ -20,8 +20,7 @@ namespace firestore { using CleanupFnQuerySnapshot = CleanupFn; -QuerySnapshot::QuerySnapshot() { -} +QuerySnapshot::QuerySnapshot() {} QuerySnapshot::QuerySnapshot(const QuerySnapshot& snapshot) { if (snapshot.internal_) { diff --git a/firestore/src/common/set_options.cc b/firestore/src/common/set_options.cc index b6707838b0..70916fabf4 100644 --- a/firestore/src/common/set_options.cc +++ b/firestore/src/common/set_options.cc @@ -22,11 +22,9 @@ namespace firebase { namespace firestore { SetOptions::SetOptions(Type type, std::vector fields) - : type_(type), fields_(firebase::Move(fields)) { -} + : type_(type), fields_(firebase::Move(fields)) {} -SetOptions::~SetOptions() { -} +SetOptions::~SetOptions() {} /* static */ SetOptions SetOptions::Merge() { diff --git a/firestore/src/common/settings.cc b/firestore/src/common/settings.cc index 57affb954c..d7a8fb73b0 100644 --- a/firestore/src/common/settings.cc +++ b/firestore/src/common/settings.cc @@ -16,9 +16,7 @@ namespace { const char kDefaultHost[] = "firestore.googleapis.com"; -std::string ToStr(bool v) { - return v ? "true" : "false"; -} +std::string ToStr(bool v) { return v ? "true" : "false"; } std::string ToStr(int64_t v) { // TODO(b/163140650): use `std::to_string` (which will make this function @@ -31,17 +29,12 @@ std::string ToStr(int64_t v) { } // namespace #if !defined(__APPLE__) -Settings::Settings() : host_(kDefaultHost) { -} +Settings::Settings() : host_(kDefaultHost) {} #endif -void Settings::set_host(std::string host) { - host_ = firebase::Move(host); -} +void Settings::set_host(std::string host) { host_ = firebase::Move(host); } -void Settings::set_ssl_enabled(bool enabled) { - ssl_enabled_ = enabled; -} +void Settings::set_ssl_enabled(bool enabled) { ssl_enabled_ = enabled; } void Settings::set_persistence_enabled(bool enabled) { persistence_enabled_ = enabled; diff --git a/firestore/src/common/write_batch.cc b/firestore/src/common/write_batch.cc index ad65a5c4b9..02b503fb9b 100644 --- a/firestore/src/common/write_batch.cc +++ b/firestore/src/common/write_batch.cc @@ -20,8 +20,7 @@ namespace firestore { using CleanupFnWriteBatch = CleanupFn; -WriteBatch::WriteBatch() { -} +WriteBatch::WriteBatch() {} WriteBatch::WriteBatch(const WriteBatch& value) { if (value.internal_) { diff --git a/firestore/src/include/firebase/firestore/document_reference.h b/firestore/src/include/firebase/firestore/document_reference.h index 385f2101dc..4b98673037 100644 --- a/firestore/src/include/firebase/firestore/document_reference.h +++ b/firestore/src/include/firebase/firestore/document_reference.h @@ -355,9 +355,7 @@ class DocumentReference { * @return true if this DocumentReference is valid, false if this * DocumentReference is invalid. */ - bool is_valid() const { - return internal_ != nullptr; - } + bool is_valid() const { return internal_ != nullptr; } /** * Returns a string representation of this `DocumentReference` for diff --git a/firestore/src/include/firebase/firestore/field_value.h b/firestore/src/include/firebase/firestore/field_value.h index 971b82cee6..6718705a87 100644 --- a/firestore/src/include/firebase/firestore/field_value.h +++ b/firestore/src/include/firebase/firestore/field_value.h @@ -202,63 +202,41 @@ class FieldValue final { Type type() const; /** @brief Gets whether this FieldValue is currently null. */ - bool is_null() const { - return type() == Type::kNull; - } + bool is_null() const { return type() == Type::kNull; } /** @brief Gets whether this FieldValue contains a boolean value. */ - bool is_boolean() const { - return type() == Type::kBoolean; - } + bool is_boolean() const { return type() == Type::kBoolean; } /** @brief Gets whether this FieldValue contains an integer value. */ - bool is_integer() const { - return type() == Type::kInteger; - } + bool is_integer() const { return type() == Type::kInteger; } /** @brief Gets whether this FieldValue contains a double value. */ - bool is_double() const { - return type() == Type::kDouble; - } + bool is_double() const { return type() == Type::kDouble; } /** @brief Gets whether this FieldValue contains a timestamp. */ - bool is_timestamp() const { - return type() == Type::kTimestamp; - } + bool is_timestamp() const { return type() == Type::kTimestamp; } /** @brief Gets whether this FieldValue contains a string. */ - bool is_string() const { - return type() == Type::kString; - } + bool is_string() const { return type() == Type::kString; } /** @brief Gets whether this FieldValue contains a blob. */ - bool is_blob() const { - return type() == Type::kBlob; - } + bool is_blob() const { return type() == Type::kBlob; } /** * @brief Gets whether this FieldValue contains a reference to a document in * the same Firestore. */ - bool is_reference() const { - return type() == Type::kReference; - } + bool is_reference() const { return type() == Type::kReference; } /** @brief Gets whether this FieldValue contains a GeoPoint. */ - bool is_geo_point() const { - return type() == Type::kGeoPoint; - } + bool is_geo_point() const { return type() == Type::kGeoPoint; } /** @brief Gets whether this FieldValue contains an array of FieldValues. */ - bool is_array() const { - return type() == Type::kArray; - } + bool is_array() const { return type() == Type::kArray; } /** @brief Gets whether this FieldValue contains a map of std::string to * FieldValue. */ - bool is_map() const { - return type() == Type::kMap; - } + bool is_map() const { return type() == Type::kMap; } /** @brief Gets the boolean value contained in this FieldValue. */ bool boolean_value() const; @@ -305,9 +283,7 @@ class FieldValue final { * @return `true` if this `FieldValue` is valid, `false` if this `FieldValue` * is invalid. */ - bool is_valid() const { - return internal_ != nullptr; - } + bool is_valid() const { return internal_ != nullptr; } /** @brief Constructs a null. */ static FieldValue Null(); diff --git a/firestore/src/include/firebase/firestore/load_bundle_task_progress.h b/firestore/src/include/firebase/firestore/load_bundle_task_progress.h index 2c286e9c89..e848ff5b73 100644 --- a/firestore/src/include/firebase/firestore/load_bundle_task_progress.h +++ b/firestore/src/include/firebase/firestore/load_bundle_task_progress.h @@ -42,35 +42,25 @@ class LoadBundleTaskProgress { State state); /** Returns how many documents have been loaded. */ - int32_t documents_loaded() const { - return documents_loaded_; - } + int32_t documents_loaded() const { return documents_loaded_; } /** * Returns the total number of documents in the bundle. Returns 0 if the * bundle failed to parse. */ - int32_t total_documents() const { - return total_documents_; - } + int32_t total_documents() const { return total_documents_; } /** Returns how many bytes have been loaded. */ - int64_t bytes_loaded() const { - return bytes_loaded_; - } + int64_t bytes_loaded() const { return bytes_loaded_; } /** * Returns the total number of bytes in the bundle. Returns 0 if the bundle * failed to parse. */ - int64_t total_bytes() const { - return total_bytes_; - } + int64_t total_bytes() const { return total_bytes_; } /** Returns the current state of the loading progress. */ - State state() const { - return state_; - } + State state() const { return state_; } private: friend class EventListenerInternal; diff --git a/firestore/src/include/firebase/firestore/query_snapshot.h b/firestore/src/include/firebase/firestore/query_snapshot.h index 0103b29b6f..71718e0854 100644 --- a/firestore/src/include/firebase/firestore/query_snapshot.h +++ b/firestore/src/include/firebase/firestore/query_snapshot.h @@ -141,9 +141,7 @@ class QuerySnapshot { * * @return True if there are no documents in the QuerySnapshot. */ - bool empty() const { - return size() == 0; - } + bool empty() const { return size() == 0; } /** * @brief Checks the size of the QuerySnapshot. diff --git a/firestore/src/include/firebase/firestore/settings.h b/firestore/src/include/firebase/firestore/settings.h index d67eafd3bb..5daa2ec1bb 100644 --- a/firestore/src/include/firebase/firestore/settings.h +++ b/firestore/src/include/firebase/firestore/settings.h @@ -106,28 +106,20 @@ class Settings final { /** * Gets the host of the Firestore backend to connect to. */ - const std::string& host() const { - return host_; - } + const std::string& host() const { return host_; } /** * Returns whether to use SSL when communicating. */ - bool is_ssl_enabled() const { - return ssl_enabled_; - } + bool is_ssl_enabled() const { return ssl_enabled_; } /** * Returns whether to enable local persistent storage. */ - bool is_persistence_enabled() const { - return persistence_enabled_; - } + bool is_persistence_enabled() const { return persistence_enabled_; } /** Returns cache size for on-disk data. */ - int64_t cache_size_bytes() const { - return cache_size_bytes_; - } + int64_t cache_size_bytes() const { return cache_size_bytes_; } /** * Sets the host of the Firestore backend. The default is diff --git a/firestore/src/include/firebase/firestore/snapshot_metadata.h b/firestore/src/include/firebase/firestore/snapshot_metadata.h index 11f3968d3b..e394f5459e 100644 --- a/firestore/src/include/firebase/firestore/snapshot_metadata.h +++ b/firestore/src/include/firebase/firestore/snapshot_metadata.h @@ -41,8 +41,8 @@ class SnapshotMetadata final { * @param is_from_cache Whether the snapshot is from cache instead of backend. */ SnapshotMetadata(bool has_pending_writes, bool is_from_cache) - : has_pending_writes_(has_pending_writes), is_from_cache_(is_from_cache) { - } + : has_pending_writes_(has_pending_writes), + is_from_cache_(is_from_cache) {} /** * @brief Copy constructor. @@ -104,9 +104,7 @@ class SnapshotMetadata final { * has_pending_writes() equal to false once the writes have been committed to * the backend. */ - bool has_pending_writes() const { - return has_pending_writes_; - } + bool has_pending_writes() const { return has_pending_writes_; } /** * Returns whether the snapshot was created from cached data. @@ -117,9 +115,7 @@ class SnapshotMetadata final { * with is_from_cache() equal to false once the client has received up-to-date * data from the backend. */ - bool is_from_cache() const { - return is_from_cache_; - } + bool is_from_cache() const { return is_from_cache_; } /** * Returns a string representation of this `SnapshotMetadata` for diff --git a/firestore/src/include/firebase/firestore/transaction.h b/firestore/src/include/firebase/firestore/transaction.h index 310328ea2b..4430ff5e83 100644 --- a/firestore/src/include/firebase/firestore/transaction.h +++ b/firestore/src/include/firebase/firestore/transaction.h @@ -145,8 +145,7 @@ class Transaction { */ class TransactionFunction { public: - virtual ~TransactionFunction() { - } + virtual ~TransactionFunction() {} /** * Subclass should override this method and put the transaction logic here. diff --git a/firestore/src/jni/array.h b/firestore/src/jni/array.h index dfe892b2b5..9923b14613 100644 --- a/firestore/src/jni/array.h +++ b/firestore/src/jni/array.h @@ -16,16 +16,11 @@ class Array : public Object { using jni_type = JniType>; Array() = default; - explicit Array(jni_type array) : Object(array) { - } + explicit Array(jni_type array) : Object(array) {} - jni_type get() const override { - return static_cast(Object::get()); - } + jni_type get() const override { return static_cast(Object::get()); } - size_t Size(Env& env) const { - return env.GetArrayLength(*this); - } + size_t Size(Env& env) const { return env.GetArrayLength(*this); } Local Get(Env& env, size_t i) const { return env.GetArrayElement(*this, i); diff --git a/firestore/src/jni/array_list.cc b/firestore/src/jni/array_list.cc index f9f651ade3..aeb75f4fc2 100644 --- a/firestore/src/jni/array_list.cc +++ b/firestore/src/jni/array_list.cc @@ -20,9 +20,7 @@ void ArrayList::Initialize(Loader& loader) { kConstructorWithSize); } -Local ArrayList::Create(Env& env) { - return env.New(kConstructor); -} +Local ArrayList::Create(Env& env) { return env.New(kConstructor); } Local ArrayList::Create(Env& env, size_t size) { return env.New(kConstructorWithSize, size); diff --git a/firestore/src/jni/boolean.cc b/firestore/src/jni/boolean.cc index 386320548a..72293cee36 100644 --- a/firestore/src/jni/boolean.cc +++ b/firestore/src/jni/boolean.cc @@ -22,9 +22,7 @@ void Boolean::Initialize(Loader& loader) { kBooleanValue); } -Class Boolean::GetClass() { - return Class(g_clazz); -} +Class Boolean::GetClass() { return Class(g_clazz); } Local Boolean::Create(Env& env, bool value) { return env.New(kConstructor, value); diff --git a/firestore/src/jni/class.cc b/firestore/src/jni/class.cc index 4d11d62043..4a79a9680c 100644 --- a/firestore/src/jni/class.cc +++ b/firestore/src/jni/class.cc @@ -28,9 +28,7 @@ std::string Class::GetClassName(Env& env, const Object& object) { return util::JObjectClassName(env.get(), object.get()); } -bool Class::IsArray(Env& env) const { - return env.Call(*this, kIsArray); -} +bool Class::IsArray(Env& env) const { return env.Call(*this, kIsArray); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/class.h b/firestore/src/jni/class.h index 528ed4d371..9892a3839c 100644 --- a/firestore/src/jni/class.h +++ b/firestore/src/jni/class.h @@ -21,12 +21,9 @@ namespace jni { class Class : public Object { public: Class() = default; - explicit Class(jclass clazz) : Object(clazz) { - } + explicit Class(jclass clazz) : Object(clazz) {} - jclass get() const override { - return static_cast(object_); - } + jclass get() const override { return static_cast(object_); } /** * Returns the name of the class, as returned by the Java `Class.name` method. diff --git a/firestore/src/jni/collection.cc b/firestore/src/jni/collection.cc index 2515ca42a1..a3ca074398 100644 --- a/firestore/src/jni/collection.cc +++ b/firestore/src/jni/collection.cc @@ -29,9 +29,7 @@ Local Collection::Iterator(Env& env) { return env.Call(*this, kIterator); } -size_t Collection::Size(Env& env) const { - return env.Call(*this, kSize); -} +size_t Collection::Size(Env& env) const { return env.Call(*this, kSize); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/declaration.h b/firestore/src/jni/declaration.h index 0ef16c76c1..88a9f78a5b 100644 --- a/firestore/src/jni/declaration.h +++ b/firestore/src/jni/declaration.h @@ -22,18 +22,12 @@ class ConstructorBase { * the string. The internal method ID should be populated later with a call to * `Loader::Load`. */ - constexpr explicit ConstructorBase(const char* sig) : sig_(sig) { - } + constexpr explicit ConstructorBase(const char* sig) : sig_(sig) {} - ConstructorBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) { - } + ConstructorBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) {} - jclass clazz() const { - return clazz_; - } - jmethodID id() const { - return id_; - } + jclass clazz() const { return clazz_; } + jmethodID id() const { return id_; } private: friend class Loader; @@ -68,15 +62,11 @@ class MethodBase { * to `Loader::Load`. */ constexpr MethodBase(const char* name, const char* sig) - : name_(name), sig_(sig) { - } + : name_(name), sig_(sig) {} - explicit MethodBase(jmethodID id) : id_(id) { - } + explicit MethodBase(jmethodID id) : id_(id) {} - jmethodID id() const { - return id_; - } + jmethodID id() const { return id_; } private: friend class Loader; @@ -112,19 +102,13 @@ class StaticFieldBase { * with a call to `Loader::Load`. */ constexpr StaticFieldBase(const char* name, const char* sig) - : name_(name), sig_(sig) { - } + : name_(name), sig_(sig) {} - explicit StaticFieldBase(jfieldID id) : id_(id) { - } + explicit StaticFieldBase(jfieldID id) : id_(id) {} - jclass clazz() const { - return clazz_; - } + jclass clazz() const { return clazz_; } - jfieldID id() const { - return id_; - } + jfieldID id() const { return id_; } private: friend class Loader; @@ -161,18 +145,12 @@ class StaticMethodBase { * with a call to `Loader::Load`. */ constexpr StaticMethodBase(const char* name, const char* sig) - : name_(name), sig_(sig) { - } - - StaticMethodBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) { - } - - jclass clazz() const { - return clazz_; - } - jmethodID id() const { - return id_; - } + : name_(name), sig_(sig) {} + + StaticMethodBase(jclass clazz, jmethodID id) : clazz_(clazz), id_(id) {} + + jclass clazz() const { return clazz_; } + jmethodID id() const { return id_; } private: friend class Loader; diff --git a/firestore/src/jni/double.cc b/firestore/src/jni/double.cc index 0e95e53076..4bfd0e1c3f 100644 --- a/firestore/src/jni/double.cc +++ b/firestore/src/jni/double.cc @@ -21,9 +21,7 @@ void Double::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kDoubleValue); } -Class Double::GetClass() { - return Class(g_clazz); -} +Class Double::GetClass() { return Class(g_clazz); } Local Double::Create(Env& env, double value) { return env.New(kConstructor, value); diff --git a/firestore/src/jni/env.cc b/firestore/src/jni/env.cc index bea2ac6ff2..e6bbf44d89 100644 --- a/firestore/src/jni/env.cc +++ b/firestore/src/jni/env.cc @@ -37,12 +37,10 @@ int CurrentExceptionCount() { } // namespace -Env::Env() : Env(GetEnv()) { -} +Env::Env() : Env(GetEnv()) {} Env::Env(JNIEnv* env) - : env_(env), initial_pending_exceptions_(CurrentExceptionCount()) { -} + : env_(env), initial_pending_exceptions_(CurrentExceptionCount()) {} Env::~Env() noexcept(false) { if (ok()) return; @@ -89,9 +87,7 @@ Local Env::ExceptionOccurred() { return Local(env_, exception); } -void Env::ExceptionClear() { - env_->ExceptionClear(); -} +void Env::ExceptionClear() { env_->ExceptionClear(); } Local Env::ClearExceptionOccurred() { Local result = ExceptionOccurred(); diff --git a/firestore/src/jni/env.h b/firestore/src/jni/env.h index 331a42a758..e9b7abbaa1 100644 --- a/firestore/src/jni/env.h +++ b/firestore/src/jni/env.h @@ -75,14 +75,10 @@ class Env { Env& operator=(Env&&) noexcept = default; /** Returns true if the Env has not encountered an exception. */ - bool ok() const { - return !env_->ExceptionCheck(); - } + bool ok() const { return !env_->ExceptionCheck(); } /** Returns the underlying JNIEnv pointer. */ - JNIEnv* get() const { - return env_; - } + JNIEnv* get() const { return env_; } // MARK: Class Operations @@ -545,8 +541,7 @@ class Env { class ExceptionClearGuard { public: explicit ExceptionClearGuard(Env& env) - : env_(env), exception_(env.ClearExceptionOccurred()) { - } + : env_(env), exception_(env.ClearExceptionOccurred()) {} ~ExceptionClearGuard() { if (exception_) { diff --git a/firestore/src/jni/hash_map.cc b/firestore/src/jni/hash_map.cc index 6221efde61..8fb06f1de7 100644 --- a/firestore/src/jni/hash_map.cc +++ b/firestore/src/jni/hash_map.cc @@ -19,9 +19,7 @@ void HashMap::Initialize(Loader& loader) { kConstructor); } -Local HashMap::Create(Env& env) { - return env.New(kConstructor); -} +Local HashMap::Create(Env& env) { return env.New(kConstructor); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/integer.cc b/firestore/src/jni/integer.cc index 8f0f9a538f..34ad7cb810 100644 --- a/firestore/src/jni/integer.cc +++ b/firestore/src/jni/integer.cc @@ -21,17 +21,13 @@ void Integer::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kIntValue); } -Class Integer::GetClass() { - return Class(g_clazz); -} +Class Integer::GetClass() { return Class(g_clazz); } Local Integer::Create(Env& env, int32_t value) { return env.New(kConstructor, value); } -int32_t Integer::IntValue(Env& env) const { - return env.Call(*this, kIntValue); -} +int32_t Integer::IntValue(Env& env) const { return env.Call(*this, kIntValue); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/iterator.cc b/firestore/src/jni/iterator.cc index d24e27b67c..e0d63b0955 100644 --- a/firestore/src/jni/iterator.cc +++ b/firestore/src/jni/iterator.cc @@ -20,13 +20,9 @@ void Iterator::Initialize(Loader& loader) { kNext); } -bool Iterator::HasNext(Env& env) const { - return env.Call(*this, kHasNext); -} +bool Iterator::HasNext(Env& env) const { return env.Call(*this, kHasNext); } -Local Iterator::Next(Env& env) { - return env.Call(*this, kNext); -} +Local Iterator::Next(Env& env) { return env.Call(*this, kNext); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/jni.cc b/firestore/src/jni/jni.cc index 9b14f5e3ee..6f070c9921 100644 --- a/firestore/src/jni/jni.cc +++ b/firestore/src/jni/jni.cc @@ -17,9 +17,7 @@ JavaVM* g_jvm = nullptr; * Reinterprets `JNIEnv**` out parameters to `void**` on platforms where that's * required. */ -void** EnvOut(JNIEnv** env) { - return reinterpret_cast(env); -} +void** EnvOut(JNIEnv** env) { return reinterpret_cast(env); } JavaVM* GetGlobalJavaVM() { // TODO(mcg): Use dlsym to call JNI_GetCreatedJavaVMs. diff --git a/firestore/src/jni/list.cc b/firestore/src/jni/list.cc index d94fefba76..b4de125fb3 100644 --- a/firestore/src/jni/list.cc +++ b/firestore/src/jni/list.cc @@ -20,9 +20,7 @@ void List::Initialize(Loader& loader) { loader.LoadFromExistingClass("java/util/List", g_clazz, kGet, kSet); } -Class List::GetClass() { - return Class(g_clazz); -} +Class List::GetClass() { return Class(g_clazz); } Local List::Get(Env& env, size_t i) const { return env.Call(*this, kGet, i); diff --git a/firestore/src/jni/loader.cc b/firestore/src/jni/loader.cc index f6715b2330..ec4f85dd13 100644 --- a/firestore/src/jni/loader.cc +++ b/firestore/src/jni/loader.cc @@ -24,9 +24,7 @@ Loader::Loader(App* app) : app_(app), env_(app->GetJNIEnv()) { Class::Initialize(*this); } -Loader::~Loader() { - Unload(); -} +Loader::~Loader() { Unload(); } void Loader::AddEmbeddedFile(const char* name, const unsigned char* data, diff --git a/firestore/src/jni/loader.h b/firestore/src/jni/loader.h index fecdb07e8e..6539e297f8 100644 --- a/firestore/src/jni/loader.h +++ b/firestore/src/jni/loader.h @@ -44,9 +44,7 @@ class Loader { * Returns true if the loader has succeeded. If not, any errors have already * been logged. */ - bool ok() const { - return ok_ && !env_->ExceptionCheck(); - } + bool ok() const { return ok_ && !env_->ExceptionCheck(); } /** * Adds metadata about embedded class files in the binary distribution. @@ -136,8 +134,7 @@ class Loader { Load(Forward(first)); LoadAll(Forward(rest)...); } - void LoadAll() { - } + void LoadAll() {} /** * Registers the given native methods with the JVM. diff --git a/firestore/src/jni/long.cc b/firestore/src/jni/long.cc index 2858263014..dbe8865847 100644 --- a/firestore/src/jni/long.cc +++ b/firestore/src/jni/long.cc @@ -21,17 +21,13 @@ void Long::Initialize(Loader& loader) { loader.LoadFromExistingClass(kClassName, g_clazz, kConstructor, kLongValue); } -Class Long::GetClass() { - return Class(g_clazz); -} +Class Long::GetClass() { return Class(g_clazz); } Local Long::Create(Env& env, int64_t value) { return env.New(kConstructor, value); } -int64_t Long::LongValue(Env& env) const { - return env.Call(*this, kLongValue); -} +int64_t Long::LongValue(Env& env) const { return env.Call(*this, kLongValue); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/map.cc b/firestore/src/jni/map.cc index 8f6281e7ed..ddc8be22ee 100644 --- a/firestore/src/jni/map.cc +++ b/firestore/src/jni/map.cc @@ -26,13 +26,9 @@ void Map::Initialize(Loader& loader) { kRemove, kKeySet); } -Class Map::GetClass() { - return Class(g_clazz); -} +Class Map::GetClass() { return Class(g_clazz); } -size_t Map::Size(Env& env) const { - return env.Call(*this, kSize); -} +size_t Map::Size(Env& env) const { return env.Call(*this, kSize); } Local Map::Get(Env& env, const Object& key) { return env.Call(*this, kGet, key); @@ -46,9 +42,7 @@ Local Map::Remove(Env& env, const Object& key) { return env.Call(*this, kRemove, key); } -Local Map::KeySet(Env& env) { - return env.Call(*this, kKeySet); -} +Local Map::KeySet(Env& env) { return env.Call(*this, kKeySet); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/object.cc b/firestore/src/jni/object.cc index 5ff301aa13..0e7f961fcd 100644 --- a/firestore/src/jni/object.cc +++ b/firestore/src/jni/object.cc @@ -22,9 +22,7 @@ void Object::Initialize(Loader& loader) { kToString); } -Class Object::GetClass() { - return Class(object_class); -} +Class Object::GetClass() { return Class(object_class); } std::string Object::ToString(Env& env) const { Local java_string = env.Call(*this, kToString); diff --git a/firestore/src/jni/object.h b/firestore/src/jni/object.h index c2f1eeac7d..f5735dc332 100644 --- a/firestore/src/jni/object.h +++ b/firestore/src/jni/object.h @@ -25,17 +25,12 @@ class Loader; class Object { public: Object() = default; - constexpr explicit Object(jobject object) : object_(object) { - } + constexpr explicit Object(jobject object) : object_(object) {} virtual ~Object() = default; - explicit operator bool() const { - return object_ != nullptr; - } + explicit operator bool() const { return object_ != nullptr; } - virtual jobject get() const { - return object_; - } + virtual jobject get() const { return object_; } static void Initialize(Loader& loader); diff --git a/firestore/src/jni/ownership.h b/firestore/src/jni/ownership.h index 8b1037e101..e7ff211a27 100644 --- a/firestore/src/jni/ownership.h +++ b/firestore/src/jni/ownership.h @@ -29,8 +29,7 @@ class Local : public T { /** * Adopts a local reference that is the result of a JNI invocation. */ - Local(JNIEnv* env, jni_type value) : T(value), env_(env) { - } + Local(JNIEnv* env, jni_type value) : T(value), env_(env) {} /** * An explicit copy constructor, which prevents accidental copies at function @@ -54,8 +53,7 @@ class Local : public T { return *this; } - Local(Local&& other) noexcept : T(other.release()), env_(other.env_) { - } + Local(Local&& other) noexcept : T(other.release()), env_(other.env_) {} Local& operator=(Local&& other) noexcept { if (T::object_ != other.get()) { @@ -114,9 +112,7 @@ class Local : public T { return Local(env_, release()); } - jni_type get() const override { - return static_cast(T::object_); - } + jni_type get() const override { return static_cast(T::object_); } jni_type release() { jobject result = T::object_; @@ -131,9 +127,7 @@ class Local : public T { } } - JNIEnv* env() const { - return env_; - } + JNIEnv* env() const { return env_; } private: void EnsureEnv(JNIEnv* other = nullptr) { @@ -172,8 +166,7 @@ class Global : public T { Global() = default; - Global(jni_type object, AdoptExisting) : T(object) { - } + Global(jni_type object, AdoptExisting) : T(object) {} Global(const Local& other) { JNIEnv* env = EnsureEnv(other.env()); @@ -207,16 +200,14 @@ class Global : public T { // Without this, the implicitly-defined copy constructor would be deleted, and // during overload resolution the deleted copy constructor would take priority // over the looser match above that takes `const T&`. - Global(const Global& other) : Global(static_cast(other)) { - } + Global(const Global& other) : Global(static_cast(other)) {} Global& operator=(const Global& other) { *this = static_cast(other); return *this; } - Global(Global&& other) noexcept : T(other.release()) { - } + Global(Global&& other) noexcept : T(other.release()) {} Global& operator=(Global&& other) noexcept { if (T::object_ != other.get()) { @@ -250,9 +241,7 @@ class Global : public T { } } - jni_type get() const override { - return static_cast(T::object_); - } + jni_type get() const override { return static_cast(T::object_); } jni_type release() { jobject result = T::object_; diff --git a/firestore/src/jni/string.cc b/firestore/src/jni/string.cc index 6253858a75..1144fcdc28 100644 --- a/firestore/src/jni/string.cc +++ b/firestore/src/jni/string.cc @@ -40,13 +40,9 @@ void String::Terminate(Env& env) { } } -Class String::GetClass() { - return Class(string_class); -} +Class String::GetClass() { return Class(string_class); } -String String::GetUtf8() { - return String(utf8_string); -} +String String::GetUtf8() { return String(utf8_string); } Local String::Create(Env& env, const Array& bytes, @@ -58,9 +54,7 @@ Local> String::GetBytes(Env& env, const String& encoding) const { return env.Call(*this, kGetBytes, encoding); } -std::string String::ToString(Env& env) const { - return env.ToStringUtf(*this); -} +std::string String::ToString(Env& env) const { return env.ToStringUtf(*this); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/string.h b/firestore/src/jni/string.h index 8368e09865..3961d83405 100644 --- a/firestore/src/jni/string.h +++ b/firestore/src/jni/string.h @@ -20,8 +20,7 @@ class Class; class String : public Object { public: String() = default; - explicit String(jstring string) : Object(string) { - } + explicit String(jstring string) : Object(string) {} /** * Creates a new Java String from the given bytes, using the given encoding. @@ -34,9 +33,7 @@ class String : public Object { const Array& bytes, const String& encoding); - jstring get() const override { - return static_cast(object_); - } + jstring get() const override { return static_cast(object_); } static void Initialize(Env& env, Loader& loader); static void Terminate(Env& env); diff --git a/firestore/src/jni/task.cc b/firestore/src/jni/task.cc index 57e8137d64..6608c11432 100644 --- a/firestore/src/jni/task.cc +++ b/firestore/src/jni/task.cc @@ -32,17 +32,13 @@ Local Task::GetException(Env& env) const { return env.Call(*this, kGetException); } -bool Task::IsComplete(Env& env) const { - return env.Call(*this, kIsComplete); -} +bool Task::IsComplete(Env& env) const { return env.Call(*this, kIsComplete); } bool Task::IsSuccessful(Env& env) const { return env.Call(*this, kIsSuccessful); } -bool Task::IsCanceled(Env& env) const { - return env.Call(*this, kIsCanceled); -} +bool Task::IsCanceled(Env& env) const { return env.Call(*this, kIsCanceled); } } // namespace jni } // namespace firestore diff --git a/firestore/src/jni/throwable.h b/firestore/src/jni/throwable.h index 56b7ff0be3..98091f2fb5 100644 --- a/firestore/src/jni/throwable.h +++ b/firestore/src/jni/throwable.h @@ -18,12 +18,9 @@ namespace jni { class Throwable : public Object { public: Throwable() = default; - explicit Throwable(jthrowable throwable) : Object(throwable) { - } + explicit Throwable(jthrowable throwable) : Object(throwable) {} - jthrowable get() const override { - return static_cast(object_); - } + jthrowable get() const override { return static_cast(object_); } /** * Gets the message associated with this throwable. diff --git a/firestore/src/jni/traits.h b/firestore/src/jni/traits.h index 83be3693e5..de05698d74 100644 --- a/firestore/src/jni/traits.h +++ b/firestore/src/jni/traits.h @@ -191,9 +191,7 @@ using nullptr_t = decltype(nullptr); using nullptr_t = std::nullptr_t; #endif -inline jobject RankedToJni(nullptr_t, ConverterChoice<2>) { - return nullptr; -} +inline jobject RankedToJni(nullptr_t, ConverterChoice<2>) { return nullptr; } /** * Converts wrapper types to JNI references by unwrapping them. diff --git a/firestore/src/main/collection_reference_main.cc b/firestore/src/main/collection_reference_main.cc index 543f118a94..b4ba34d57b 100644 --- a/firestore/src/main/collection_reference_main.cc +++ b/firestore/src/main/collection_reference_main.cc @@ -16,8 +16,7 @@ using core::ParsedSetData; CollectionReferenceInternal::CollectionReferenceInternal( api::CollectionReference&& collection) - : QueryInternal{std::move(collection)} { -} + : QueryInternal{std::move(collection)} {} const api::CollectionReference& CollectionReferenceInternal::collection_core_api() const { diff --git a/firestore/src/main/credentials_provider_desktop.cc b/firestore/src/main/credentials_provider_desktop.cc index e9c4243192..96a17ffdac 100644 --- a/firestore/src/main/credentials_provider_desktop.cc +++ b/firestore/src/main/credentials_provider_desktop.cc @@ -128,8 +128,7 @@ void OnToken(const Future& future_token, } // namespace FirebaseCppCredentialsProvider::FirebaseCppCredentialsProvider(App& app) - : contents_(std::make_shared(app)) { -} + : contents_(std::make_shared(app)) {} FirebaseCppCredentialsProvider::~FirebaseCppCredentialsProvider() { RemoveAuthStateListener(); diff --git a/firestore/src/main/credentials_provider_desktop.h b/firestore/src/main/credentials_provider_desktop.h index 03074f6b49..35d743a7a3 100644 --- a/firestore/src/main/credentials_provider_desktop.h +++ b/firestore/src/main/credentials_provider_desktop.h @@ -59,8 +59,7 @@ class FirebaseCppCredentialsProvider // the `GetToken` callback might be invoked after this credentials provider // has already been destroyed (Auth may outlive Firestore). struct Contents { - explicit Contents(App& app) : app(app) { - } + explicit Contents(App& app) : app(app) {} // FirebaseCppCredentialsProvider may be used by more than one thread. The // mutex is locked in all public member functions and none of the private diff --git a/firestore/src/main/document_change_main.cc b/firestore/src/main/document_change_main.cc index 3a61a42762..58700c6b0a 100644 --- a/firestore/src/main/document_change_main.cc +++ b/firestore/src/main/document_change_main.cc @@ -14,8 +14,7 @@ namespace firestore { using Type = DocumentChange::Type; DocumentChangeInternal::DocumentChangeInternal(api::DocumentChange&& change) - : change_{std::move(change)} { -} + : change_{std::move(change)} {} FirestoreInternal* DocumentChangeInternal::firestore_internal() { return GetFirestoreInternal(&change_); diff --git a/firestore/src/main/document_reference_main.cc b/firestore/src/main/document_reference_main.cc index 5c69faa918..9532693e9a 100644 --- a/firestore/src/main/document_reference_main.cc +++ b/firestore/src/main/document_reference_main.cc @@ -21,8 +21,7 @@ DocumentReferenceInternal::DocumentReferenceInternal( api::DocumentReference&& reference) : reference_{std::move(reference)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} { -} + user_data_converter_{&firestore_internal()->database_id()} {} Firestore* DocumentReferenceInternal::firestore() { return GetFirestore(&reference_); diff --git a/firestore/src/main/document_reference_main.h b/firestore/src/main/document_reference_main.h index 351c443013..bf2e71bafb 100644 --- a/firestore/src/main/document_reference_main.h +++ b/firestore/src/main/document_reference_main.h @@ -31,15 +31,9 @@ class DocumentReferenceInternal { Firestore* firestore(); FirestoreInternal* firestore_internal(); - const std::string& id() const { - return reference_.document_id(); - } - std::string path() const { - return reference_.Path(); - } - const model::DocumentKey& key() const { - return reference_.key(); - } + const std::string& id() const { return reference_.document_id(); } + std::string path() const { return reference_.Path(); } + const model::DocumentKey& key() const { return reference_.key(); } CollectionReference Parent(); CollectionReference Collection(const std::string& collection_path); diff --git a/firestore/src/main/document_snapshot_main.cc b/firestore/src/main/document_snapshot_main.cc index 5ff26de28a..084542cef2 100644 --- a/firestore/src/main/document_snapshot_main.cc +++ b/firestore/src/main/document_snapshot_main.cc @@ -23,8 +23,7 @@ using model::DocumentKey; DocumentSnapshotInternal::DocumentSnapshotInternal( api::DocumentSnapshot&& snapshot) - : snapshot_{std::move(snapshot)} { -} + : snapshot_{std::move(snapshot)} {} Firestore* DocumentSnapshotInternal::firestore() { return GetFirestore(&snapshot_); @@ -51,9 +50,7 @@ SnapshotMetadata DocumentSnapshotInternal::metadata() const { return SnapshotMetadata{result.pending_writes(), result.from_cache()}; } -bool DocumentSnapshotInternal::exists() const { - return snapshot_.exists(); -} +bool DocumentSnapshotInternal::exists() const { return snapshot_.exists(); } MapFieldValue DocumentSnapshotInternal::GetData( ServerTimestampBehavior stb) const { diff --git a/firestore/src/main/field_value_main.cc b/firestore/src/main/field_value_main.cc index 38680d3929..f09530d73d 100644 --- a/firestore/src/main/field_value_main.cc +++ b/firestore/src/main/field_value_main.cc @@ -22,46 +22,37 @@ using Type = FieldValue::Type; // Constructors FieldValueInternal::FieldValueInternal(bool value) - : type_{Type::kBoolean}, value_{model::FieldValue::FromBoolean(value)} { -} + : type_{Type::kBoolean}, value_{model::FieldValue::FromBoolean(value)} {} FieldValueInternal::FieldValueInternal(int64_t value) - : type_{Type::kInteger}, value_{model::FieldValue::FromInteger(value)} { -} + : type_{Type::kInteger}, value_{model::FieldValue::FromInteger(value)} {} FieldValueInternal::FieldValueInternal(double value) - : type_{Type::kDouble}, value_{model::FieldValue::FromDouble(value)} { -} + : type_{Type::kDouble}, value_{model::FieldValue::FromDouble(value)} {} FieldValueInternal::FieldValueInternal(Timestamp value) - : type_{Type::kTimestamp}, value_{model::FieldValue::FromTimestamp(value)} { -} + : type_{Type::kTimestamp}, + value_{model::FieldValue::FromTimestamp(value)} {} FieldValueInternal::FieldValueInternal(std::string value) : type_{Type::kString}, - value_{model::FieldValue::FromString(std::move(value))} { -} + value_{model::FieldValue::FromString(std::move(value))} {} FieldValueInternal::FieldValueInternal(const uint8_t* value, size_t size) : type_{Type::kBlob}, - value_{model::FieldValue::FromBlob(ByteString{value, size})} { -} + value_{model::FieldValue::FromBlob(ByteString{value, size})} {} FieldValueInternal::FieldValueInternal(DocumentReference value) - : type_{Type::kReference}, value_{std::move(value)} { -} + : type_{Type::kReference}, value_{std::move(value)} {} FieldValueInternal::FieldValueInternal(GeoPoint value) - : type_{Type::kGeoPoint}, value_{model::FieldValue::FromGeoPoint(value)} { -} + : type_{Type::kGeoPoint}, value_{model::FieldValue::FromGeoPoint(value)} {} FieldValueInternal::FieldValueInternal(std::vector value) - : type_{Type::kArray}, value_{std::move(value)} { -} + : type_{Type::kArray}, value_{std::move(value)} {} FieldValueInternal::FieldValueInternal(MapFieldValue value) - : type_{Type::kMap}, value_{std::move(value)} { -} + : type_{Type::kMap}, value_{std::move(value)} {} // Accessors diff --git a/firestore/src/main/field_value_main.h b/firestore/src/main/field_value_main.h index 0461b466e3..93b52e9faa 100644 --- a/firestore/src/main/field_value_main.h +++ b/firestore/src/main/field_value_main.h @@ -32,9 +32,7 @@ class FieldValueInternal { explicit FieldValueInternal(std::vector value); explicit FieldValueInternal(MapFieldValue value); - FieldValue::Type type() const { - return type_; - } + FieldValue::Type type() const { return type_; } bool boolean_value() const; int64_t integer_value() const; @@ -70,8 +68,7 @@ class FieldValueInternal { template explicit FieldValueInternal(FieldValue::Type type, T value) - : type_{type}, value_{std::move(value)} { - } + : type_{type}, value_{std::move(value)} {} FieldValue::Type type_ = FieldValue::Type::kNull; // Note: it's impossible to roundtrip between a `DocumentReference` and diff --git a/firestore/src/main/firestore_main.cc b/firestore/src/main/firestore_main.cc index 4ddadfddd0..e8f1037b05 100644 --- a/firestore/src/main/firestore_main.cc +++ b/firestore/src/main/firestore_main.cc @@ -68,8 +68,7 @@ LoadBundleTaskProgress ToApiProgress( } // namespace FirestoreInternal::FirestoreInternal(App* app) - : FirestoreInternal{app, CreateCredentialsProvider(*app)} { -} + : FirestoreInternal{app, CreateCredentialsProvider(*app)} {} FirestoreInternal::FirestoreInternal( App* app, std::unique_ptr credentials) diff --git a/firestore/src/main/firestore_main.h b/firestore/src/main/firestore_main.h index 8c3338cdbb..23e3dfb705 100644 --- a/firestore/src/main/firestore_main.h +++ b/firestore/src/main/firestore_main.h @@ -41,25 +41,17 @@ class FirestoreInternal { FirestoreInternal(const FirestoreInternal&) = delete; FirestoreInternal& operator=(const FirestoreInternal&) = delete; - App* app() const { - return app_; - } + App* app() const { return app_; } // Whether this object was successfully initialized by the constructor. - bool initialized() const { - return app_ != nullptr; - } + bool initialized() const { return app_ != nullptr; } // Manages all Future objects returned from Firestore API. - FutureManager& future_manager() { - return future_manager_; - } + FutureManager& future_manager() { return future_manager_; } // When this is deleted, it will clean up all DatabaseReferences, // DataSnapshots, and other such objects. - CleanupNotifier& cleanup() { - return cleanup_; - } + CleanupNotifier& cleanup() { return cleanup_; } CollectionReference Collection(const char* collection_path) const; @@ -111,12 +103,8 @@ class FirestoreInternal { firestore_public_ = firestore_public; } - Firestore* firestore_public() { - return firestore_public_; - } - const Firestore* firestore_public() const { - return firestore_public_; - } + Firestore* firestore_public() { return firestore_public_; } + const Firestore* firestore_public() const { return firestore_public_; } const std::shared_ptr& firestore_core() const { return firestore_core_; diff --git a/firestore/src/main/listener_registration_main.cc b/firestore/src/main/listener_registration_main.cc index 8ce9cce6c2..c8d3bfdcd1 100644 --- a/firestore/src/main/listener_registration_main.cc +++ b/firestore/src/main/listener_registration_main.cc @@ -14,9 +14,7 @@ ListenerRegistrationInternal::ListenerRegistrationInternal( firestore->RegisterListenerRegistration(this); } -ListenerRegistrationInternal::~ListenerRegistrationInternal() { - Remove(); -} +ListenerRegistrationInternal::~ListenerRegistrationInternal() { Remove(); } } // namespace firestore } // namespace firebase diff --git a/firestore/src/main/listener_registration_main.h b/firestore/src/main/listener_registration_main.h index d9350e98df..a3e904dc54 100644 --- a/firestore/src/main/listener_registration_main.h +++ b/firestore/src/main/listener_registration_main.h @@ -20,16 +20,12 @@ class ListenerRegistrationInternal { ListenerRegistrationInternal& operator=(const ListenerRegistrationInternal&) = delete; - FirestoreInternal* firestore_internal() { - return firestore_; - } + FirestoreInternal* firestore_internal() { return firestore_; } private: friend class FirestoreInternal; - void Remove() { - registration_->Remove(); - } + void Remove() { registration_->Remove(); } std::unique_ptr registration_; FirestoreInternal* firestore_ = nullptr; diff --git a/firestore/src/main/promise_factory_main.h b/firestore/src/main/promise_factory_main.h index 6cc4125905..4ca6108a84 100644 --- a/firestore/src/main/promise_factory_main.h +++ b/firestore/src/main/promise_factory_main.h @@ -34,9 +34,7 @@ class PromiseFactory { future_manager_->AllocFutureApi(this, ApisCount()); } - ~PromiseFactory() { - future_manager_->ReleaseFutureApi(this); - } + ~PromiseFactory() { future_manager_->ReleaseFutureApi(this); } PromiseFactory(const PromiseFactory& rhs) : cleanup_{rhs.cleanup_}, future_manager_{rhs.future_manager_} { @@ -61,9 +59,7 @@ class PromiseFactory { return future_manager_->GetFutureApi(this); } - int ApisCount() const { - return static_cast(ApiEnum::kCount); - } + int ApisCount() const { return static_cast(ApiEnum::kCount); } CleanupNotifier* cleanup_ = nullptr; FutureManager* future_manager_ = nullptr; diff --git a/firestore/src/main/promise_main.h b/firestore/src/main/promise_main.h index 51a12bd6bf..3d0d2a7f82 100644 --- a/firestore/src/main/promise_main.h +++ b/firestore/src/main/promise_main.h @@ -147,9 +147,7 @@ class Promise { private: Promise() = default; - int NoError() const { - return static_cast(Error::kErrorOk); - } + int NoError() const { return static_cast(Error::kErrorOk); } void Reset() { cleanup_ = nullptr; @@ -189,9 +187,7 @@ class Promise { cleanup_->UnregisterObject(this); } - bool IsCleanedUp() const { - return cleanup_ == nullptr; - } + bool IsCleanedUp() const { return cleanup_ == nullptr; } CleanupNotifier* cleanup_ = nullptr; ReferenceCountedFutureImpl* future_api_ = nullptr; diff --git a/firestore/src/main/query_main.cc b/firestore/src/main/query_main.cc index 1b0665bfd9..4868576c66 100644 --- a/firestore/src/main/query_main.cc +++ b/firestore/src/main/query_main.cc @@ -31,12 +31,9 @@ using model::ResourcePath; QueryInternal::QueryInternal(api::Query&& query) : query_{std::move(query)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} { -} + user_data_converter_{&firestore_internal()->database_id()} {} -Firestore* QueryInternal::firestore() { - return GetFirestore(&query_); -} +Firestore* QueryInternal::firestore() { return GetFirestore(&query_); } FirestoreInternal* QueryInternal::firestore_internal() { return GetFirestoreInternal(&query_); diff --git a/firestore/src/main/query_main.h b/firestore/src/main/query_main.h index 558de84c5b..464041501e 100644 --- a/firestore/src/main/query_main.h +++ b/firestore/src/main/query_main.h @@ -146,15 +146,9 @@ class QueryInternal { kCount, }; - const api::Query& query_core_api() const { - return query_; - } - const UserDataConverter& converter() const { - return user_data_converter_; - } - PromiseFactory& promise_factory() { - return promise_factory_; - } + const api::Query& query_core_api() const { return query_; } + const UserDataConverter& converter() const { return user_data_converter_; } + PromiseFactory& promise_factory() { return promise_factory_; } private: enum class BoundPosition { diff --git a/firestore/src/main/query_snapshot_main.cc b/firestore/src/main/query_snapshot_main.cc index 51240a83dd..1fac6da602 100644 --- a/firestore/src/main/query_snapshot_main.cc +++ b/firestore/src/main/query_snapshot_main.cc @@ -12,8 +12,7 @@ namespace firebase { namespace firestore { QuerySnapshotInternal::QuerySnapshotInternal(api::QuerySnapshot&& snapshot) - : snapshot_{std::move(snapshot)} { -} + : snapshot_{std::move(snapshot)} {} FirestoreInternal* QuerySnapshotInternal::firestore_internal() { return GetFirestoreInternal(&snapshot_); @@ -28,9 +27,7 @@ SnapshotMetadata QuerySnapshotInternal::metadata() const { return SnapshotMetadata{result.pending_writes(), result.from_cache()}; } -std::size_t QuerySnapshotInternal::size() const { - return snapshot_.size(); -} +std::size_t QuerySnapshotInternal::size() const { return snapshot_.size(); } std::vector QuerySnapshotInternal::DocumentChanges( MetadataChanges metadata_changes) const { diff --git a/firestore/src/main/set_options_main.h b/firestore/src/main/set_options_main.h index 0baa18b3c3..95460d3d93 100644 --- a/firestore/src/main/set_options_main.h +++ b/firestore/src/main/set_options_main.h @@ -18,15 +18,10 @@ class SetOptionsInternal { using Type = SetOptions::Type; explicit SetOptionsInternal(SetOptions options) - : options_{std::move(options)} { - } - - Type type() const { - return options_.type_; - } - const std::vector& field_mask() const { - return options_.fields_; - } + : options_{std::move(options)} {} + + Type type() const { return options_.type_; } + const std::vector& field_mask() const { return options_.fields_; } private: SetOptions options_; diff --git a/firestore/src/main/transaction_main.cc b/firestore/src/main/transaction_main.cc index 11acfbcf8d..5021d487a9 100644 --- a/firestore/src/main/transaction_main.cc +++ b/firestore/src/main/transaction_main.cc @@ -78,8 +78,7 @@ TransactionInternal::TransactionInternal( FirestoreInternal* firestore_internal) : transaction_{std::move(NOT_NULL(transaction))}, firestore_internal_{NOT_NULL(firestore_internal)}, - user_data_converter_{&firestore_internal->database_id()} { -} + user_data_converter_{&firestore_internal->database_id()} {} Firestore* TransactionInternal::firestore() { return Firestore::GetInstance(firestore_internal_->app()); diff --git a/firestore/src/main/user_data_converter_main.h b/firestore/src/main/user_data_converter_main.h index 96a0c6f3f4..8285598d62 100644 --- a/firestore/src/main/user_data_converter_main.h +++ b/firestore/src/main/user_data_converter_main.h @@ -27,8 +27,7 @@ class ParseContext; class UserDataConverter { public: explicit UserDataConverter(const model::DatabaseId* database_id) - : database_id_{database_id} { - } + : database_id_{database_id} {} /** Parse document data from a non-merge `SetData` call. */ core::ParsedSetData ParseSetData(const MapFieldValue& input) const; diff --git a/firestore/src/main/write_batch_main.cc b/firestore/src/main/write_batch_main.cc index 7f8c6ee7aa..0028f0ad5f 100644 --- a/firestore/src/main/write_batch_main.cc +++ b/firestore/src/main/write_batch_main.cc @@ -20,12 +20,9 @@ using core::ParsedUpdateData; WriteBatchInternal::WriteBatchInternal(api::WriteBatch&& batch) : batch_{std::move(batch)}, promise_factory_{PromiseFactory::Create(this)}, - user_data_converter_{&firestore_internal()->database_id()} { -} + user_data_converter_{&firestore_internal()->database_id()} {} -Firestore* WriteBatchInternal::firestore() { - return GetFirestore(&batch_); -} +Firestore* WriteBatchInternal::firestore() { return GetFirestore(&batch_); } FirestoreInternal* WriteBatchInternal::firestore_internal() { return GetFirestoreInternal(&batch_); diff --git a/firestore/src/stub/transaction_stub.h b/firestore/src/stub/transaction_stub.h index 2c9a13415e..03cff3c979 100644 --- a/firestore/src/stub/transaction_stub.h +++ b/firestore/src/stub/transaction_stub.h @@ -16,7 +16,8 @@ class TransactionInternal { TransactionInternal() {} FirestoreInternal* firestore_internal() const { return nullptr; } - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options) {} void Update(const DocumentReference& document, const MapFieldValue& data) {} @@ -26,7 +27,8 @@ class TransactionInternal { void Delete(const DocumentReference& document) {} - DocumentSnapshot Get(const DocumentReference& document, Error* error_code, + DocumentSnapshot Get(const DocumentReference& document, + Error* error_code, std::string* error_message) { return DocumentSnapshot{}; } diff --git a/firestore/src/stub/write_batch_stub.h b/firestore/src/stub/write_batch_stub.h index d69a0a3496..7eb944cdd5 100644 --- a/firestore/src/stub/write_batch_stub.h +++ b/firestore/src/stub/write_batch_stub.h @@ -17,7 +17,8 @@ class WriteBatchInternal { WriteBatchInternal() {} FirestoreInternal* firestore_internal() const { return nullptr; } - void Set(const DocumentReference& document, const MapFieldValue& data, + void Set(const DocumentReference& document, + const MapFieldValue& data, const SetOptions& options) {} void Update(const DocumentReference& document, const MapFieldValue& data) {}