Skip to content

Commit

Permalink
Rename h_results to h_result
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Sep 29, 2024
1 parent 70232d3 commit a7bfde8
Show file tree
Hide file tree
Showing 24 changed files with 276 additions and 265 deletions.
11 changes: 6 additions & 5 deletions src/xtd.core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ add_sources(
include/xtd/guid
include/xtd/hash_code.h
include/xtd/hash_code
include/xtd/h_results.h
include/xtd/h_results
include/xtd/h_results_category.h
include/xtd/h_results_category
include/xtd/h_result.h
include/xtd/h_result
include/xtd/h_result_category.h
include/xtd/h_result_category
include/xtd/iasync_result.h
include/xtd/iasync_result
include/xtd/iclonable.h
Expand Down Expand Up @@ -1046,7 +1046,8 @@ add_sources(
src/xtd/exception.cpp
src/xtd/guid.cpp
src/xtd/hash_code.cpp
src/xtd/h_results_category.cpp
src/xtd/h_result.cpp
src/xtd/h_result_category.cpp
src/xtd/iformatable.cpp
src/xtd/istringable.cpp
src/xtd/literals.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/xtd.core/include/xtd/access_violation_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// @brief Contains xtd::access_violation_exception exception.
/// @copyright Copyright (c) 2024 Gammasoft. All rights reserved.
#pragma once
#include "h_results.h"
#include "h_result.h"
#include "system_exception.h"

/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Expand Down Expand Up @@ -34,7 +34,7 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
access_violation_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : xtd::system_exception(message, inner_exception, stack_frame) {error_code(h_results::make_error_code(h_results::E_POINTER));}
access_violation_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : xtd::system_exception(message, inner_exception, stack_frame) {error_code(h_result::make_error_code(h_result::E_POINTER));}

/// @brief Create a new instance of class access_violation_exception
/// @param message Message string associate to the exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
key_not_found_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : xtd::system_exception(message, inner_exception, stack_frame) {error_code(h_results::make_error_code(h_results::E_POINTER));}
key_not_found_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : xtd::system_exception(message, inner_exception, stack_frame) {error_code(h_result::make_error_code(h_result::E_POINTER));}

/// @brief Create a new instance of class key_not_found_exception
/// @param message Message string associate to the exception.
Expand Down
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "diagnostics/stack_frame.h"
#include "diagnostics/stack_trace.h"
#include "core_export.h"
#include "h_results.h"
#include "h_result.h"
#include "literals.h"
#include "object.h"
#include "optional.h"
Expand Down
2 changes: 2 additions & 0 deletions src/xtd.core/include/xtd/h_result
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "h_result.h"
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
/// @file
/// @brief Contains h_results class.
/// @brief Contains h_result class.
/// @copyright Copyright (c) 2024 Gammasoft. All rights reserved.
#pragma once
#include "h_results_category.h"
#include "int32.h"
#include "string.h"
#include "static.h"
#include <system_error>

/// @cond
#if defined(_WIN32)
#undef S_OK
#undef S_FALSE
#undef CO_E_NOTINITIALIZED
#undef DISP_E_OVERFLOW
#undef E_ABORT
#undef E_BOUNDS
#undef E_CHANGED_STATE
#undef E_FAIL
#undef E_HANDLE
#undef E_INVALIDARG
#undef E_NOTIMPL
#undef E_POINTER
#undef E_UNEXPECTED
#undef ERROR_MRM_MAP_NOT_FOUND
#undef ERROR_TIMEOUT
#undef RO_E_CLOSED
#undef RPC_E_CHANGED_MODE
#undef TYPE_E_TYPEMISMATCH
#undef STG_E_PATHNOTFOUND
#undef ERROR_TOO_MANY_OPEN_FILES
#undef ERROR_SHARING_VIOLATION
#undef ERROR_LOCK_VIOLATION
#undef ERROR_OPEN_FAILED
#undef ERROR_DISK_CORRUPT
#undef ERROR_UNRECOGNIZED_VOLUME
#undef ERROR_DLL_INIT_FAILED
#undef ERROR_FILE_INVALID
# undef S_OK
# undef S_FALSE
# undef CO_E_NOTINITIALIZED
# undef DISP_E_OVERFLOW
# undef E_ABORT
# undef E_BOUNDS
# undef E_CHANGED_STATE
# undef E_FAIL
# undef E_HANDLE
# undef E_INVALIDARG
# undef E_NOTIMPL
# undef E_POINTER
# undef E_UNEXPECTED
# undef ERROR_MRM_MAP_NOT_FOUND
# undef ERROR_TIMEOUT
# undef RO_E_CLOSED
# undef RPC_E_CHANGED_MODE
# undef TYPE_E_TYPEMISMATCH
# undef STG_E_PATHNOTFOUND
# undef ERROR_TOO_MANY_OPEN_FILES
# undef ERROR_SHARING_VIOLATION
# undef ERROR_LOCK_VIOLATION
# undef ERROR_OPEN_FAILED
# undef ERROR_DISK_CORRUPT
# undef ERROR_UNRECOGNIZED_VOLUME
# undef ERROR_DLL_INIT_FAILED
# undef ERROR_FILE_INVALID
#endif
/// @endcond

Expand All @@ -47,7 +48,7 @@ namespace xtd {
/// xtd.core
/// @ingroup xtd_core exceptions
/// @remarks For more information, see Winerror.h from Micorosft's Win32 API.
class h_results static_ {
class h_result static_ {
public:
/// @name Public Fields

Expand Down Expand Up @@ -287,14 +288,14 @@ namespace xtd {
/// @name Public Static Methods

/// @{
/// @brief Obtains a reference to the static error category object for h_result errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "h_results_category". It is used to identify error conditions that correspond to the xtd::h_results error codes.
/// @brief Obtains a reference to the static error category object for h_result errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "h_result_category". It is used to identify error conditions that correspond to the xtd::h_result error codes.
/// @return A reference to the static object of unspecified runtime type, derived from [std::error_category](https://en.cppreference.com/w/cpp/error/error_category).
static const std::error_category& h_results_category() noexcept {return xtd::h_results_category();}
static const std::error_category& h_result_category() noexcept;

/// @brief Creates error code value for xtd::h_results `h_result`.
/// @param h_result xtd::h_results error code to create error code for.
/// @brief Creates error code value for xtd::h_result `h_result`.
/// @param h_result xtd::h_result error code to create error code for.
/// @return Error code corresponding to `h_result`.
static std::error_code make_error_code(int h_result) noexcept {return xtd::make_error_code(h_result);}
static std::error_code make_error_code(int h_result) noexcept;
/// &}
};
}
2 changes: 2 additions & 0 deletions src/xtd.core/include/xtd/h_result_category
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "h_result_category.h"
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/// @file
/// @brief Contains h_results class.
/// @brief Contains h_result class.
/// @copyright Copyright (c) 2024 Gammasoft. All rights reserved.
#pragma once
#include "int32.h"
#include "string.h"
#include "static.h"
#include <system_error>

/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
namespace xtd {
/// @brief Obtains a reference to the static error category object for h_result errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "h_results_category". It is used to identify error conditions that correspond to the xtd::h_results error codes.
/// @brief Obtains a reference to the static error category object for h_result errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "h_result_category". It is used to identify error conditions that correspond to the xtd::h_result error codes.
/// @return A reference to the static object of unspecified runtime type, derived from [std::error_category](https://en.cppreference.com/w/cpp/error/error_category).
/// @par Namespace
/// xtd
/// @par Library
/// xtd.core
/// @ingroup xtd_core exceptions
const std::error_category& h_results_category() noexcept;
const std::error_category& h_result_category() noexcept;

/// @brief Creates error code value for xtd::h_results `h_result`.
/// @param h_result xtd::h_results error code to create error code for.
/// @brief Creates error code value for xtd::h_result `h_result`.
/// @param h_result xtd::h_result error code to create error code for.
/// @return Error code corresponding to `h_result`.
/// @par Namespace
/// xtd
Expand Down
2 changes: 0 additions & 2 deletions src/xtd.core/include/xtd/h_results

This file was deleted.

2 changes: 0 additions & 2 deletions src/xtd.core/include/xtd/h_results_category

This file was deleted.

2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/rank_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ namespace xtd {

private:
const char* default_message() const noexcept {return "Attempted to operate on an array with the incorrect number of dimensions."_t;}
const std::error_code default_error() const noexcept {return {h_results::COR_E_RANK, h_results::h_results_category()};}
const std::error_code default_error() const noexcept {return {h_result::COR_E_RANK, h_result::h_result_category()};}
};
}
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/system_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
system_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception, stack_frame) {error_code(h_results::make_error_code(h_results::COR_E_SYSTEM));}
system_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception, stack_frame) {error_code(h_result::make_error_code(h_result::COR_E_SYSTEM));}

/// @brief Create a new instance of class system_exception
/// @param message Message string associate to the exception.
Expand Down
4 changes: 2 additions & 2 deletions src/xtd.core/include/xtd/xtd.core.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@
#include "get_out_rdbuf.h"
#include "guid.h"
#include "hash_code.h"
#include "h_results.h"
#include "h_results_category.h"
#include "h_result.h"
#include "h_result_category.h"
#include "iasync_result.h"
#include "iclonable.h"
#include "icomparable.h"
Expand Down
12 changes: 6 additions & 6 deletions src/xtd.core/src/xtd/access_violation_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ using namespace xtd;
using namespace xtd::diagnostics;

access_violation_exception::access_violation_exception(const stack_frame& stack_frame) : system_exception(std::nullopt, stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
}

access_violation_exception::access_violation_exception(const std::optional<xtd::string>& message, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
}

access_violation_exception::access_violation_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(error);
}

access_violation_exception::access_violation_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
this->help_link(help_link);
}

