MainWidget.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * Copyright (c) 2022, Dylan Katz <dykatz@uw.edu>
  3. * Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
  4. * Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #include <DevTools/SQLStudio/SQLStudioGML.h>
  9. #include <LibCore/DirIterator.h>
  10. #include <LibCore/StandardPaths.h>
  11. #include <LibDesktop/Launcher.h>
  12. #include <LibFileSystem/FileSystem.h>
  13. #include <LibGUI/Action.h>
  14. #include <LibGUI/Application.h>
  15. #include <LibGUI/BoxLayout.h>
  16. #include <LibGUI/ComboBox.h>
  17. #include <LibGUI/FilePicker.h>
  18. #include <LibGUI/GroupBox.h>
  19. #include <LibGUI/ItemListModel.h>
  20. #include <LibGUI/JsonArrayModel.h>
  21. #include <LibGUI/Menu.h>
  22. #include <LibGUI/MessageBox.h>
  23. #include <LibGUI/SortingProxyModel.h>
  24. #include <LibGUI/Statusbar.h>
  25. #include <LibGUI/TabWidget.h>
  26. #include <LibGUI/TableView.h>
  27. #include <LibGUI/TextDocument.h>
  28. #include <LibGUI/TextEditor.h>
  29. #include <LibGUI/Toolbar.h>
  30. #include <LibGUI/ToolbarContainer.h>
  31. #include <LibSQL/AST/Lexer.h>
  32. #include <LibSQL/AST/Token.h>
  33. #include <LibSQL/SQLClient.h>
  34. #include <LibSQL/Value.h>
  35. #include "MainWidget.h"
  36. #include "ScriptEditor.h"
  37. REGISTER_WIDGET(SQLStudio, MainWidget);
  38. namespace SQLStudio {
  39. static Vector<DeprecatedString> lookup_database_names()
  40. {
  41. static constexpr auto database_extension = ".db"sv;
  42. auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory());
  43. if (!FileSystem::exists(database_path))
  44. return {};
  45. Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir);
  46. Vector<DeprecatedString> database_names;
  47. while (iterator.has_next()) {
  48. if (auto database = iterator.next_path(); database.ends_with(database_extension))
  49. database_names.append(database.substring(0, database.length() - database_extension.length()));
  50. }
  51. return database_names;
  52. }
  53. ErrorOr<NonnullRefPtr<MainWidget>> MainWidget::create()
  54. {
  55. auto widget = TRY(try_make_ref_counted<MainWidget>());
  56. TRY(widget->load_from_gml(sql_studio_gml));
  57. TRY(widget->setup());
  58. return widget;
  59. }
  60. ErrorOr<void> MainWidget::setup()
  61. {
  62. m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv)), [this](auto&) {
  63. open_new_script();
  64. });
  65. m_open_action = GUI::CommonActions::make_open_action([&](auto&) {
  66. if (auto result = GUI::FilePicker::get_open_filepath(window()); result.has_value())
  67. open_script_from_file(LexicalPath { result.release_value() });
  68. });
  69. m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
  70. auto* editor = active_editor();
  71. VERIFY(editor);
  72. if (auto result = editor->save(); result.is_error())
  73. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
  74. });
  75. m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
  76. auto* editor = active_editor();
  77. VERIFY(editor);
  78. if (auto result = editor->save_as(); result.is_error())
  79. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error()));
  80. });
  81. m_save_all_action = GUI::Action::create("Save All", { Mod_Ctrl | Mod_Alt, Key_S }, [this](auto&) {
  82. auto* editor = active_editor();
  83. VERIFY(editor);
  84. m_tab_widget->for_each_child_widget([&](auto& child) {
  85. auto& editor = verify_cast<ScriptEditor>(child);
  86. m_tab_widget->set_active_widget(&editor);
  87. if (auto result = editor.save(); result.is_error()) {
  88. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
  89. return IterationDecision::Break;
  90. } else if (!result.value()) {
  91. return IterationDecision::Break;
  92. }
  93. return IterationDecision::Continue;
  94. });
  95. m_tab_widget->set_active_widget(editor);
  96. });
  97. m_copy_action = GUI::CommonActions::make_copy_action([&](auto&) {
  98. auto* editor = active_editor();
  99. VERIFY(editor);
  100. editor->copy_action().activate();
  101. update_editor_actions(editor);
  102. });
  103. m_cut_action = GUI::CommonActions::make_cut_action([&](auto&) {
  104. auto* editor = active_editor();
  105. VERIFY(editor);
  106. editor->cut_action().activate();
  107. update_editor_actions(editor);
  108. });
  109. m_paste_action = GUI::CommonActions::make_paste_action([&](auto&) {
  110. auto* editor = active_editor();
  111. VERIFY(editor);
  112. editor->paste_action().activate();
  113. update_editor_actions(editor);
  114. });
  115. m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
  116. auto* editor = active_editor();
  117. VERIFY(editor);
  118. editor->document().undo();
  119. update_editor_actions(editor);
  120. });
  121. m_redo_action = GUI::CommonActions::make_redo_action([&](auto&) {
  122. auto* editor = active_editor();
  123. VERIFY(editor);
  124. editor->document().redo();
  125. update_editor_actions(editor);
  126. });
  127. m_connect_to_database_action = GUI::Action::create("Connect to Database"sv, { Mod_Alt, Key_C }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv)), [this](auto&) {
  128. auto database_name = m_databases_combo_box->text().trim_whitespace();
  129. if (database_name.is_empty())
  130. return;
  131. m_run_script_action->set_enabled(false);
  132. m_statusbar->set_text(1, "Disconnected"sv);
  133. if (m_connection_id.has_value()) {
  134. m_sql_client->disconnect(*m_connection_id);
  135. m_connection_id.clear();
  136. }
  137. if (auto connection_id = m_sql_client->connect(database_name); connection_id.has_value()) {
  138. m_statusbar->set_text(1, DeprecatedString::formatted("Connected to: {}", database_name));
  139. m_connection_id = *connection_id;
  140. m_run_script_action->set_enabled(true);
  141. } else {
  142. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not connect to {}", database_name));
  143. }
  144. });
  145. m_run_script_action = GUI::Action::create("Run script", { Mod_Alt, Key_F9 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"sv)), [&](auto&) {
  146. m_results.clear();
  147. m_current_line_for_parsing = 0;
  148. read_next_sql_statement_of_editor();
  149. });
  150. m_run_script_action->set_enabled(false);
  151. static auto database_names = lookup_database_names();
  152. m_databases_combo_box = GUI::ComboBox::construct();
  153. m_databases_combo_box->set_editor_placeholder("Enter new database or select existing database"sv);
  154. m_databases_combo_box->set_max_width(font().width(m_databases_combo_box->editor_placeholder()) + font().max_glyph_width() + 16);
  155. m_databases_combo_box->set_model(*GUI::ItemListModel<DeprecatedString>::create(database_names));
  156. m_databases_combo_box->on_return_pressed = [this]() {
  157. m_connect_to_database_action->activate(m_databases_combo_box);
  158. };
  159. auto& toolbar = *find_descendant_of_type_named<GUI::Toolbar>("toolbar"sv);
  160. toolbar.add_action(*m_new_action);
  161. toolbar.add_action(*m_open_action);
  162. toolbar.add_action(*m_save_action);
  163. toolbar.add_action(*m_save_as_action);
  164. toolbar.add_separator();
  165. toolbar.add_action(*m_copy_action);
  166. toolbar.add_action(*m_cut_action);
  167. toolbar.add_action(*m_paste_action);
  168. toolbar.add_separator();
  169. toolbar.add_action(*m_undo_action);
  170. toolbar.add_action(*m_redo_action);
  171. toolbar.add_separator();
  172. toolbar.add_child(*m_databases_combo_box);
  173. toolbar.add_action(*m_connect_to_database_action);
  174. toolbar.add_separator();
  175. toolbar.add_action(*m_run_script_action);
  176. m_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("script_tab_widget"sv);
  177. m_tab_widget->on_tab_close_click = [&](auto& widget) {
  178. auto& editor = verify_cast<ScriptEditor>(widget);
  179. if (auto result = editor.attempt_to_close(); result.is_error()) {
  180. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error()));
  181. } else if (result.value()) {
  182. m_tab_widget->remove_tab(editor);
  183. update_title();
  184. on_editor_change();
  185. }
  186. };
  187. m_tab_widget->on_change = [&](auto&) {
  188. update_title();
  189. on_editor_change();
  190. };
  191. m_action_tab_widget = find_descendant_of_type_named<GUI::TabWidget>("action_tab_widget"sv);
  192. m_query_results_widget = m_action_tab_widget->add_tab<GUI::Widget>("Results"_short_string);
  193. m_query_results_widget->set_layout<GUI::VerticalBoxLayout>(6);
  194. m_query_results_table_view = m_query_results_widget->add<GUI::TableView>();
  195. m_action_tab_widget->on_tab_close_click = [this](auto&) {
  196. m_action_tab_widget->set_visible(false);
  197. };
  198. m_statusbar = find_descendant_of_type_named<GUI::Statusbar>("statusbar"sv);
  199. m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto);
  200. m_statusbar->set_text(1, "Disconnected"sv);
  201. m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed);
  202. m_statusbar->segment(2).set_fixed_width(font().width("Ln 0,000 Col 000"sv) + font().max_glyph_width());
  203. GUI::Application::the()->on_action_enter = [this](GUI::Action& action) {
  204. auto text = action.status_tip();
  205. if (text.is_empty())
  206. text = Gfx::parse_ampersand_string(action.text());
  207. m_statusbar->set_override_text(move(text));
  208. };
  209. GUI::Application::the()->on_action_leave = [this](GUI::Action&) {
  210. m_statusbar->set_override_text({});
  211. };
  212. m_sql_client = TRY(SQL::SQLClient::try_create());
  213. m_sql_client->on_execution_success = [this](auto result) {
  214. m_result_column_names = move(result.column_names);
  215. read_next_sql_statement_of_editor();
  216. };
  217. m_sql_client->on_execution_error = [this](auto result) {
  218. auto* editor = active_editor();
  219. VERIFY(editor);
  220. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Error executing {}\n{}", editor->path(), result.error_message));
  221. };
  222. m_sql_client->on_next_result = [this](auto result) {
  223. m_results.append({});
  224. m_results.last().ensure_capacity(result.values.size());
  225. for (auto const& value : result.values)
  226. m_results.last().unchecked_append(value.to_deprecated_string());
  227. };
  228. m_sql_client->on_results_exhausted = [this](auto) {
  229. if (m_results.size() == 0)
  230. return;
  231. if (m_results[0].size() == 0)
  232. return;
  233. Vector<GUI::JsonArrayModel::FieldSpec> query_result_fields;
  234. for (auto& column_name : m_result_column_names)
  235. query_result_fields.empend(column_name, String::from_deprecated_string(column_name).release_value_but_fixme_should_propagate_errors(), Gfx::TextAlignment::CenterLeft);
  236. auto query_results_model = GUI::JsonArrayModel::create("{}", move(query_result_fields));
  237. m_query_results_table_view->set_model(MUST(GUI::SortingProxyModel::create(*query_results_model)));
  238. for (auto& result_row : m_results) {
  239. Vector<JsonValue> individual_result_as_json;
  240. for (auto& result_row_column : result_row)
  241. individual_result_as_json.append(result_row_column);
  242. MUST(query_results_model->add(move(individual_result_as_json)));
  243. }
  244. m_action_tab_widget->set_visible(true);
  245. };
  246. return {};
  247. }
  248. ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
  249. {
  250. auto file_menu = TRY(window->try_add_menu("&File"_short_string));
  251. TRY(file_menu->try_add_action(*m_new_action));
  252. TRY(file_menu->try_add_action(*m_open_action));
  253. TRY(file_menu->try_add_action(*m_save_action));
  254. TRY(file_menu->try_add_action(*m_save_as_action));
  255. TRY(file_menu->try_add_action(*m_save_all_action));
  256. TRY(file_menu->try_add_separator());
  257. TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
  258. GUI::Application::the()->quit();
  259. })));
  260. auto edit_menu = TRY(window->try_add_menu("&Edit"_short_string));
  261. TRY(edit_menu->try_add_action(*m_copy_action));
  262. TRY(edit_menu->try_add_action(*m_cut_action));
  263. TRY(edit_menu->try_add_action(*m_paste_action));
  264. TRY(edit_menu->try_add_separator());
  265. TRY(edit_menu->try_add_action(*m_undo_action));
  266. TRY(edit_menu->try_add_action(*m_redo_action));
  267. TRY(edit_menu->try_add_separator());
  268. TRY(edit_menu->try_add_action(*m_run_script_action));
  269. auto help_menu = TRY(window->try_add_menu("&Help"_short_string));
  270. TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
  271. TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
  272. Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/Applications/SQLStudio.md"), "/bin/Help");
  273. })));
  274. TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window)));
  275. return {};
  276. }
  277. void MainWidget::open_new_script()
  278. {
  279. auto new_script_name = DeprecatedString::formatted("New Script - {}", m_new_script_counter);
  280. ++m_new_script_counter;
  281. auto& editor = m_tab_widget->add_tab<ScriptEditor>(String::from_deprecated_string(new_script_name).release_value_but_fixme_should_propagate_errors());
  282. editor.new_script_with_temp_name(new_script_name);
  283. editor.on_cursor_change = [this] { on_editor_change(); };
  284. editor.on_selection_change = [this] { on_editor_change(); };
  285. editor.on_highlighter_change = [this] { on_editor_change(); };
  286. m_tab_widget->set_active_widget(&editor);
  287. }
  288. void MainWidget::open_script_from_file(LexicalPath const& file_path)
  289. {
  290. auto& editor = m_tab_widget->add_tab<ScriptEditor>(String::from_deprecated_string(file_path.title()).release_value_but_fixme_should_propagate_errors());
  291. if (auto result = editor.open_script_from_file(file_path); result.is_error()) {
  292. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to open {}\n{}", file_path, result.error()));
  293. return;
  294. }
  295. editor.on_cursor_change = [this] { on_editor_change(); };
  296. editor.on_selection_change = [this] { on_editor_change(); };
  297. editor.on_highlighter_change = [this] { on_editor_change(); };
  298. m_tab_widget->set_active_widget(&editor);
  299. }
  300. bool MainWidget::request_close()
  301. {
  302. auto any_scripts_modified { false };
  303. auto is_script_modified = [&](auto& child) {
  304. auto& editor = verify_cast<ScriptEditor>(child);
  305. if (editor.document().is_modified()) {
  306. any_scripts_modified = true;
  307. return IterationDecision::Break;
  308. }
  309. return IterationDecision::Continue;
  310. };
  311. m_tab_widget->for_each_child_widget(is_script_modified);
  312. if (!any_scripts_modified)
  313. return true;
  314. auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), {});
  315. switch (result) {
  316. case GUI::Dialog::ExecResult::Yes:
  317. break;
  318. case GUI::Dialog::ExecResult::No:
  319. return true;
  320. default:
  321. return false;
  322. }
  323. m_save_all_action->activate();
  324. any_scripts_modified = false;
  325. m_tab_widget->for_each_child_widget(is_script_modified);
  326. return !any_scripts_modified;
  327. }
  328. ScriptEditor* MainWidget::active_editor()
  329. {
  330. if (!m_tab_widget || !m_tab_widget->active_widget())
  331. return nullptr;
  332. return verify_cast<ScriptEditor>(m_tab_widget->active_widget());
  333. }
  334. void MainWidget::update_title()
  335. {
  336. if (auto* editor = active_editor())
  337. window()->set_title(DeprecatedString::formatted("{} - SQL Studio", editor->name()));
  338. else
  339. window()->set_title("SQL Studio");
  340. }
  341. void MainWidget::on_editor_change()
  342. {
  343. auto* editor = active_editor();
  344. update_statusbar(editor);
  345. update_editor_actions(editor);
  346. }
  347. void MainWidget::update_statusbar(ScriptEditor* editor)
  348. {
  349. if (!editor) {
  350. m_statusbar->set_text(0, "");
  351. m_statusbar->set_text(2, "");
  352. return;
  353. }
  354. StringBuilder builder;
  355. if (editor->has_selection()) {
  356. auto character_count = editor->selected_text().length();
  357. auto word_count = editor->number_of_selected_words();
  358. builder.appendff("Selected: {:'d} {} ({:'d} {})", character_count, character_count == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
  359. }
  360. m_statusbar->set_text(0, builder.to_deprecated_string());
  361. m_statusbar->set_text(2, DeprecatedString::formatted("Ln {:'d} Col {:'d}", editor->cursor().line() + 1, editor->cursor().column()));
  362. }
  363. void MainWidget::update_editor_actions(ScriptEditor* editor)
  364. {
  365. if (!editor) {
  366. m_save_action->set_enabled(false);
  367. m_save_as_action->set_enabled(false);
  368. m_save_all_action->set_enabled(false);
  369. m_run_script_action->set_enabled(false);
  370. m_copy_action->set_enabled(false);
  371. m_cut_action->set_enabled(false);
  372. m_paste_action->set_enabled(false);
  373. m_undo_action->set_enabled(false);
  374. m_redo_action->set_enabled(false);
  375. return;
  376. }
  377. m_save_action->set_enabled(true);
  378. m_save_as_action->set_enabled(true);
  379. m_save_all_action->set_enabled(true);
  380. m_run_script_action->set_enabled(m_connection_id.has_value());
  381. m_copy_action->set_enabled(editor->copy_action().is_enabled());
  382. m_cut_action->set_enabled(editor->cut_action().is_enabled());
  383. m_paste_action->set_enabled(editor->paste_action().is_enabled());
  384. m_undo_action->set_enabled(editor->undo_action().is_enabled());
  385. m_redo_action->set_enabled(editor->redo_action().is_enabled());
  386. }
  387. void MainWidget::drag_enter_event(GUI::DragEvent& event)
  388. {
  389. auto const& mime_types = event.mime_types();
  390. if (mime_types.contains_slow("text/uri-list"))
  391. event.accept();
  392. }
  393. void MainWidget::drop_event(GUI::DropEvent& drop_event)
  394. {
  395. drop_event.accept();
  396. window()->move_to_front();
  397. if (drop_event.mime_data().has_urls()) {
  398. auto urls = drop_event.mime_data().urls();
  399. if (urls.is_empty())
  400. return;
  401. for (auto& url : urls) {
  402. auto& scheme = url.scheme();
  403. if (!scheme.equals_ignoring_ascii_case("file"sv))
  404. continue;
  405. auto lexical_path = LexicalPath(url.serialize_path());
  406. open_script_from_file(lexical_path);
  407. }
  408. }
  409. }
  410. void MainWidget::read_next_sql_statement_of_editor()
  411. {
  412. if (!m_connection_id.has_value())
  413. return;
  414. StringBuilder piece;
  415. do {
  416. if (!piece.is_empty())
  417. piece.append('\n');
  418. auto line_maybe = read_next_line_of_editor();
  419. if (!line_maybe.has_value())
  420. return;
  421. auto& line = line_maybe.value();
  422. auto lexer = SQL::AST::Lexer(line);
  423. piece.append(line);
  424. bool is_first_token = true;
  425. bool is_command = false;
  426. bool last_token_ended_statement = false;
  427. bool tokens_found = false;
  428. for (SQL::AST::Token token = lexer.next(); token.type() != SQL::AST::TokenType::Eof; token = lexer.next()) {
  429. tokens_found = true;
  430. switch (token.type()) {
  431. case SQL::AST::TokenType::ParenOpen:
  432. ++m_editor_line_level;
  433. break;
  434. case SQL::AST::TokenType::ParenClose:
  435. --m_editor_line_level;
  436. break;
  437. case SQL::AST::TokenType::SemiColon:
  438. last_token_ended_statement = true;
  439. break;
  440. case SQL::AST::TokenType::Period:
  441. if (is_first_token)
  442. is_command = true;
  443. break;
  444. default:
  445. last_token_ended_statement = is_command;
  446. break;
  447. }
  448. is_first_token = false;
  449. }
  450. if (tokens_found)
  451. m_editor_line_level = last_token_ended_statement ? 0 : (m_editor_line_level > 0 ? m_editor_line_level : 1);
  452. } while ((m_editor_line_level > 0) || piece.is_empty());
  453. auto sql_statement = piece.to_deprecated_string();
  454. if (auto statement_id = m_sql_client->prepare_statement(*m_connection_id, sql_statement); statement_id.has_value()) {
  455. m_sql_client->async_execute_statement(*statement_id, {});
  456. } else {
  457. auto* editor = active_editor();
  458. VERIFY(editor);
  459. GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not parse {}\n{}", editor->path(), sql_statement));
  460. }
  461. }
  462. Optional<DeprecatedString> MainWidget::read_next_line_of_editor()
  463. {
  464. auto* editor = active_editor();
  465. if (!editor)
  466. return {};
  467. if (m_current_line_for_parsing >= editor->document().line_count())
  468. return {};
  469. auto result = editor->document().line(m_current_line_for_parsing).to_utf8();
  470. ++m_current_line_for_parsing;
  471. return result;
  472. }
  473. }