int main() { expr x = s_node(5, s_node(7, 42)); std::cout << "Before: " << x << "\n"; boost::apply_visitor(Traversal(), x); std::cout << "After: " << x << "\n"; }
HRESULT touchmind::shell::Clipboard::CopyNodeModel(IN HWND hWnd, IN const std::shared_ptr<touchmind::model::node::NodeModel> &node) { HRESULT hr = _InitializeClipboard(); if (SUCCEEDED(hr)) { if (!::OpenClipboard(hWnd)) { return E_FAIL; } ::EmptyClipboard(); // customized xml format MSXML::IXMLDOMDocumentPtr pXMLDoc; hr = pXMLDoc.CreateInstance(__uuidof(MSXML::DOMDocument60), nullptr, CLSCTX_INPROC_SERVER); _bstr_t s_node(L"node"); MSXML::IXMLDOMElementPtr pElement = pXMLDoc->createElement(s_node); pXMLDoc->appendChild(pElement); m_pNodeModelXMLEncoder->Encode(node, pXMLDoc, pElement); std::wstring xml(pXMLDoc->xml); _CopyXML(hWnd, xml); // text format touchmind::converter::NodeModelToTextConverter textConverter; std::wstring text; textConverter.ToText(node, text); _CopyTEXT(hWnd, text); ::CloseClipboard(); } return hr; }
void DependencyGraph::AddDependency(std::string s, std::string t) { Node::Node s_node(""); Node::Node t_node(""); // check if s and t exist already as nodes try { s_node = GetNode(s); } // if not, create the node and add to list of nodes catch (std::exception& e) { s_node.SetName(s); nodes->push_back(s_node); } // repeat with t try { t_node = GetNode(t); } catch (std::exception& e) { t_node.SetName(t); nodes->push_back(t_node); } bool tDep = false; std::list<Node::Node>::iterator it; for(it = (s_node.dependents)->begin(); it != (s_node.dependents)->end(); ++it) { if ((*it).GetName().compare(t) == 0) { tDep = true; } } if (!tDep) { s_node.add_dependent(t_node); size++; } }