Expand All @@ -27,19 +27,19 @@ access_violation_exception::access_violation_exception(const xtd::string& messag
}

access_violation_exception::access_violation_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
}

access_violation_exception::access_violation_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
}

access_violation_exception::access_violation_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(error);
}

access_violation_exception::access_violation_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::E_POINTER));
error_code(h_result::make_error_code(h_result::E_POINTER));
this->help_link(help_link);
}

Expand Down
12 changes: 6 additions & 6 deletions src/xtd.core/src/xtd/collections/key_not_found_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ using namespace xtd::collections;
using namespace xtd::diagnostics;

key_not_found_exception::key_not_found_exception(const stack_frame& stack_frame) : system_exception(std::nullopt, stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
}

key_not_found_exception::key_not_found_exception(const std::optional<xtd::string>& message, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
}

key_not_found_exception::key_not_found_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(error);
}

key_not_found_exception::key_not_found_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
this->help_link(help_link);
}

Expand All @@ -28,19 +28,19 @@ key_not_found_exception::key_not_found_exception(const xtd::string& message, con
}

key_not_found_exception::key_not_found_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
}

key_not_found_exception::key_not_found_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
}

key_not_found_exception::key_not_found_exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(error);
}

key_not_found_exception::key_not_found_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : system_exception(message, stack_frame) {
error_code(h_results::make_error_code(h_results::COR_E_KEYNOTFOUND));
error_code(h_result::make_error_code(h_result::COR_E_KEYNOTFOUND));
this->help_link(help_link);
}

