void HelpWin::SyncDocTree() { ClearTree(); VectorMap<String, Vector<String> > map; String pdir = GetFileFolder(GetExeFilePath()) + "/"; for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) if(ff.IsFolder()) { String group = GetFileTitle(ff.GetName()); String dir = AppendFileName(pdir, ff.GetName()); for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) { if(ft.IsFile()) { if(String(ft.GetName()).Mid(0, 1) != "_") map.GetAdd(group).Add(GetFileTitle(ft.GetName())); } } } for(int i = 0; i < map.GetCount(); i++) { Vector<String>& group = map[i]; int pid; pid = AddTree(0, commonImg::group_1_16(), "topic://" + GetExeTitle() + "/" + map.GetKey(i), map.GetKey(i)); for(int j = 0; j < group.GetCount(); j++) { String t = "topic://" + GetExeTitle() + "/" + map.GetKey(i) + "/" + group[j]; String u = GetTopicTitle(GetFileFolder(GetExeFilePath()) + "/" + map.GetKey(i) + ".tpp/" + group[j] + ".tpp"); AddTree(pid, commonImg::commonImg::commonImg::topic_1_16(), t, u); } } FinishTree(); }
void ForceSchemaUpdate(SqlId table, Fields nf, Fields of, SqlId key, const Value& keyval, Sql& cursor) { String tbl; VectorMap<Id, Value> nmap = GetValueMap(nf, &tbl); VectorMap<Id, Value> omap = GetValueMap(of); SqlUpdate update(SqlId(SchemaTableName(Nvl(~table, tbl)))); for(int i = 0; i < nmap.GetCount(); i++) if(nmap[i] != omap.Get(nmap.GetKey(i), Value())) update(SqlId(nmap.GetKey(i)), nmap[i]); if(update) update.Where(key == keyval).Force(cursor); }
ValueMap Result::LoadPage(const CommitFilter& f) { SQLR * Select(SqlAll(RESULT),UID,CMT,BRANCH,CLIENT_ID) .From( Select(UID.As("FILTER")) .From(COMMITS) .Where(f) .OrderBy(Descending(DT)) .Limit(f.offset, f.limit) .AsTable("FILTER_TABLE") ) .InnerJoin(COMMITS).On(SqlId("FILTER")==UID) .LeftJoin(RESULT).On(CMT_UID == UID) .LeftJoin(CLIENT).On(ID == CLIENT_ID) .OrderBy(Descending(DT)); VectorMap<Tuple2<String, int>,ValueMap> rows; SortedIndex<int> clients; VectorMap<String, ValueMap> commits; ValueArray v_clients; ValueMap v_commits; ValueMap vm; while (SQLR.Fetch(vm)){ SetComputedAttributes(vm); String uid = vm["UID"]; int cid = vm["CLIENT_ID"]; rows.Add(MakeTuple(uid, cid), vm); clients.FindAdd(cid); ValueMap& commit = commits.GetAdd(uid); commit.Set("CMT", vm["CMT"]); commit.Set("BRANCH", vm["BRANCH"]); } ValueMap results; for(int i = 0; i<commits.GetCount() ; ++i){ v_commits.Add(commits.GetKey(i), commits[i]); vm.Clear(); for(int j = 0; j < clients.GetCount(); ++j){ if(!IsNull(clients[j])) vm.Add(clients[j], rows.GetAdd(MakeTuple(commits.GetKey(i), clients[j]))); } results.Add(commits.GetKey(i), vm); } for(int i = (!clients.IsEmpty() && IsNull(clients[0]))?1:0; i < clients.GetCount(); i++) v_clients.Add(clients[i]); ValueMap res; res.Set("RESULTS", results); res.Set("COMMITS", v_commits); res.Set("CLIENTS", v_clients); res.Set("ALLCLIENTS", Client::LoadAll()); return res; }
bool SaveVarFile(const char *filename, const VectorMap<String, String>& var) { FileOut out(filename); for(int i = 0; i < var.GetCount(); i++) out << var.GetKey(i) << " = " << AsCString(var[i]) << ";\n"; out.Close(); return !out.IsError(); }
void Data::Dump() { DUMP(sz); DUMP(text); LOG("lang: " << LNGAsText(lang)); DUMPC(vector); LOG("score: "); for(int i = 0; i < score.GetCount(); i++) LOG(" " << score.GetKey(i) << " ..... " << score[i]); LOG("map: "); for(int i = 0; i < map.GetCount(); i++) LOG(" " << map.GetKey(i) << " ..... " << map[i]); LOG("sizemap: "); for(int i = 0; i < sizemap.GetCount(); i++) LOG(" " << sizemap.GetKey(i) << " ..... " << sizemap[i]); DUMP(number); DUMP(option); }
void SaveImages(const char *dir, const char *prefix, const VectorMap<String, Image>& img) { for(int i = 0; i < img.GetCount(); i++) { String fn; if(prefix) fn << prefix; Point p1 = img[i].GetHotSpot(); Point p2 = img[i].Get2ndSpot(); fn << img.GetKey(i) << '.' << p1.x << '.' << p1.y << '.' << p2.x << '.' << p2.y << ".png"; PNGEncoder().SaveFile(AppendFileName(dir, fn), img[i]); } }
void Puzzle::Scores() { WithScoreLayout<TopWindow> d; CtrlLayoutOK(d, t_("Best scores")); d.score.AddColumn(t_("Dimension")); d.score.AddColumn(t_("Moves")); d.score.ColumnWidths("71 48"); d.score.NoCursor().NoGrid(); Vector<int> o = GetSortOrder(score.GetKeys()); for(int i = 0; i < o.GetCount(); i++) d.score.Add(score.GetKey(o[i]), score[o[i]]); d.Run(); }
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions, const VectorMap<String, ClipData>& data) { LLOG("------------------------------"); LLOG("DoDragAndDrop " << fmts); TopWindow *w = GetTopWindow(); if(!w || !w->top) return DND_NONE; int gdk_actions = 0; if(actions & DND_MOVE) gdk_actions |= GDK_ACTION_MOVE; if(actions & DND_COPY) gdk_actions |= GDK_ACTION_COPY; GtkTargetList *list = CreateTargetList(data); dnd_fmts.Clear(); for(int i = 0; i < data.GetCount(); i++) AddFmt(list, data.GetKey(i), i); Vector<String> f = Split(fmts, ';'); for(int i = 0; i < f.GetCount(); i++) { AddFmt(list, f[i], data.GetCount() + i); dnd_fmts.Add(f[i]); } dnd_source_data = &data; dnd_result = DND_NONE; dnd_source = this; if(IsNull(sample)) dnd_icon = Null; else { Size sz = sample.GetSize(); if(sz.cx > 128) sz.cx = 128; if(sz.cy > 128) sz.cy = 128; sz += 2; ImageDraw iw(sz); iw.DrawRect(sz, White()); DrawFrame(iw, sz, Black()); iw.DrawImage(1, 1, sz.cx, sz.cy, sample); ImageBuffer b(128, 128); dnd_icon = iw; } gtk_drag_begin(w->top->window, list, GdkDragAction(gdk_actions), GetMouseLeft() ? 1 : GetMouseMiddle() ? 2 : 3, CurrentEvent.event); while(dnd_source && GetTopCtrls().GetCount()) ProcessEvents(); dnd_source_data = NULL; gtk_target_list_unref (list); LLOG("-------- DoDragAndDrop"); return dnd_result; }
void Pdb::AddThis(const VectorMap<String, Val>& m, adr_t address, const VectorMap<String, Value>& prev) { for(int i = 0; i < m.GetCount() && self.GetCount() < 2000; i++) { Val mv = m[i]; mv.address += address; Visual vis; try { vis = Visualise(mv); } catch(CParser::Error e) { vis.Cat(e, SColorDisabled); } Vis(self, m.GetKey(i), prev, vis); } }
void sOptimizedTextRenderer::Flush() { if(cache.GetCount() == 0) return; LTIMING("Flush"); for(int i = 0; i < cache.GetCount(); i++) { Chrs& c = cache[i]; if(c.x.GetCount()) { Tuple2<Font, Color> fc = cache.GetKey(i); int x = c.x[0]; for(int i = 0; i < c.x.GetCount() - 1; i++) c.x[i] = c.x[i + 1] - c.x[i]; c.x.Top() = 0; w.DrawText(x, y, c.text, fc.a, fc.b, c.x); } } cache.Clear(); }
int main(int argc, const char *argv[]) { int n; VectorMap<String, int> map; Cout() << " lines words bytes file\n"; int total_lines = 0; int total_words = 0; int total_bytes = 0; for(int i = 1; i < argc; i++) { String f = LoadFile(argv[i]); int lines = 0; int words = 0; const char *q = f; for(;;) { int c = *q; if(IsAlpha(c)) { const char *b = q++; while(IsAlNum(*q)) q++; map.GetAdd(String(b, q), 0)++; words++; } else { if(!c) break; if(c == '\n') ++lines; q++; } } Cout() << Format("%8d%8d%8d %s\n", lines, words, f.GetCount(), argv[i]); total_lines += lines; total_words += words; total_bytes += f.GetCount(); } Vector<int> order = GetSortOrder(map.GetKeys()); #ifndef NOOUTPUT Cout() << Format("--------------------------------------%8d%8d%8d total\n", total_lines, total_words, total_bytes); for(int i = 0; i < order.GetCount(); i++) Cout() << map.GetKey(order[i]) << ": " << map[order[i]] << '\n'; #endif return 0; }
void SaveProp(FileOut& out, VectorMap<String, String>& prop, const char *tab) { for(int i = 0; i < prop.GetCount(); i++) out << tab << FillRight(prop.GetKey(i), 8) << " " << prop[i] << "\r\n"; out << ";\r\n\r\n"; }