mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Removed platform types dependency from windows platform codes
PiperOrigin-RevId: 676447748
This commit is contained in:
committed by
Copybara-Service
parent
a9e753e1e1
commit
47f2dfec28
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "internal/platform/implementation/windows/preferences_manager.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem> // NOLINT(build/c++17)
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -21,11 +22,16 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "nlohmann/json_fwd.hpp"
|
||||
#include "internal/base/files.h"
|
||||
#include "internal/platform/implementation/platform.h"
|
||||
#include "internal/platform/implementation/preferences_manager.h"
|
||||
#include "internal/platform/implementation/windows/preferences_repository.h"
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
@@ -190,7 +196,7 @@ void PreferencesManager::Remove(absl::string_view key) {
|
||||
// Writes data to storage.
|
||||
bool PreferencesManager::Commit() {
|
||||
if (!preferences_repository_->SavePreferences(value_)) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to save preference." << std::endl;
|
||||
LOG(ERROR) << "Failed to save preference." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -198,8 +204,8 @@ bool PreferencesManager::Commit() {
|
||||
|
||||
bool PreferencesManager::SetValue(absl::string_view key, const json& value) {
|
||||
if (!value_.is_object()) {
|
||||
NEARBY_LOGS(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
LOG(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
value_ = json::object();
|
||||
}
|
||||
|
||||
@@ -215,8 +221,8 @@ template <typename T>
|
||||
T PreferencesManager::GetValue(absl::string_view key,
|
||||
const T& default_value) const {
|
||||
if (!value_.is_object()) {
|
||||
NEARBY_LOGS(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
LOG(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
return default_value;
|
||||
}
|
||||
|
||||
@@ -231,8 +237,8 @@ template <typename T>
|
||||
bool PreferencesManager::SetArrayValue(absl::string_view key,
|
||||
absl::Span<const T> value) {
|
||||
if (!value_.is_object()) {
|
||||
NEARBY_LOGS(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
LOG(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
value_ = json::object();
|
||||
}
|
||||
|
||||
@@ -255,8 +261,8 @@ std::vector<T> PreferencesManager::GetArrayValue(
|
||||
std::vector<T> result;
|
||||
|
||||
if (!value_.is_object()) {
|
||||
NEARBY_LOGS(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
LOG(ERROR) << "Preferences is no longer an object! value_="
|
||||
<< value_.dump(4);
|
||||
|
||||
for (const T& value : default_value) {
|
||||
result.push_back(value);
|
||||
|
||||
Reference in New Issue
Block a user