public DbSlc(Reach smb) { Db db = new Db(new ctx().DbDrivers); init(); DbSlc ret = new DbGrid(smb.before(-1, ".SL")).SLC; smb = smb.after(-1, ".SL"); if (smb.startsWith("D")) { ret = ret.DST; } smb = smb.from(3); while (smb.len > 0) { if (smb.startsWith("DST")) { ret = ret.DST; smb = smb.from(5); continue; } if (smb.startsWith("TOP(")) { ret = ret.TOP(long.Parse(smb.from(5).before(1, ")").text)); smb = smb.after(1, ")").from(2); continue; } if (smb.startsWith("ORD(")) { ret = ret.ORD(smb.from(5).before(1, ")").after(1, "\"").before(1, "\"").text); smb = smb.after(1, ")").from(2); continue; } } this.count = ret.count; this.fields = ret.fields.Clone(); //new Pile<string>(ret.fieldNames); this.from = new KeyPile <string, string>(ret.from); this.join = ret.join.Clone(); //new Pile<Cnd>(ret.join); this.where = ret.where.Clone(); //new Pile<Cnd>(ret.where); this.order = ret.order; }
private Reach extract(Reach source, bool includeTokens) { Reach ret = source.upto(0) + source.from(source.len + 1); // FromLeftToRight strategy Reach ret = source.from(source.len + 1) for (long i = 1; i <= def.Length; i++) { long k = 1; while ((k <= rpt[i - 1]) || ((rpt[i - 1] == 0) && (source.len > 0))) { Reach leadIn = source.at(1, utl.dmyBool("al(occur, token) is planned"), def[i - 1].Name); if ((leadIn.len == 0) && (def[i - 1].Name.Length > 0)) { return(ret); } if (includeTokens) { if (ret.len == 0) { ret = leadIn; } else { ret = ret + leadIn; } } Reach res = source.after(leadIn); Reach leadOut = null; int occur = 0; // first we try the first closing bracelet, only in case that this will be a non-matching bracelet then wee will try the second, third, fourth etc. closing closing bracelet do { occur++; for (int j = (def[i - 1]).Len; j > 0; j--) { Reach token = res.at(occur, utl.dmyBool("al(occur, token) is planned"), (def[i - 1])[j]); if (token.len > 0) { leadOut = token; } } } while (nested[i - 1] && (res.upto(leadOut).at(-occur, utl.dmyBool("al(occur, token) is planned"), leadIn.text).len > 0)); if (leadOut != null) { res = res.before(leadOut); } if (leadOut == null) { return((ret.len == 0) ? res : ret + res); } if (ret.len == 0) { ret = includeTokens ? source.after(leadIn).upto(leadOut) : source.after(leadIn).before(leadOut); } else { ret = includeTokens ? ret + source.after(leadIn).upto(leadOut) : ret + source.after(leadIn).before(leadOut); } source = source.after(leadOut); k++; } } return(ret); }
internal DbGrid(Reach smb) { init(); Zone bktFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "(", ")", "||:1")); Zone strFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "\"", "\"", "||:1")); if (smb.at(".OR").len > 0) { smb = smb; } //def = new Reach("Grid(\"cpt cpt\").sC(\"id\").sR(cd(\"idnm\").EQ(ds(\"TS\")).OR(cd(\"idnm\").EQ(ds(\"TO\"))).OR(cd(\"idnm\").EQ(ds(\"TO\")))).SLC"); smb = new Reach(smb.text); Reach gridDef = bktFilter.on(smb); Reach tblDef = strFilter.on(gridDef); addTables(tblDef); Reach jCnd = smb.after(tblDef).after(1, ", "); joinCnd.Add(DbCnd.fromSymbolicDef(jCnd)); string testsql = this.SLC.sql(); smb = smb.after(gridDef).from(3); while (smb.len > 0) { if (smb.startsWith("sR(")) { Reach selCnds = bktFilter.on(smb); joinCnd = sR(DbCnd.fromSymbolicDef(selCnds)).joinCnd; selCnd = sR(DbCnd.fromSymbolicDef(selCnds)).selCnd; smb = smb.after(selCnds).from(3); } else if (smb.startsWith("sC(")) { Reach colDef = strFilter.on(bktFilter.on(smb)); fields = sC(colDef).fields; smb = smb.after(colDef).from(4); } else if (smb.startsWith("SL")) { smb = smb.from(4); } } allFields = fields; //addTables(tables); }
public ndUrl(string urlString) { urlString = urlString.Trim(); if (urlString.IndexOf("://") < 0) { urlString = "http://" + urlString; } _url = new Reach(urlString); Protocol = _url.before(1, "://"); _url = _url.after(Protocol).from(4); Domain = _url.before(1, "/"); _url = _url.after(Domain).from(2); Password = Domain.before(-1, "@"); if (Password.len > 0) { Domain = Domain.after(Password).from(2); User = Password.before(1, ":"); if (User.len > 0) { Password = Password.after(User).from(2); } } else { User = Password.upto(0); } Port = Domain.after(1, ":"); if (Port.len > 0) { Domain = Domain.before(Port).upto(-2); } Extension = Domain.after(-2, "."); if (_allExtensions.IndexOf(" " + Extension.uText + " ") < 0) { Extension = Domain.after(-1, "."); } if (_allExtensions.IndexOf(" " + Extension.uText + " ") < 0) { Extension = Domain.from(Domain.len + 1); } if (Extension.len > 0) { Domain = Domain.before(Extension).upto(-2); } Server = Domain.before(-1, "."); if (Server.len > 0) { Domain = Domain.after(Server).from(2); } Path = _url.before(1, "?"); if (Path.len > 0) { _url = _url.after(Path).from(2); } Query = new Assoc(_url, "=", "&", ""); File = Path.after(-1, "/"); if (File.len > 0) { Path = Path.before(File).upto(-2); } }
private void splitparts() { Pile <Reach> res = new Pile <Reach>(); Reach s = parts[1].Trim(); while (s.len > 0) { Reach first = s.At(1, false, ops.array()); if (first.len == 0) { res.Push(s); s = ""; } else { if (s.startsWith(first)) { if (first.Equals("\"")) { res.Push("`dsF`"); res.Push(Zone.quotation.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("'")) { res.Push("`dsF`"); res.Push(Zone.charray.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("(")) { res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("[")) { res.Push(Zone.bracket.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("{")) { res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("+")) { res.Push("`cct`"); res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("||")) { res.Push("`cct`"); res.Push(Zone.curlybrack.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("ltrim(")) { res.Push("`ltr`"); res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } if (first.Equals("rtrim(")) { res.Push("`rtr`"); res.Push(Zone.bracelet.on(s)); res.Push(s.after(res[-1]).Trim()); s = ""; } } else { res.Push("`dF`"); res.Push(s.before(first).Trim()); res.Push(s.from(first).Trim()); s = ""; } } } parts = res; }