const std::vector<CMyHtmlParser::HtmlTag>& CMyHtmlParser::parse(const QByteArray& html) { _tags.clear(); _tree = myhtml_tree_create(); assert_r(_tree); assert_r(myhtml_tree_init(_tree, _myhtmlInstance) == MyCORE_STATUS_OK); myhtml_callback_tree_node_insert_set(_tree, &CMyHtmlParser::callbackNodeInserted, this); /* * From Specification: * * The authoring conformance requirements for character encoding declarations limit them to only * appearing in the first 1024 bytes. User agents are therefore encouraged to use the prescan * algorithm below (as invoked by these steps) on the first 1024 bytes, but not to stall beyond that. */ _encoding = myencoding_prescan_stream_to_determine_encoding(html.data(), std::min(html.size(), 1024)); if (_encoding == MyENCODING_NOT_DETERMINED) { assert_unconditional_r("Failed to determine data encoding"); _encoding = MyENCODING_UTF_8; } assert_r(myhtml_parse(_tree, _encoding, html.data(), html.size()) == MyCORE_STATUS_OK); myhtml_tree_destroy(_tree); return _tags; }
void CPeriodicExecutionThread::setWorkload(const std::function<void()>& workload) { if (!_thread.joinable()) _workload = workload; else assert_unconditional_r("The thread has already started"); }
void CPeriodicExecutionThread::start(const std::function<void()>& workload /*= std::function<void ()>()*/) { if (!_thread.joinable()) { if (workload) _workload = workload; _thread = std::thread(&CPeriodicExecutionThread::threadFunc, this); } else assert_unconditional_r("The thread has already started"); }
Panel CController::otherPanelPosition(Panel p) { switch (p) { case LeftPanel: return RightPanel; case RightPanel: return LeftPanel; default: assert_unconditional_r("Uknown panel"); return LeftPanel; } }
const CPanel &CController::otherPanel(Panel p) const { switch (p) { case LeftPanel: return _rightPanel; case RightPanel: return _leftPanel; default: assert_unconditional_r("Uknown panel"); return _rightPanel; } }