Skip to content

Commit

Permalink
Review code
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Jun 21, 2024
1 parent e86829c commit 602ac16
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/xtd.core/src/xtd/configuration/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include "../../../include/xtd/environment.h"
#include "../../../include/xtd/configuration/file_settings.h"
#include "../../../include/xtd/configuration/settings.h"
#include "../../../include/xtd/io/directory.h"
#include "../../../include/xtd/io/file.h"
#include "../../../include/xtd/io/path.h"
#include "../../../include/xtd/io/stream_reader.h"
#include "../../../include/xtd/io/stream_writer.h"
#include "../../../include/xtd/reflection/assembly.h"
#define __XTD_CORE_NATIVE_LIBRARY__
#include <xtd/native/settings>
#undef __XTD_CORE_NATIVE_LIBRARY__
#include <map>

using namespace xtd;
using namespace xtd::configuration;
Expand All @@ -24,7 +19,7 @@ struct settings::data {
settings::settings() : data_(std::make_shared<data>()) {
auto product_name = [] {
if (assembly::get_executing_assembly().product() != ustring::empty_string) return assembly::get_executing_assembly().product();
if (environment::get_command_line_args().size() != 0) return xtd::io::path::get_file_name_without_extension(environment::get_command_line_args()[0]);
if (environment::get_command_line_args().size() != 0) return path::get_file_name_without_extension(environment::get_command_line_args()[0]);
return "noname"_s;
};

Expand All @@ -36,11 +31,11 @@ settings::settings() : data_(std::make_shared<data>()) {
data_->file_settings = file_settings {native::settings::get_path(company_name(), product_name())};
}

const xtd::ustring& settings::file_path() const noexcept {
const ustring& settings::file_path() const noexcept {
return data_->file_settings.file_path();
}

xtd::ustring settings::read(const xtd::ustring& key, const xtd::ustring& default_value) {
ustring settings::read(const ustring& key, const ustring& default_value) {
return read_string(key, default_value);
}

Expand All @@ -52,14 +47,14 @@ void settings::save() {
data_->file_settings.save();
}

void settings::write(const xtd::ustring& key, const xtd::ustring& value) {
void settings::write(const ustring& key, const ustring& value) {
write_string(key, value);
}

xtd::ustring settings::read_string(const xtd::ustring& key, const xtd::ustring& default_value) {
ustring settings::read_string(const ustring& key, const ustring& default_value) {
return data_->file_settings.read(key, default_value);
}

void settings::write_string(const xtd::ustring& key, const xtd::ustring& value) {
void settings::write_string(const ustring& key, const ustring& value) {
data_->file_settings.write(key, value);
}

0 comments on commit 602ac16

Please sign in to comment.