public bool insertFolder(TreeIndex index, String name) { if (name == "") { return(false); } if (index.type == IndexTypes.Module || index.type == IndexTypes.Folder) { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } Directory.CreateDirectory(bpath + Path.DirectorySeparatorChar + name); tree.addNode(index.tree_path, name, IndexTypes.Folder, bpath + Path.DirectorySeparatorChar + name); //editor.openFile(index.path,name,IndexTypes.Function); return(false); } else { return(true); } }
public bool insertClass(TreeIndex index, String name) { if (name == "") { return(false); } if (index.type == IndexTypes.Module || index.type == IndexTypes.Folder) { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } File.WriteAllText(bpath + Path.DirectorySeparatorChar + name + ".class.md", $@" ## Class **{name}** "); tree.addNode(index.tree_path, name, IndexTypes.Class, bpath + Path.DirectorySeparatorChar + name + ".class.md"); editor.openFile(bpath + Path.DirectorySeparatorChar + name + ".class.md", name, IndexTypes.Class); return(false); } else { return(true); } }
public String renderFileFromIndex(TreeIndex index) { switch (index.type) { case IndexTypes.Page: { String content = File.ReadAllText(index.path); content = parseLinks(content, index); String result = CommonMark.CommonMarkConverter.Convert(content); return(result); } case IndexTypes.Module: { FuncParser parser = new FuncParser(index.path); String result = ""; result += CommonMark.CommonMarkConverter.Convert(parseLinks(parser.head, index)); // Add head String classlist = ""; foreach (TreeIndex i in index.content) { if (i.type == IndexTypes.Class) { classlist += $"- *class* [**{i.label}**]([[{i.tree_path}]]) "; } } result += CommonMark.CommonMarkConverter.Convert(parseLinks(classlist, index)); // Add classes foreach (TreeIndex i in index.content) { if (i.type == IndexTypes.Function) { result += CommonMark.CommonMarkConverter.Convert(parseLinks(parser.functions[i.label], index)); } } return(result); } case IndexTypes.Class: { FuncParser parser = new FuncParser(index.path); String result = ""; result += CommonMark.CommonMarkConverter.Convert(parseLinks(parser.head, index)); // Add head foreach (TreeIndex i in index.content) { if (i.type == IndexTypes.Function) { result += CommonMark.CommonMarkConverter.Convert(parseLinks(parser.functions[i.label], index)); } } return(result); } case IndexTypes.Function: { // This will never be called by the exporter - just for the in-app display FuncParser parser = new FuncParser(index.path); return(CommonMark.CommonMarkConverter.Convert(parseLinks(parser.functions[index.label], index))); } } return(""); }
public bool insertModule(TreeIndex index, String name) { if (name == "") { return(false); } if (index.type == IndexTypes.Module || index.type == IndexTypes.Folder) { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } Directory.CreateDirectory(bpath + Path.DirectorySeparatorChar + "mod_" + name); File.WriteAllText(bpath + Path.DirectorySeparatorChar + "mod_" + name + Path.DirectorySeparatorChar + "mod_" + name + ".mod.md", $@" # Module **{name}** "); tree.addNode(index.tree_path, name, IndexTypes.Module, bpath + Path.DirectorySeparatorChar + "mod_" + name + Path.DirectorySeparatorChar + "mod_" + name + ".mod.md"); editor.openFile(bpath + Path.DirectorySeparatorChar + "mod_" + name + Path.DirectorySeparatorChar + "mod_" + name + ".mod.md", name, IndexTypes.Module); return(false); } else { return(true); } }
public String useTemplate(TreeIndex index, String tmplate = null) { if (tmplate == null) { tmplate = tmp; } int sss; if (index.type == IndexTypes.Module) { sss = index.tree_path.Split("/").Length - 1; } else { sss = index.tree_path.Split("/").Length - 2; } String backdots = ""; for (int i = 1; i <= sss; i++) { backdots += "../"; } String thunk = tmplate.Replace("{{content}}", renderFileFromIndex(index)); thunk = thunk.Replace("{{sidebar}}", renderTree(index)); return(thunk.Replace("_assets/", backdots + "_assets/").Replace("{{searchpath}}", backdots + "search.html").Replace("{{title}}", title)); }
void deleteItem(object sender, EventArgs e) { bool err = false; try { TreeIndex item = tree.getSelectedItem(); MessageDialog d = new MessageDialog(this, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel, $"Are you sure you want to delete item '{item.label}'"); //err = files.insertFunction(item,entryDialog("Name for new item: ","UntitledFunction")); ResponseType r = (ResponseType)d.Run(); d.Destroy(); if (r == ResponseType.Ok) { files.deleteNode(item, item.label); } } catch { log.error("Error caught while deleting file."); err = true; } if (err == true) { MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Unknown error deleting the selected item. Are you sure you have the right permissions set for your file tree?"); md.Run(); md.Destroy(); } log.info("Item deleted"); }
public bool insertFunction(TreeIndex index, String name) { if (name == "") { return(false); } if (index.type != IndexTypes.Page && index.type != IndexTypes.Folder) { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } FuncParser parser = new FuncParser(index.path); parser[name] = $@" ### Function **{name}**() "; parser.reSave(); tree.addNode(index.tree_path, name, IndexTypes.Function, index.path); editor.openFile(index.path, name, IndexTypes.Function); return(false); } else { return(true); } }
private void makeSearch() { TreeIndex index = tree.getIndexAtPath("root"); String json = getSearchJson(); String text = useTemplate(index, templates.getTemplate(template).search_Data.Replace("{{searchJson}}", json)); File.WriteAllText(outpath + Path.DirectorySeparatorChar + "search.html", text); }
bool onItemClicked(TreeIter iter) { (bool, TreeIndex)result = tree.getIndexFromIter(iter, "root"); TreeIndex item = result.Item2; log.info($"File path: {item.path}"); editor.openFile(item.path, item.label, item.type); return(true); }
/// <summary>Serves as the default hash function.</summary> /// <returns>A hash code for the current object.</returns> public override int GetHashCode() { int hashCode = -449695491; hashCode = hashCode * -1521134295 + NodeId.GetHashCode(); hashCode = hashCode * -1521134295 + AssetId.GetHashCode(); hashCode = hashCode * -1521134295 + TreeIndex.GetHashCode(); hashCode = hashCode * -1521134295 + SubtreeSize.GetHashCode(); return(hashCode); }
private String recRenderTree(TreeIndex index, TreeIndex target) { String output = ""; foreach (TreeIndex i in index.content) { bool active; if (i.Equals(tree.getIndexAtPath("root"))) { active = true; } else { active = getRelations(i, target); } switch (i.type) { case IndexTypes.Folder: { output += tmp_folder.Replace("{{name}}", i.label).Replace("{{active}}", active.ToString().ToLower()) .Replace("{{link}}", parseLinks($"[[{i.tree_path}]]", target)) .Replace("{{tree}}", recRenderTree(i, target)); break; } case IndexTypes.Module: { output += tmp_module.Replace("{{name}}", i.label).Replace("{{active}}", active.ToString().ToLower()) .Replace("{{link}}", parseLinks($"[[{i.tree_path}]]", target)) .Replace("{{tree}}", recRenderTree(i, target)); break; } case IndexTypes.Page: { output += tmp_page.Replace("{{name}}", i.label).Replace("{{active}}", active.ToString().ToLower()) .Replace("{{link}}", parseLinks($"[[{i.tree_path}]]", target)) .Replace("{{tree}}", recRenderTree(i, target)); break; } case IndexTypes.Class: { output += tmp_class.Replace("{{name}}", i.label).Replace("{{active}}", active.ToString().ToLower()) .Replace("{{link}}", parseLinks($"[[{i.tree_path}]]", target)) .Replace("{{tree}}", recRenderTree(i, target)); break; } case IndexTypes.Function: { output += tmp_function.Replace("{{name}}", i.label).Replace("{{active}}", active.ToString().ToLower()) .Replace("{{link}}", parseLinks($"[[{i.parent.tree_path}]]", target)) .Replace("{{tree}}", recRenderTree(i, target)); break; } } } return(output); }
private void Awake() { int index = transform.GetSiblingIndex(); TreeIndex parent = transform.GetComponentInParent <TreeIndex>(); if (parent != null) { index += parent.Index; } Index = index; }
static void RunComputeTreeIndices(TestNode[] nodes, out TreeIndex tree, Allocator allocator = Allocator.TempJob) { using (var tmpNodes = new NativeArray <TestNode>(nodes, Allocator.TempJob)) { var job = new ComputeTreeIndices <TestNode, TestTree> { Tree = new TestTree(), Data = tmpNodes, }; job.AllocateTreeIndex(Allocator.Persistent); job.Run(); tree = job.Indices; } }
private String parseLinks(String text, TreeIndex index) { Regex pbs = new Regex(@"\[\[(.+?)\]\]", RegexOptions.Compiled | RegexOptions.IgnoreCase); int sss; if (index.type == IndexTypes.Module) { sss = index.tree_path.Split("/").Length - 1; } else { sss = index.tree_path.Split("/").Length - 2; } String backdots = ""; for (int i = 1; i <= sss; i++) { backdots += "../"; } MatchCollection matches = pbs.Matches(text); foreach (Match match in matches) { String raw = (String)match.Value.Replace("[[", "").Replace("]]", ""); try { TreeIndex real_index = tree.getIndexAtPath(raw); String real_place; if (real_index.type == IndexTypes.Function) { real_place = real_index.parent.path + $".html#{real_index.label}"; } else { real_place = real_index.path + ".html"; } log.info("Parsing link: " + (backdots + (real_place.Replace(inpath, "").Remove(0, 1)))); text = text.Replace((String)match.Value, (backdots + (real_place.Replace(inpath, "").Remove(0, 1)))); } catch { log.warning($"Cannot find link {raw}"); } } return(text); }
public override void Invoke(SpoolSpace Memory) { this.AddSpools(Memory); Table ltable = (this._Parameters[0]).Select(Memory); Table rtable = (this._Parameters[1]).Select(Memory); string lalias = this._Parameters[0].NameOf(); string ralias = this._Parameters[1].NameOf(); TreeIndex rindex = rtable.GetIndex(this._RKey) ?? rtable.CreateTemporyIndex(this._RKey); using (RecordReader lstream = ltable.OpenReader()) { while (lstream.CanAdvance) { Record l = lstream.ReadNext(); Memory[lalias].Set(l); bool found = false; using (RecordReader rstream = rindex.OpenStrictReader(Record.Split(l, this._LKey))) { while (rstream != null && rstream.CanAdvance) { Record r = rstream.ReadNext(); int compare = Record.Compare(l, this._LKey, r, this._RKey); if (compare == 0) { Memory[ralias].Set(r); found = true; if ((this._Affinity == JoinAffinity.Inner || this._Affinity == JoinAffinity.Left) && this._Filter.Evaluate(Memory).valueBOOL) { this.InvokeChildren(Memory); } } } // End inner loop } if (!found && (this._Affinity == JoinAffinity.Left || this._Affinity == JoinAffinity.AntiLeft)) { Memory[ralias].Set(rtable.Columns.NullRecord); if (this._Filter.Evaluate(Memory).valueBOOL) { this.InvokeChildren(Memory); } } } // End outer loop } this.RemoveSpools(Memory); }
private List <String> recSearchJson(TreeIndex index) { List <String> l = new List <String>(); foreach (TreeIndex i in index.content) { if (i.type != IndexTypes.Folder) { String link = parseLinks($"[[{i.tree_path}]]", tree.getIndexAtPath("root")); l.Add($"['{i.label}','{link}']"); l.AddRange(recSearchJson(i)); } } return(l); }
public bool getRelations(TreeIndex index, TreeIndex target) { foreach (TreeIndex i in index.content) { if (i.Equals(target)) { return(true); } } foreach (TreeIndex i in index.content) { if (getRelations(i, target) == true) { return(true); } } return(index.Equals(target)); }
private void recExport(TreeIndex folder) { switch (folder.type) { case IndexTypes.Folder: { try { Directory.CreateDirectory(folder.path.Replace(inpath, outpath)); } catch { log.warning("At root directory"); } foreach (TreeIndex thing in folder.content) { recExport(thing); } break; } case IndexTypes.Page: { File.WriteAllText(folder.path.Replace(inpath, outpath) + ".html", useTemplate(folder)); break; } case IndexTypes.Class: { File.WriteAllText(folder.path.Replace(inpath, outpath) + ".html", useTemplate(folder)); break; } case IndexTypes.Module: { Directory.CreateDirectory(Path.GetDirectoryName(folder.path).Replace(inpath, outpath)); File.WriteAllText(folder.path.Replace(inpath, outpath) + ".html", useTemplate(folder)); foreach (TreeIndex thing in folder.content) { recExport(thing); } break; } } }
void insertModule(object sender, EventArgs e) { bool err = false; try { TreeIndex item = tree.getSelectedItem(); err = files.insertModule(item, entryDialog("Name for new item: ", "UntitledModule")); } catch { log.error("Error caught while adding new item"); err = true; } if (err == true) { MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Cannot add new item. Are you sure you selected a correct parent from the tree?"); md.Run(); md.Destroy(); } log.info("Page inserted!"); }
void insertFunction(object sender, EventArgs e) { bool err = false; try { TreeIndex item = tree.getSelectedItem(); err = files.insertFunction(item, entryDialog("Name for new item: ", "UntitledFunction")); } catch { log.error("Error caught while adding new item. Probably caused by there being no selection. (This happening is impossible, so if you see this message, you've glitched the system way more than I thought possible)"); err = true; } if (err == true) { MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Close, "Cannot add new item. Are you sure you selected a correct parent from the tree?"); md.Run(); md.Destroy(); } log.info("Page inserted!"); }
public bool deleteNode(TreeIndex index, String name) { editor.closeFile(); switch (index.type) { case IndexTypes.Class: { File.Delete(index.path); tree.removeNode(index); break; } case IndexTypes.Page: { File.Delete(index.path); tree.removeNode(index); break; } case IndexTypes.Module: { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } System.IO.DirectoryInfo di = new DirectoryInfo(bpath); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } di.Delete(); tree.removeNode(index); break; } case IndexTypes.Folder: { System.IO.DirectoryInfo di = new DirectoryInfo(index.path); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } di.Delete(); tree.removeNode(index); break; } case IndexTypes.Function: { FuncParser parser = new FuncParser(index.path); parser.functions.Remove(index.label); parser.reSave(); tree.removeNode(index); break; } } return(false); }
public String renderTree(TreeIndex index) { return(recRenderTree(tree.getIndexAtPath("root"), index)); }
public override void Invoke(SpoolSpace Memory) { // Add spools // this.AddSpools(Memory); // Render each table // Table ltable = (this._Parameters[0]).Select(Memory); Table rtable = (this._Parameters[1]).Select(Memory); string lalias = this._Parameters[0].NameOf(); string ralias = this._Parameters[1].NameOf(); // Get the left and right join index // TreeIndex lidx = ltable.GetIndex(this._LKey) ?? TreeIndex.BuildTemporaryIndex(ltable, this._LKey); //lidx.Tree.DumpMeta(@"C:\Users\pwdlu_000\Documents\Spectre_Projects\Test\treeJoinT1.txt"); TreeIndex ridx = rtable.GetIndex(this._RKey) ?? TreeIndex.BuildTemporaryIndex(rtable, this._RKey); // Get the join tags // bool Intersection = (this._Affinity == JoinAffinity.Inner || this._Affinity == JoinAffinity.Left); bool Antisection = (this._Affinity == JoinAffinity.Left || this._Affinity == JoinAffinity.AntiLeft); // Open a read stream // RecordReader lstream = lidx.OpenReader(); RecordReader rstream = ridx.OpenReader(); // Render some null records // Record RNull = rstream.Columns.NullRecord; // Main loop through both left and right while (lstream.CanAdvance && rstream.CanAdvance) { Record lrec = lstream.Read(); Record rrec = rstream.Read(); int Compare = Record.Compare(lrec, this._LKey, rrec, this._RKey); // Left is less than right, control left if (Compare < 0) { lstream.Advance(); } // AWValue is less than left, control right, but also output an anti join record else if (Compare > 0) { if (Antisection) { Memory[lalias].Set(lrec); Memory[ralias].Set(RNull); if (this._Filter.Evaluate(Memory)) { this.InvokeChildren(Memory); } } rstream.Advance(); } else if (Intersection) // Compare == 0 { // Save the loop-result // int NestedLoopCount = 0; // Loop through all possible tuples // while (Compare == 0) { // Render the record and potentially output // Memory[lalias].Set(lstream.Read()); Memory[ralias].Set(rstream.Read()); if (this._Filter.Evaluate(Memory)) { this.InvokeChildren(Memory); } // Advance the right table // rstream.Advance(); NestedLoopCount++; // Check if this advancing pushed us to the end of the table // if (!rstream.CanAdvance) { break; } // Reset the compare token // Compare = Record.Compare(lstream.Read(), this._LKey, rstream.Read(), this._RKey); } // Revert the nested loops // rstream.Revert(NestedLoopCount); // Step the left stream // lstream.Advance(); } else { lstream.Advance(); } } // Do Anti-Join // if (Antisection) { // Assign the right table to null // Memory[ralias].Set(RNull); // Walk the rest of the left table // while (lstream.CanAdvance) { Memory[lalias].Set(lstream.ReadNext()); if (this._Filter.Evaluate(Memory)) { this.InvokeChildren(Memory); } } } // Add spools // this.RemoveSpools(Memory); }
public void AddIndex(string id, IComparer <T> comparer) { var filePath = Path.Combine(_currentDirectory, $"{_name}.{id}.db"); _indices[id] = new TreeIndex <T>(filePath, _data, comparer, true); }