Expand Down
10 changes: 5 additions & 5 deletions src/xtd.core/src/xtd/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "../../include/xtd/console.h"
#include "../../include/xtd/environment.h"
#include "../../include/xtd/exception.h"
#include "../../include/xtd/h_results.h"
#include "../../include/xtd/h_results_category.h"
#include "../../include/xtd/h_result.h"
#include "../../include/xtd/h_result_category.h"
#include "../../include/xtd/diagnostics/stack_trace.h"
#include "../../include/xtd/io/path.h"
#include "../../include/xtd/reflection/assembly.h"
Expand All @@ -20,7 +20,7 @@ struct exception::data {
std::optional<string> message;
uptr<exception> inner_exception;
exception_ref inner_exception_deprecated;
std::error_code error = h_results::make_error_code(h_results::COR_E_EXCEPTION);
std::error_code error = h_result::make_error_code(h_result::COR_E_EXCEPTION);
string help_link;
string source = io::path::get_file_name(reflection::assembly::get_executing_assembly().location());
diagnostics::stack_frame stack_frame;
Expand Down Expand Up @@ -51,12 +51,12 @@ void exception::help_link(const xtd::string& value) noexcept {
}

int32 exception::h_result() const noexcept {
if (data_->error.category() != h_results::h_results_category()) return h_results::COR_E_EXCEPTION;
if (data_->error.category() != h_result::h_result_category()) return h_result::COR_E_EXCEPTION;
return data_->error.value();
}

void exception::h_result(int32 value) noexcept {
if (data_->error.value() == value && data_->error.category() == h_results::h_results_category()) return;
if (data_->error.value() == value && data_->error.category() == h_result::h_result_category()) return;
data_->error = make_error_code(value);
}

Expand Down
Loading

0 comments on commit a7bfde8

Please sign in to comment.