Skip to content

Commit 6cb6092

Browse files
committed
using xtd::helpers::throw_helper class
1 parent f088ce1 commit 6cb6092

34 files changed

+82
-51
lines changed

src/xtd.forms/src/xtd/forms/label.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using namespace xtd;
2222
using namespace xtd::drawing;
2323
using namespace xtd::forms;
24+
using namespace xtd::helpers;
2425

2526
struct label::data {
2627
bool auto_ellipsis = false;
@@ -138,7 +139,7 @@ int32 label::image_index() const noexcept {
138139

139140
label& label::image_index(int32 value) {
140141
if (data_->image_index == value) return *this;
141-
if (value < -1 || static_cast<size_t>(value) >= data_->image_list.images().size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
142+
if (value < -1 || static_cast<size_t>(value) >= data_->image_list.images().size()) throw_helper::throws(exception_case::argument_out_of_range);
142143
data_->image_index = value;
143144
if (data_->flat_style != xtd::forms::flat_style::system) invalidate();
144145
if (value != -1) data_->image = xtd::drawing::image::empty;
@@ -348,7 +349,7 @@ forms::create_params label::create_params() const noexcept {
348349

349350
xtd::uptr<xtd::object> label::clone() const {
350351
auto result = xtd::new_uptr<label>(*this);
351-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
352+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
352353
return result;
353354
}
354355

src/xtd.forms/src/xtd/forms/lcd_label.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void lcd_label::dot_matrix_display_digit::set_character(char32 value) {
249249
};
250250
if (character_ != value) {
251251
auto it = characters.find(value);
252-
if (it == characters.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
252+
if (it == characters.end()) throw_helper::throws(exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
253253
character_ = value;
254254
set_dots(it->second);
255255
}
@@ -376,7 +376,7 @@ void lcd_label::fourteen_segment_display_digit::set_character(char32 value) {
376376
};
377377
if (character_ != value) {
378378
auto it = characters.find(value);
379-
if (it == characters.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
379+
if (it == characters.end()) throw_helper::throws(exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
380380
character_ = value;
381381
fourteen_segment_display_digit::value(it->second);
382382
}
@@ -483,7 +483,7 @@ void lcd_label::nine_segment_display_digit::set_character(char32 value) {
483483
};
484484
if (character_ != value) {
485485
auto it = characters.find(value);
486-
if (it == characters.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
486+
if (it == characters.end()) throw_helper::throws(exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
487487
character_ = value;
488488
nine_segment_display_digit::value(it->second);
489489
}
@@ -590,7 +590,7 @@ void lcd_label::seven_segment_display_digit::set_character(char32 value) {
590590
{U':', forms::segments::pc}};
591591
if (character_ != value) {
592592
auto it = characters.find(value);
593-
if (it == characters.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
593+
if (it == characters.end()) throw_helper::throws(exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
594594
character_ = value;
595595
seven_segment_display::value(it->second);
596596
}
@@ -711,7 +711,7 @@ void lcd_label::sixteen_segment_display_digit::set_character(char32 value) {
711711
};
712712
if (character_ != value) {
713713
auto it = characters.find(value);
714-
if (it == characters.end()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
714+
if (it == characters.end()) throw_helper::throws(exception_case::argument, string::format("Only characters : \"{}\" are valid"_t, get_valid_characters()).c_str());
715715
character_ = value;
716716
sixteen_segment_display::value(it->second);
717717
}
@@ -854,7 +854,7 @@ control& lcd_label::text(const xtd::string& value) {
854854
case lcd_style::fourteen_segment_display: data_->digits.push_back(xtd::new_sptr<fourteen_segment_display_digit>()); break;
855855
case lcd_style::sixteen_segment_display: data_->digits.push_back(xtd::new_sptr<sixteen_segment_display_digit>()); break;
856856
case lcd_style::dot_matrix_display: data_->digits.push_back(xtd::new_sptr<dot_matrix_display_digit>()); break;
857-
default: xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, "lcd_style invalid"_t);
857+
default: throw_helper::throws(exception_case::argument, "lcd_style invalid"_t);
858858
}
859859
dynamic_cast<control*>(data_->digits[data_->digits.size() - 1].get())->parent(*this);
860860
dynamic_cast<control*>(data_->digits[data_->digits.size() - 1].get())->double_buffered(double_buffered());
@@ -879,7 +879,7 @@ std::vector<char32> lcd_label::valid_characters() {
879879
case lcd_style::fourteen_segment_display: digit = xtd::new_sptr<fourteen_segment_display_digit>(); break;
880880
case lcd_style::sixteen_segment_display: digit = xtd::new_sptr<sixteen_segment_display_digit>(); break;
881881
case lcd_style::dot_matrix_display: digit = xtd::new_sptr<dot_matrix_display_digit>(); break;
882-
default: xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, "lcd_style invalid"_t);
882+
default: throw_helper::throws(exception_case::argument, "lcd_style invalid"_t);
883883
}
884884
auto vc = digit->get_valid_characters();
885885
return {vc.begin(), vc.end()};
@@ -1010,7 +1010,7 @@ drawing::size lcd_label::default_size() const noexcept {
10101010

10111011
xtd::uptr<xtd::object> lcd_label::clone() const {
10121012
auto result = xtd::new_uptr<lcd_label>(*this);
1013-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
1013+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
10141014
return result;
10151015
}
10161016

src/xtd.forms/src/xtd/forms/light_button.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using namespace xtd;
1818
using namespace xtd::forms;
19+
using namespace xtd::helpers;
1920

2021
namespace {
2122
xtd::forms::visual_styles::push_button_state to_push_button_style(xtd::forms::visual_styles::check_box_state state) {
@@ -437,7 +438,7 @@ xtd::forms::visual_styles::check_box_state light_button::state() const noexcept
437438

438439
xtd::uptr<xtd::object> light_button::clone() const {
439440
auto result = xtd::new_uptr<light_button>(*this);
440-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
441+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
441442
return result;
442443
}
443444

src/xtd.forms/src/xtd/forms/link_label.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using namespace xtd;
1010
using namespace xtd::drawing;
1111
using namespace xtd::forms;
12+
using namespace xtd::helpers;
1213

1314
namespace {
1415
link_label::link link_empty;
@@ -349,7 +350,7 @@ link_label link_label::create(const control& parent, const xtd::string& text, co
349350

350351
xtd::uptr<xtd::object> link_label::clone() const {
351352
auto result = xtd::new_uptr<link_label>(*this);
352-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
353+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
353354
return result;
354355
}
355356

src/xtd.forms/src/xtd/forms/list_box.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ forms::create_params list_box::create_params() const noexcept {
401401

402402
xtd::uptr<xtd::object> list_box::clone() const {
403403
auto result = xtd::new_uptr<list_box>(*this);
404-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
404+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
405405
return result;
406406
}
407407

src/xtd.forms/src/xtd/forms/loading_indicator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
using namespace xtd;
2828
using namespace xtd::forms;
29+
using namespace xtd::helpers;
2930

3031
struct loading_indicator::data {
3132
bool running = false;
@@ -149,7 +150,7 @@ forms::create_params loading_indicator::create_params() const noexcept {
149150

150151
xtd::uptr<xtd::object> loading_indicator::clone() const {
151152
auto result = xtd::new_uptr<loading_indicator>(*this);
152-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
153+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
153154
return result;
154155
}
155156

src/xtd.forms/src/xtd/forms/main_menu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using namespace xtd;
1414
using namespace xtd::drawing;
1515
using namespace xtd::forms;
16+
using namespace xtd::helpers;
1617

1718
main_menu::main_menu() {
1819
create_menu();
@@ -31,7 +32,7 @@ main_menu::main_menu(const std::vector<menu_item_ref>& menu_items) {
3132

3233
xtd::uptr<xtd::object> main_menu::clone() const {
3334
auto result = xtd::new_uptr<main_menu>(*this);
34-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
35+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
3536
return result;
3637
}
3738

src/xtd.forms/src/xtd/forms/menu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
using namespace xtd;
1515
using namespace xtd::forms;
16+
using namespace xtd::helpers;
1617

1718
std::map<intptr, std::reference_wrapper<menu>> menu::handles_;
1819

@@ -160,7 +161,7 @@ void menu::clone_menu(const menu& menu_src) {
160161
}
161162

162163
void menu::merge_menu(const menu& menu_src) {
163-
if (data_.get() == menu_src.data_.get()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, "It was attempted to merge the menu with itself"_t);
164+
if (data_.get() == menu_src.data_.get()) throw_helper::throws(exception_case::argument, "It was attempted to merge the menu with itself"_t);
164165
data_->menu_items.push_back_range(menu_src.data_->menu_items);
165166
}
166167

src/xtd.forms/src/xtd/forms/menu_item.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
using namespace xtd;
1010
using namespace xtd::forms;
11+
using namespace xtd::helpers;
1112

1213
struct menu_item::data {
1314
xtd::string text;
@@ -229,7 +230,7 @@ xtd::forms::menu_item_kind menu_item::kind() const noexcept {
229230
menu_item& menu_item::kind(xtd::forms::menu_item_kind value) {
230231
if (data_->kind != value) {
231232
data_->kind = value;
232-
xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::not_implemented);
233+
throw_helper::throws(exception_case::not_implemented);
233234
//recreate_menu();
234235
}
235236
return *this;
@@ -263,7 +264,7 @@ menu_item& menu_item::text(const xtd::string& value) {
263264

264265
xtd::uptr<xtd::object> menu_item::clone() const {
265266
auto result = xtd::new_uptr<menu_item>(*this);
266-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
267+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
267268
return result;
268269
}
269270

src/xtd.forms/src/xtd/forms/message_notifier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
using namespace xtd;
1717
using namespace xtd::forms;
18+
using namespace xtd::helpers;
1819

1920
namespace {
2021
class message_notifier_standard : public form {
@@ -204,11 +205,11 @@ void message_notifier::show() {
204205
if (notifier_appearance_ == xtd::forms::notifier_appearance::standard)
205206
message_notifier_standard::show(0, *this);
206207
else
207-
xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::not_implemented);
208+
throw_helper::throws(exception_case::not_implemented);
208209
}
209210
void message_notifier::show(const iwin32_window& owner) {
210211
if (notifier_appearance_ == xtd::forms::notifier_appearance::standard)
211212
message_notifier_standard::show(owner.handle(), *this);
212213
else
213-
xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::not_implemented);
214+
throw_helper::throws(exception_case::not_implemented);
214215
}

0 commit comments

Comments
 (0)