int RemoteSlaveProcess::GetExitCode() { if(!terminated) return Null; Recv(2, timeout); return StrInt(output[2]); }
int Pop3::GetMessageCount() { if(!PutGet("STAT\r\n")) return Null; String ok, cnt, tsz; if(!SplitTo(data, ' ', ok, cnt, tsz)) return Null; return StrInt(cnt); }
//задание цвета строки void AnimeList::RowColor(int row) { Date release; Array<CellSeries> array; Date today = GetSysDate(); String xml = listName.Get(row, SeriesRelease); String number, date; int ep = listName.Get(row, Episodes); int ser; if(xml.GetCount() > 0) { int pos; while(xml.GetCount() > 0){ pos = xml.Find("-"); if(pos > 0) { number = String(xml, pos); xml.Remove(0, pos + 1); date = String(xml, 10); xml.Remove(0, 11); series.number = StrInt(number); StrToDate(series.release, date); array.Add(series); } } release = array[array.GetCount()-1].release; if((ep == array[array.GetCount()-1].number) & (today < release)) ser = array[array.GetCount()-1].number - 1; else ser = ((today - release) / 7) + array[array.GetCount()-1].number; } else { release = listName.Get(row, Release); ser = ((today - release) / 7) + 1; } int views = listName.Get(row, Views); if(views == ep) //полностью просмотрено for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnBlue>()); else if((views < ep) & (views != 0) & (views == ser)) //нет новых серий, в просмотре for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnGreen>()); else if((views < ep) & (views != 0) & (views < ser)) //есть новые серии, в просмотре for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnRed>()); else if(views == 0) //нет просмотренных серий for(int i=0;i<listName.GetColumnCount();i++) listName.SetDisplay(row, i, Single<ColumnDefault>()); }
//выбор в главном массиве void AnimeList::Change() { if(listName.IsCursor()) { infoTab.complete.SetLabel(AsString(listName.Get(Complete))); infoTab.name.SetLabel(AsString(listName.Get(Named))); infoTab.nameRus.SetLabel(AsString(listName.Get(NamedRus))); infoTab.episodes.SetLabel(AsString(listName.Get(Episodes))); infoTab.views.SetLabel(AsString(listName.Get(Views))); infoTab.dateRelease.SetLabel(AsString(listName.Get(Release))); test.testStr.SetText(AsString((listName.Get(SeriesRelease)))); if(parameters.checkSave) { String text; int v = listName.Get(Views); v++; text = Format(AsString(listName.Get(Named))+ " %d", v); copy.SetText(text); copy.SelectAll(); copy.Copy(); }; seriesArray.Clear(); test.testList.Clear(); //заполнение массива релизов серий из поля SeriesRelease главного массива (парсер строки) String xml = listName.Get(SeriesRelease); String number, date; int pos; while(xml.GetCount() > 0){ pos = xml.Find("-"); if(pos > 0) { number = String(xml, pos); xml.Remove(0, pos + 1); date = String(xml, 10); xml.Remove(0, 11); series.number = StrInt(number); StrToDate(series.release, date); seriesArray.Add(series); } } if(listName.Get(Complete) != "Yes") AnimeSeries(); else seriesDate.Clear(); } }
void Navigator::Search() { sortitems.Check(sorting); int sc = scope.GetScroll(); String key = scope.GetKey(); String s = TrimBoth(~search); String search_name, search_nest; bool wholeclass = false; bool both = false; navigator_global = false; if(s.Find('.') >= 0) { Vector<String> h = Split((String)~search, '.'); if(*s.Last() == '.') search_nest = Join(h, "::"); else { search_name = h.Pop(); if(h.GetCount()) search_nest = Join(h, "::"); } wholeclass = *s == '.' && search_nest.GetCount(); } else { search_name = search_nest = ~search; both = true; } s = Join(Split(s, '.'), "::") + (s.EndsWith(".") ? "::" : ""); int lineno = StrInt(s); gitem.Clear(); nitem.Clear(); if(IsNull(theide->editfile)) return; int fileii = GetSourceFileIndex(theide->editfile); if(!IsNull(lineno)) { NavItem& m = nitem.Add(); m.type = "Go to line " + AsString(lineno); m.kind = KIND_LINE; m.line = lineno; gitem.Add(Null).Add(&m); } else if(IsNull(s) && !sorting) { const CppBase& b = CodeBase(); for(int i = 0; i < b.GetCount(); i++) { String nest = b.GetKey(i); const Array<CppItem>& ci = b[i]; for(int j = 0; j < ci.GetCount(); j++) { const CppItem& m = ci[j]; if(m.file == fileii) { NavItem& n = nitem.Add(); n.Set(m); n.nest = nest; n.decl_line = m.line; n.decl_file = m.file; n.decl = !m.impl; NavLine& l = n.linefo.Add(); l.impl = m.impl; l.file = m.file; l.line = m.line; } } } Sort(nitem, FieldRelation(&NavItem::line, StdLess<int>())); NavGroup(true); } else { navigator_global = true; const CppBase& b = CodeBase(); String usearch_nest = ToUpper(search_nest); String usearch_name = ToUpper(search_name); ArrayMap<String, NavItem> imap; bool local = sorting && IsNull(s); VectorMap<String, int> nest_pass; for(int pass = -1; pass < 2; pass++) { for(int i = 0; i < b.GetCount(); i++) { String nest = b.GetKey(i); bool foundnest = (wholeclass ? pass < 0 ? false : pass ? ToUpper(nest) == usearch_nest : nest == search_nest : pass < 0 ? nest == search_nest : (pass ? ToUpper(nest).Find(usearch_nest) >= 0 : nest.StartsWith(search_nest))) && nest.Find('@') < 0; if(local || foundnest || both) { const Array<CppItem>& ci = b[i]; for(int j = 0; j < ci.GetCount(); j++) { const CppItem& m = ci[j]; if(local ? m.file == fileii : m.uname.Find('@') < 0 && (pass < 0 ? m.name == search_name : pass ? m.uname.Find(usearch_name) >= 0 : m.name.StartsWith(search_name)) || both && foundnest) { String key = nest + '\1' + m.qitem; int q = nest_pass.Find(nest); int p = pass; if(q < 0) // We do not want classes to be split based on pass nest_pass.Add(nest, pass); else p = nest_pass[q]; q = imap.Find(key); if(q < 0) { NavItem& ni = imap.Add(key); ni.Set(m); ni.nest = nest; ni.decl_line = ni.line; ni.decl_file = ni.file; ni.decl = !ni.impl; ni.pass = p; NavLine& l = ni.linefo.Add(); l.impl = m.impl; l.file = m.file; l.line = m.line; } else { NavItem& mm = imap[q]; if(!m.impl && (!mm.decl || CombineCompare(mm.decl_file, m.file)(mm.decl_line, m.line) < 0)) { mm.decl = true; mm.decl_line = m.line; mm.decl_file = m.file; mm.natural = m.natural; } NavLine& l = mm.linefo.Add(); l.impl = m.impl; l.file = m.file; l.line = m.line; } } } } } } nitem = imap.PickValues(); NavGroup(false); SortByKey(gitem); Vector<String> keys = gitem.PickKeys(); Vector<Vector<NavItem *> > values = gitem.PickValues(); IndexSort(keys, values); for(int i = 0; i < keys.GetCount(); i++) keys[i].Remove(0); VectorMap<String, Vector<NavItem *> > h(pick(keys), pick(values)); gitem = pick(h); for(int i = 0; i < gitem.GetCount(); i++) Sort(gitem[i], sorting ? SortByNames : SortByLines); } scope.Clear(); scope.Add(Null); Index<String> done; for(int i = 0; i < gitem.GetCount(); i++) { String s = gitem.GetKey(i); if(done.Find(s) < 0) { done.Add(s); scope.Add(s); } } scope.ScrollTo(sc); if(!navigator_global || !scope.FindSetCursor(key)) scope.GoBegin(); }
void Player::substract() { int k = StrInt(hp.GetText()) +- StrInt(amount.GetText().ToString()); hp.SetLabel(IntStr(k)); }
void Player::add() { int k = StrInt(hp.GetText()) + StrInt(amount.GetText().ToString()); hp.SetLabel(IntStr(k)); }
//открытие файла после выбора его в системе void AnimeList::OpenFile() { mainArray.Clear(); listName.Clear(); try { String d = LoadFile(filename); XmlParser p(d); while(!p.IsTag()) p.Skip(); p.PassTag("ListView"); while(!p.IsEof()) { if(p.Tag("item")) { while(!p.End()) { if(p.Tag("complete")) { String complete = p.ReadText(); if(complete == "Yes") cell.complete = "Yes"; else if(complete == "No") cell.complete = "No"; else cell.complete = "New"; } else if(p.Tag("name")) cell.name = p.ReadText(); else if(p.Tag("russian")) cell.nameRus = p.ReadText(); else if(p.Tag("episodes")) cell.episodes = StrInt(p.ReadText()); else if(p.Tag("views")) cell.views = StrInt(p.ReadText()); else if(p.Tag("Release")) StrToDate(cell.Release, p.ReadText()); else if(p.Tag("series")) cell.releaseDate = p.ReadText(); else { p.Skip(); continue; } p.PassEnd(); } mainArray.Add(cell); listName.Add(cell.complete, cell.name, cell.nameRus, cell.episodes, cell.views, cell.Release, cell.releaseDate, mainArray.GetCount() - 1); RowColor(listName.GetCount()-1); } else p.Skip(); } } catch(XmlError) { Exclamation("Error Readong the Input File"); } SetupYears(); Title("Anime List | " + filename); String iniFile; iniFile = GetDataFile("AnimeList.xml"); String xmlIni; xmlIni << XmlTag("File").Text(AsString(filename)); SaveFile(iniFile, XmlDoc("FileList", xmlIni)); status.Set(Format("Items: %d. List Open", listName.GetCount())); }
void OpenGLFont::Parse(const char* xml, bool parsePages) { chars.SetCount(512); XmlParser p(xml); while(!p.IsTag()) p.Skip(); p.PassTag("font"); while(!p.End()) { if(p.TagE("common")) { scaleW = (float) p.Double("scaleW"); scaleH = (float) p.Double("scaleH"); lineHeight = (float) p.Double("lineHeight"); base = (float) p.Double("base"); } else if(p.Tag("pages")) { while(!p.End()) { if(p.TagE("page")) { if(parsePages) { String fileName = p["file"]; Image img = StreamRaster::LoadFileAny(GetDataFile(fileName)); images.Add(img); if(preload) resources.Add(img, true); } pages.Add(StrInt(p["id"])); } else p.Skip(); } } else if(p.Tag("chars")) { while(!p.End()) { if(p.TagE("char")) { int id = p.Int("id"); CharInfo& ci = chars[id]; ci.id = id; ci.x = (float) p.Double("x"); ci.y = (float) p.Double("y"); ci.width = (float) p.Double("width"); ci.height = (float) p.Double("height"); ci.xoffset = (float) p.Double("xoffset"); ci.yoffset = (float) p.Double("yoffset"); ci.xadvance = (float) p.Double("xadvance"); ci.page = p.Int("page"); } else p.Skip(); } } else if(p.Tag("kernings")) { while(!p.End()) { if(p.TagE("kerning")) { int first = p.Int("first"); int second = p.Int("second"); float amount = (float) p.Double("amount"); VectorMap<int, float>& vm = kerns.GetAdd(first); vm.Add(second, amount); } else p.Skip(); } } else p.Skip(); } }
NAMESPACE_UPP Value ParseXmlRpcValue(XmlParser& p) { Value r; p.PassTag("value"); if(p.Tag("int") || p.Tag("i4")) { String s = p.ReadText(); CParser p(s); if(!p.IsInt()) throw XmlError("integer expected"); r = p.ReadInt(); } else if(p.Tag("boolean")) { int n = StrInt(p.ReadText()); if(n != 0 && n != 1) throw XmlError("boolean expected"); r = (bool)n; } else if(p.Tag("double")) { String s = p.ReadText(); CParser p(s); if(!p.IsDouble()) throw XmlError("double expected"); r = p.ReadDouble(); } else if(p.Tag("string") || p.Tag("base64")) r = p.ReadText(); else if(p.TagE("nil")) { p.PassEnd(); return r; } else if(p.Tag("dateTime.iso8601")) { String s = TrimBoth(p.ReadText()); // 19980717T14:08:55 // 01234567890123456 if(s.GetCount() != 17 || s[8] != 'T' || s[11] != ':' || s[14] != ':') throw XmlError("invalid dateTime format"); Time tm; tm.year = atoi(s.Mid(0, 4)); tm.month = atoi(s.Mid(4, 2)); tm.day = atoi(s.Mid(6, 2)); tm.hour = atoi(s.Mid(9, 2)); tm.minute = atoi(s.Mid(12, 2)); tm.second = atoi(s.Mid(15, 2)); r = tm; } else if(p.Tag("array")) { ValueArray va; p.PassTag("data"); while(!p.End()) va.Add(ParseXmlRpcValue(p)); r = va; } else if(p.Tag("struct")) { ValueMap vm; while(p.Tag("member")) { p.PassTag("name"); String name = p.ReadText(); p.PassEnd(); vm.Add((Value)name, ParseXmlRpcValue(p)); p.PassEnd(); } r = vm; } else throw XmlError("unknown value type"); p.PassEnd(); p.PassEnd(); return r; }