本文整理汇总了C++中model_type::reset_timetable方法的典型用法代码示例。如果您正苦于以下问题:C++ model_type::reset_timetable方法的具体用法?C++ model_type::reset_timetable怎么用?C++ model_type::reset_timetable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model_type
的用法示例。
在下文中一共展示了model_type::reset_timetable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()(model_type& model, abstract_window_type& parent)
const
{
if (!m_confirm_file_save(parent))
return;
model.reset_timetable(tetengo2::stdalt::make_unique<timetable_type>());
}
示例2: operator
void operator()(
model_type& model,
const tetengo2::stdalt::optional<tetengo2::stdalt::filesystem::path>& given_path,
abstract_window_type& parent) const
{
if (!m_ask_file_path && !model.has_path() && !given_path)
return;
if (!m_confirm_file_save(parent))
return;
tetengo2::stdalt::filesystem::path path{};
if (given_path)
{
path = *given_path;
}
else if (m_ask_file_path)
{
file_open_dialog_type dialog{ m_message_catalog.get(TETENGO2_TEXT("Dialog:FileOpenSave:Open")),
make_file_filters(),
parent };
const auto ok = dialog.do_modal();
if (!ok)
return;
path = dialog.result();
}
else
{
assert(model.has_path());
path = model.path();
}
std::ifstream input_stream{ path, std::ios_base::binary };
if (!input_stream)
{
create_cant_open_file_message_box(path, parent)->do_modal();
return;
}
reader_selector_type reader_selector{ reader_set_type::create_readers(
parent, path.template string<typename string_type::value_type>(), m_message_catalog) };
const auto first = tetengo2::iterator::make_observable_forward_iterator(
boost::spirit::make_default_multi_pass(std::istreambuf_iterator<char>{ input_stream }));
const auto last = tetengo2::iterator::make_observable_forward_iterator(
boost::spirit::make_default_multi_pass(std::istreambuf_iterator<char>{}));
auto error = reader_error_type::none;
auto p_timetable = reader_selector.read(first, last, error);
if (!p_timetable)
{
switch (error)
{
case reader_error_type::canceled:
break; // Do nothing.
case reader_error_type::corrupted:
create_file_broken_message_box(path, parent)->do_modal();
break;
case reader_error_type::unsupported:
create_unsupported_format_file_message_box(path, parent)->do_modal();
break;
default:
assert(false);
BOOST_THROW_EXCEPTION(std::logic_error("Unknown reader error."));
}
return;
}
model.reset_timetable(std::move(p_timetable), path);
}