Skip to content

Commit

Permalink
Cleanup a lot of warnings (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire authored Apr 26, 2024
1 parent 082bf7e commit e718cc8
Show file tree
Hide file tree
Showing 43 changed files with 177 additions and 197 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ endif()
target_link_libraries(cpprealm PUBLIC Realm::ObjectStore)
set(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT_PATH})

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(cpprealm PRIVATE -Wall -Wextra -pedantic -Werror)
endif()

if(APPLE OR MSVC)
target_sources(cpprealm PRIVATE src/cpprealm/internal/network/network_transport.cpp)
elseif(ANDROID)
Expand Down Expand Up @@ -142,7 +146,7 @@ include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "1.0.0"
VERSION "${REALMCXX_VERSION}"
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/Config.cmake.in
Expand Down Expand Up @@ -174,5 +178,6 @@ if (BUILD_SHARED_LIBS)
endif()

if (NOT REALM_CPP_NO_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
25 changes: 12 additions & 13 deletions include/cpprealm/accessors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ namespace realm {
template <typename T>
struct accessor<std::vector<T>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm&,
const std::vector<T>& value) {
obj.set_list_values(key, value);
Expand All @@ -287,7 +287,7 @@ namespace realm {
template <typename T>
struct accessor<std::vector<T*>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm& realm,
const std::vector<T*>& value) {
auto list = obj.get_linklist(key);
Expand Down Expand Up @@ -320,7 +320,7 @@ namespace realm {
template <typename T>
struct accessor<std::set<T>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm& realm,
const std::set<T>& value) {
auto set = realm::internal::bridge::set(realm, obj, key);
Expand All @@ -332,7 +332,7 @@ namespace realm {
template <typename T>
struct accessor<std::set<T*>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm& realm,
const std::set<T*>& value) {
auto set = realm::internal::bridge::set(realm, obj, key);
Expand Down Expand Up @@ -362,7 +362,7 @@ namespace realm {
template <typename T>
struct accessor<std::map<std::string, T>> {
static void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm&,
const std::map<std::string, T>& value) {
auto d = obj.get_dictionary(key);
Expand All @@ -375,7 +375,6 @@ namespace realm {
} else {
if constexpr (internal::type_info::is_optional<T>::value) {
if constexpr (std::is_enum_v<typename T::value_type>) {
using U = typename internal::type_info::type_info<T, void>::internal_type;
if (v) {
d.insert(k, static_cast<typename std::underlying_type<typename T::value_type>::type>(*v));
} else {
Expand All @@ -396,7 +395,7 @@ namespace realm {
template <typename T>
struct accessor<std::map<std::string, T*>> {
static void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm& realm,
const std::map<std::string, T*>& value) {
auto d = obj.get_dictionary(key);
Expand Down Expand Up @@ -426,9 +425,9 @@ namespace realm {
template <typename T>
struct accessor<T*> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm& realm,
T* value) {
const T* value) {
if (!value) {
return;
}
Expand All @@ -454,17 +453,17 @@ namespace realm {

template <auto T>
struct accessor<linking_objects<T>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
static inline void set(const internal::bridge::obj&,
const internal::bridge::col_key&,
const internal::bridge::realm&,
linking_objects<T> value) {
const linking_objects<T>&) {
}
};
// MARK: - accessor primary key
template <typename T>
struct accessor<primary_key<T>> {
static inline void set(internal::bridge::obj& obj,
internal::bridge::col_key&& key,
const internal::bridge::col_key& key,
const internal::bridge::realm&,
const primary_key<T>& value) {
if constexpr (std::is_enum_v<T>) {
Expand Down
8 changes: 2 additions & 6 deletions include/cpprealm/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ struct user {
{
db_config config;
config.set_sync_config(sync_config(m_user));
config.sync_config().set_error_handler([](const sync_session& session, const internal::bridge::sync_error& error) {
std::cerr<<"sync error: "<<error.message()<<std::endl;
config.sync_config().set_error_handler([](const sync_session&, const internal::bridge::sync_error& error) {
std::cerr<<"ADS C++ SDK: Sync Error: " << error.message() << "\n";
});
config.set_path(sync_manager().path_for_realm(config.sync_config()));
config.sync_config().set_stop_policy(realm::internal::bridge::realm::sync_session_stop_policy::after_changes_uploaded);
Expand Down Expand Up @@ -227,10 +227,6 @@ struct user {
bool operator==(const user& lhs, const user& rhs);
bool operator!=(const user& lhs, const user& rhs);

namespace util {
template <class T>
class TaggedString;
}
namespace app {
struct AppCredentials;
}
Expand Down
2 changes: 1 addition & 1 deletion include/cpprealm/bson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace realm {
private:
friend struct bsoncxx;
explicit value(CoreDocument* d, const std::string& k)
: m_document(d), key(k) {};
: key(k), m_document(d) {}
CoreDocument* m_document;
};

Expand Down
2 changes: 1 addition & 1 deletion include/cpprealm/flex_sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace realm {
template <typename>
struct object;
struct rbool;
class rbool;

namespace sync {
class MutableSubscriptionSet;
Expand Down
4 changes: 2 additions & 2 deletions include/cpprealm/internal/bridge/decimal128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace realm {
}

namespace realm::internal::bridge {
struct decimal128 : core_binding<Decimal128> {
struct decimal128 {
decimal128() = default;
decimal128(const decimal128& other) ;
decimal128& operator=(const decimal128& other) ;
Expand All @@ -38,7 +38,7 @@ namespace realm::internal::bridge {
explicit decimal128(const std::string&);
decimal128(const double&);
decimal128(const struct ::realm::decimal128&); //NOLINT(google-explicit-constructor);
operator Decimal128() const final; //NOLINT(google-explicit-constructor);
operator Decimal128() const; //NOLINT(google-explicit-constructor);
operator ::realm::decimal128() const; //NOLINT(google-explicit-constructor);
std::string to_string() const;
bool is_NaN() const;
Expand Down
4 changes: 2 additions & 2 deletions include/cpprealm/internal/bridge/object_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace realm {
}

namespace realm::internal::bridge {
struct object_id : core_binding<ObjectId> {
struct object_id {
object_id();
object_id(const object_id& other) = default;
object_id& operator=(const object_id& other) = default;
Expand All @@ -38,7 +38,7 @@ namespace realm::internal::bridge {
object_id(const ObjectId&); //NOLINT(google-explicit-constructor);
explicit object_id(const std::string&);
object_id(const struct ::realm::object_id&); //NOLINT(google-explicit-constructor);
operator ObjectId() const final; //NOLINT(google-explicit-constructor);
operator ObjectId() const; //NOLINT(google-explicit-constructor);
operator ::realm::object_id() const; //NOLINT(google-explicit-constructor);
[[nodiscard]] std::string to_string() const;
[[nodiscard]] static object_id generate();
Expand Down
6 changes: 5 additions & 1 deletion include/cpprealm/internal/bridge/property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace realm::internal::bridge {
struct col_key;

struct property {
enum class type {
enum class type : unsigned short {
Int = 0,
Bool = 1,
String = 2,
Expand Down Expand Up @@ -102,6 +102,10 @@ namespace realm::internal::bridge {
{
return static_cast<property::type>(to_underlying(a) & to_underlying(b));
}

inline constexpr bool property_has_flag(property::type property, property::type flag) {
return static_cast<bool>(property & flag);
}
}

#endif //CPPREALM_BRIDGE_PROPERTY_HPP
4 changes: 2 additions & 2 deletions include/cpprealm/internal/bridge/sync_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

namespace realm {
class SyncManager;
struct App;
class App;
struct user;

namespace internal::bridge {
struct sync_manager {
[[nodiscard]] std::string path_for_realm(const realm::sync_config&) const;
void set_log_level(logger::level);
private:
friend struct ::realm::App;
friend class ::realm::App;
friend struct ::realm::user;
sync_manager(const std::shared_ptr<SyncManager> &);
std::shared_ptr<SyncManager> m_manager;
Expand Down
4 changes: 2 additions & 2 deletions include/cpprealm/internal/bridge/timestamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ namespace realm {
}

namespace realm::internal::bridge {
struct timestamp : core_binding<Timestamp> {
struct timestamp {
timestamp() = default;
timestamp(const timestamp& other) = default;
timestamp& operator=(const timestamp& other) = default;
timestamp(timestamp&& other) = default;
timestamp& operator=(timestamp&& other) = default;
~timestamp() = default;
timestamp(const Timestamp&); //NOLINT(google-explicit-constructor)
operator Timestamp() const final; //NOLINT(google-explicit-constructor)
operator Timestamp() const; //NOLINT(google-explicit-constructor)
operator std::chrono::time_point<std::chrono::system_clock>() const; //NOLINT(google-explicit-constructor)
timestamp(int64_t seconds, int32_t nanoseconds);
timestamp(const std::chrono::time_point<std::chrono::system_clock>& tp); //NOLINT(google-explicit-constructor)
Expand Down
6 changes: 0 additions & 6 deletions include/cpprealm/internal/bridge/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ namespace realm::internal::bridge {
template <typename Left, typename Right>
struct LayoutCheck<Left, Right, std::enable_if_t<(sizeof(Left) == sizeof(Right) && alignof(Left) == alignof(Right))>> : std::true_type {
};

template <typename T>
struct core_binding {
using underlying = T;
virtual operator T() const = 0; //NOLINT(google-explicit-constructor);
};
}

#endif //CPPREALM_BRIDGE_UTILS_HPP
4 changes: 2 additions & 2 deletions include/cpprealm/internal/bridge/uuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace realm {
}

namespace realm::internal::bridge {
struct uuid : core_binding<UUID> {
struct uuid {
uuid();
uuid(const uuid& other) = default;
uuid& operator=(const uuid& other) = default;
Expand All @@ -40,7 +40,7 @@ namespace realm::internal::bridge {
explicit uuid(const std::string&);
uuid(const std::array<uint8_t, 16>&);
uuid(const struct ::realm::uuid&); //NOLINT(google-explicit-constructor);
operator UUID() const final; //NOLINT(google-explicit-constructor);
operator UUID() const; //NOLINT(google-explicit-constructor);
operator ::realm::uuid() const; //NOLINT(google-explicit-constructor);
[[nodiscard]] std::string to_string() const;
[[nodiscard]] std::string to_base64() const;
Expand Down
2 changes: 1 addition & 1 deletion include/cpprealm/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace realm {
};
ref_type operator ->() const {
if (this->m_rbool_query) {
this->m_rbool_query->add_link_chain(m_realm, m_key);
this->m_rbool_query->add_link_chain(m_key);
return ref_type(managed<T>::prepare_for_query(*m_realm, this->m_rbool_query));
}
return ref_type(managed<T>(m_obj->get_linked_object(m_key), *m_realm));
Expand Down
6 changes: 3 additions & 3 deletions include/cpprealm/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ rbool managed<std::optional<type>>::operator op(const std::optional<type>& rhs)
return v; \
} \
auto observe(std::function<void(realm::object_change<managed>&&)>&& fn) { \
auto m_object = std::make_shared<internal::bridge::object>(m_realm, m_obj); \
auto wrapper = realm::ObjectChangeCallbackWrapper<managed>{ \
auto m_object = std::make_shared<internal::bridge::object>(m_realm, m_obj); \
auto wrapper = realm::object_change_callback_wrapper<managed>{ \
std::move(fn), this, m_object}; \
return m_object->add_notification_callback( \
std::make_shared<realm::ObjectChangeCallbackWrapper<managed>>(wrapper)); \
std::make_shared<realm::object_change_callback_wrapper<managed>>(wrapper)); \
} \
bool is_invalidated() { \
return !m_obj.is_valid(); \
Expand Down
2 changes: 1 addition & 1 deletion include/cpprealm/managed_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace realm {
false));
token.m_realm = *m_realm;
token.m_list = list;
return std::move(token);
return token;
}

// TODO: emulate a reference to the value.
Expand Down
6 changes: 3 additions & 3 deletions include/cpprealm/managed_mixed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ namespace realm {
return detach() != rhs;
}

rbool operator==(const std::nullopt_t& rhs) const noexcept {
rbool operator==(const std::nullopt_t&) const noexcept {
if (this->m_rbool_query) {
return this->m_rbool_query->mixed_equal(m_key, internal::bridge::mixed(std::monostate()));
}
return detach() == T(std::monostate());
}

rbool operator!=(const std::nullopt_t& rhs) const noexcept {
rbool operator!=(const std::nullopt_t&) const noexcept {
if (this->m_rbool_query) {
return this->m_rbool_query->mixed_not_equal(m_key, internal::bridge::mixed(std::monostate()));
}
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace realm {
};

template<typename T, typename Types>
const bool holds_alternative(const realm::managed<Types>& v) noexcept {
bool holds_alternative(const realm::managed<Types>& v) noexcept {
auto val = v.get_stored_type();
switch (val) {
case realm::managed<Types>::stored_type::Int:
Expand Down
4 changes: 2 additions & 2 deletions include/cpprealm/managed_numeric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ namespace realm {
friend struct managed; \
}; \

CPP_REALM_MANAGED_OPTIONAL_NUMERIC(int64_t);
CPP_REALM_MANAGED_OPTIONAL_NUMERIC(double);
CPP_REALM_MANAGED_OPTIONAL_NUMERIC(int64_t)
CPP_REALM_MANAGED_OPTIONAL_NUMERIC(double)

template<>
struct managed<std::optional<bool>> : managed_base {
Expand Down
8 changes: 4 additions & 4 deletions include/cpprealm/managed_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace realm {
}
}

iterator insert(const iterator& i, const T& v)
iterator insert(const iterator&, const T& v)
{
auto set = internal::bridge::set(*m_realm, *m_obj, m_key);
std::pair<size_t, bool> res = set.insert(v);
Expand Down Expand Up @@ -285,7 +285,7 @@ namespace realm {
return std::pair<iterator, bool>(iterator(res.first, this), res.second);
}

iterator insert(const iterator& i, T* value)
iterator insert(const iterator&, T* value)
{
auto set = internal::bridge::set(*m_realm, *m_obj, m_key);
auto table = m_obj->get_target_table(m_key);
Expand Down Expand Up @@ -313,7 +313,7 @@ namespace realm {

}

iterator insert(const iterator& i, const managed<T>& value)
iterator insert(const iterator&, const managed<T>& value)
{
auto set = internal::bridge::set(*m_realm, *m_obj, m_key);
std::pair<size_t, bool> res = set.insert(value.m_obj.get_key());
Expand All @@ -328,7 +328,7 @@ namespace realm {

}

iterator insert(const iterator& i, const managed<T*>& value)
iterator insert(const iterator&, const managed<T*>& value)
{
auto set = internal::bridge::set(*m_realm, *m_obj, m_key);
std::pair<size_t, bool> res = set.insert(value.m_obj.get_key());
Expand Down
Loading

0 comments on commit e718cc8

Please sign in to comment.