Esempio n. 1
0
        public Pile <Reach> split(string delim)
        {
            Reach res = this; Pile <Reach> ret = new Pile <Reach>(); while (res.len > 0)

            {
                Reach part = res.before(1, utl.dmyBool("al(occur, token) is planned"), delim); res = res.after(1, utl.dmyBool("al(occur, token) is planned"), delim); ret.Add(part);
            }
            return(ret);
        }
Esempio n. 2
0
        private static void selfTest()
        {
            selfTested = true;
            Reach r1 = new Reach("ab");
            Reach r2 = new Reach("..X--XX___XX,,XX");
            Reach r3 = new Reach("aa bb  cc ");

            ass(r3.firstWord(" ").equals(""));
            ass(r3.firstWord(" a").equals("aa "));
            ass(r3.lastWord(" ").equals(" "));

            ass(r2.upto(1, false, "X,", "X_", "X-").equals("..X-"));
            ass(r2.upto(2, false, "X,", "X_", "X-").equals("..X--XX_"));
            ass(r2.upto(3, false, "X,", "X_", "X-").equals("..X--XX___XX,"));
            ass(r2.upto(-1, false, "X,", "X_", "X-").equals("..X--XX___XX,"));
            ass(r2.upto(-2, false, "X,", "X_", "X-").equals("..X--XX_"));
            ass(r2.upto(-3, false, "X,", "X_", "X-").equals("..X-"));

            ass(r2.upto(1, false, ",XX", "_XX", "X-", "..").equals(".."));
            ass(r2.upto(2, false, ",XX", "_XX", "X-", "..").equals("..X-"));
            ass(r2.upto(3, false, ",XX", "_XX", "X-", "..").equals("..X--XX___XX"));
            ass(r2.upto(-1, false, ",XX", "_XX", "X-", "..").equals("..X--XX___XX,,XX"));
            ass(r2.upto(-2, false, ",XX", "_XX", "X-", "..").equals("..X--XX___XX"));
            ass(r2.upto(-3, false, ",XX", "_XX", "X-", "..").equals("..X-"));

            ass(r2.from(1, false, "X,", "X_", "X-").equals("X--XX___XX,,XX"));
            ass(r2.from(2, false, "X,", "X_", "X-").equals("X___XX,,XX"));
            ass(r2.from(3, false, "X,", "X_", "X-").equals("X,,XX"));
            ass(r2.from(-1, false, "X,", "X_", "X-").equals("X,,XX"));
            ass(r2.from(-2, false, "X,", "X_", "X-").equals("X___XX,,XX"));
            ass(r2.from(-3, false, "X,", "X_", "X-").equals("X--XX___XX,,XX"));

            ass(r2.from(1, false, ",XX", "_XX", "X-", "..").equals("..X--XX___XX,,XX"));
            ass(r2.from(2, false, ",XX", "_XX", "X-", "..").equals("X--XX___XX,,XX"));
            ass(r2.from(3, false, ",XX", "_XX", "X-", "..").equals("_XX,,XX"));
            ass(r2.from(-1, false, ",XX", "_XX", "X-", "..").equals(",XX"));
            ass(r2.from(-2, false, ",XX", "_XX", "X-", "..").equals("_XX,,XX"));
            ass(r2.from(-3, false, ",XX", "_XX", "X-", "..").equals("X--XX___XX,,XX"));

            ass(r1.upto(1).equals("a")); ass(r1.before(1).equals("")); ass(r1.from(1).equals("ab")); ass(r1.after(1).equals("b")); ass(r1.upto(-1).equals("ab")); ass(r1.before(-1).equals("a")); ass(r1.from(-1).equals("b")); ass(r1.after(-1).equals(""));

            ass(r2.upto(2, true, "XX").equals("..X--XX___XX")); ass(r2.upto(2, true, "X").equals("..X--X")); ass(r2.upto(2, true, "XX", "X").equals("..X--X")); ass(r2.upto(2, true, "X", "XX").equals("..X--X")); ass(r2.upto(-2, true, "XX").equals("..X--XX___XX")); ass(r2.upto(-2, true, "X").equals("..X--XX___XX,,X")); ass(r2.upto(-2, true, "XX", "X").equals("..X--XX___XX,,X")); ass(r2.upto(-2, true, "X", "XX").equals("..X--XX___XX,,X"));
            ass(r2.from(2, true, "XX").equals("XX,,XX")); ass(r2.from(2, true, "X").equals("XX___XX,,XX")); ass(r2.from(2, true, "XX", "X").equals("XX___XX,,XX")); ass(r2.from(2, true, "X", "XX").equals("XX___XX,,XX")); ass(r2.from(-2, true, "XX").equals("XX,,XX")); ass(r2.from(-2, true, "X").equals("XX")); ass(r2.from(-2, true, "XX", "X").equals("XX")); ass(r2.from(-2, true, "X", "XX").equals("XX"));
            ass(r2.before(2, true, "XX").equals("..X--XX___")); ass(r2.before(2, true, "X").equals("..X--")); ass(r2.before(2, true, "XX", "X").equals("..X--")); ass(r2.before(2, true, "X", "XX").equals("..X--")); ass(r2.before(-2, true, "XX").equals("..X--XX___")); ass(r2.before(-2, true, "X").equals("..X--XX___XX,,")); ass(r2.before(-2, true, "XX", "X").equals("..X--XX___XX,,")); ass(r2.before(-2, true, "X", "XX").equals("..X--XX___XX,,"));
            ass(r2.after(2, true, "XX").equals(",,XX")); ass(r2.after(2, true, "X").equals("X___XX,,XX")); ass(r2.after(2, true, "XX", "X").equals("X___XX,,XX")); ass(r2.after(2, true, "X", "XX").equals("X___XX,,XX")); ass(r2.after(-2, true, "XX").equals(",,XX")); ass(r2.after(-2, true, "X").equals("X")); ass(r2.after(-2, true, "XX", "X").equals("X")); ass(r2.after(-2, true, "X", "XX").equals("X"));
            ass(r2.at(2, true, "XX").equals("XX")); ass(r2.at(2, true, "X").equals("X")); ass(r2.at(2, true, "XX", "X").equals("X")); ass(r2.at(2, true, "X", "XX").equals("X")); ass(r2.at(-2, true, "XX").equals("XX")); ass(r2.at(-2, true, "X").equals("X")); ass(r2.at(-2, true, "XX", "X").equals("X")); ass(r2.at(-2, true, "X", "XX").equals("X"));
        }
Esempio n. 3
0
 public Reach Load()
 {
     return(Reach.Load(location.ToString()));
 }
Esempio n. 4
0
 public Reach from(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop)? (Reach)Base.rplfrom_(other, this)              : (Reach)Base.rplfrom(other, this)              : (bufop) ? (Reach)Base.rplfrom(other, (Rch)rTxt)              : (Reach)Base.rplfrom(other, (Rch)rTxt));
 }
Esempio n. 5
0
// ******************* (Rch other)
        public Reach before(Reach other)
        {
            Base.upd(); other.upd(); return((pure) ? (bufop)? (Reach)Base.rplbefore_(other, this)              : (Reach)Base.rplbefore(other, this)              : (bufop) ? (Reach)Base.rplbefore(other, (Rch)rTxt)              : (Reach)Base.rplbefore(other, (Rch)rTxt));
        }
Esempio n. 6
0
 internal ReplaceWith(bool bufop, Reach Base, string txt)
 {
     this.bufop = bufop; this.Base = Base; sTxt = txt; pure = true;
 }
Esempio n. 7
0
 public Reach from(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop) ? (Reach)Base.delfrom_(other)              : (Reach)Base.delfrom(other)              : (bufop) ? (Reach)Base.delfrom_(other, this)              : (Reach)Base.delfrom(other, this));
 }
Esempio n. 8
0
 internal Delete(bool bufop, Reach Base, int cnt)
 {
     this.bufop = bufop; this.Base = Base; this.cnt = cnt; pure = false;
 }
Esempio n. 9
0
 public Reach after(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.after__(other)              : (Reach)Base.after_(other));
 }
Esempio n. 10
0
 public Reach after(Reach other)
 {
     upd(); other.upd(); return((Reach)base.after(other));
 }
Esempio n. 11
0
 public Reach from(Reach other)
 {
     upd(); other.upd(); return((Reach)base.from(other));
 }
Esempio n. 12
0
 public Reach at(Reach other)
 {
     upd(); other.upd(); return((Reach)base.at(other));
 }
Esempio n. 13
0
 public Reach upto(Reach other)
 {
     upd(); other.upd(); return((Reach)base.upto(other));
 }
Esempio n. 14
0
// ******************* (Rch other)
        public Reach before(Reach other)
        {
            upd(); other.upd(); return((Reach)base.before(other));
        }
Esempio n. 15
0
        public static Reach Load(string uri)
        {
            Reach Uri = new Reach(uri);

            uri = Uri.before(1, "///?");
            byte[] post     = new ASCIIEncoding().GetBytes(Uri.after(1, "///?"));
            Uri    location = new Uri(uri);

            if (location.IsFile)
            {
                Reach ret = new Reach(utl.f2s(location.ToString()));
                ret.location = location;
                return(ret);
            }
            else
            {
                HttpWebRequest  req;
                HttpWebResponse resp;
                Encoding        enc;
                req = (HttpWebRequest)WebRequest.Create(location.ToString());
                req.CookieContainer = new CookieContainer();
                req.CookieContainer.Add(Cookies);
                req.Timeout   = 30000; // 30 secs
                req.UserAgent = "Internet Explorer";
                if (post.Length > 0)
                {
                    req.Method        = "POST";
                    req.ContentType   = "application/x-www-form-urlencoded";
                    req.ContentLength = post.Length;
                    req.GetRequestStream().Write(post, 0, post.Length);
                }
                try
                {
                    resp = (HttpWebResponse)req.GetResponse();
                    Cookies.Add(resp.Cookies);

                    Reach ret = null;
                    try
                    {
                        Stream       responseStream = resp.GetResponseStream();
                        Encoding     e      = Encoding.GetEncoding(resp.CharacterSet);
                        StreamReader reader = new StreamReader(responseStream, e);
                        string       s      = reader.ReadToEnd();
                        ret = new Reach(s);
                    }
                    catch
                    {
                        //enc = Encoding.GetEncoding(1252);  // Windows-1252 or iso
                        //enc = Encoding.GetEncoding("unicodeFFFE");  // 1201 = "UTF-16BE" or "unicodeFFFE"
                        enc = Encoding.GetEncoding("unicode"); // 1200 = "UTF-16LE", "utf-16", "ucs-2", "unicode", or "ISO-10646-UCS-2"
                        try { if (resp.ContentEncoding.Length > 0)
                              {
                                  enc = Encoding.GetEncoding(resp.ContentEncoding);
                              }
                        } catch (Exception e) { e.ToString(); }
                        ret = new Reach((new StreamReader(resp.GetResponseStream())).ReadToEnd());
                    }
                    ret.location = location;
                    return(ret);
                }
                catch (Exception e)
                {
                    utl.msg(" ******* CANNOT LOAD DOCUMENT FROM WEB ********" + e.ToString());
                    return(null);
                    //SleepEx(20000, 1); //debug
                }
            }
        }
Esempio n. 16
0
 public Reach at(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.at__(other)              : (Reach)Base.at_(other));
 }
Esempio n. 17
0
 public Reach from(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.from__(other)              : (Reach)Base.from_(other));
 }
Esempio n. 18
0
 public bool    Equals(Reach other)
 {
     upd(); other.upd(); return(base.Equals((Rch)other));
 }
Esempio n. 19
0
 internal Delete(bool bufop, Reach Base)
 {
     this.bufop = bufop; this.Base = Base; pure = true;
 }
Esempio n. 20
0
 internal Insert(bool bufop, Reach Base, string txt)
 {
     this.bufop = bufop; this.Base = Base; sTxt = txt; pure = true;
 }
Esempio n. 21
0
 public Reach upto(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop) ? (Reach)Base.delupto_(other)              : (Reach)Base.delupto(other)              : (bufop) ? (Reach)Base.delupto_(other, this)              : (Reach)Base.delupto(other, this));
 }
Esempio n. 22
0
 internal Insert(bool bufop, Reach Base, Reach txt)
 {
     this.bufop = bufop; this.Base = Base; rTxt = txt; pure = false; rTxt.upd();
 }
Esempio n. 23
0
 public Reach after(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop) ? (Reach)Base.delafter_(other)              : (Reach)Base.delafter(other)              : (bufop) ? (Reach)Base.delafter_(other, this)              : (Reach)Base.delafter(other, this));
 }
Esempio n. 24
0
 internal Extract(Reach Base)
 {
     this.Base = Base;
 }
Esempio n. 25
0
 internal ReplaceWith(bool bufop, Reach Base, Reach txt)
 {
     this.bufop = bufop; this.Base = Base; rTxt = txt; pure = false; rTxt.upd();
 }
Esempio n. 26
0
// ******************* (Rch other)
        public Reach before(Reach other)
        {
            Base.upd(); other.upd(); return((strong) ? (Reach)Base.before__(other)              : (Reach)Base.before_(other));
        }
Esempio n. 27
0
 public Reach upto(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop)? (Reach)Base.rplupto_(other, this)              : (Reach)Base.rplupto(other, this)              : (bufop) ? (Reach)Base.rplupto(other, (Rch)rTxt)              : (Reach)Base.rplupto(other, (Rch)rTxt));
 }
Esempio n. 28
0
 public Reach upto(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.upto__(other)              : (Reach)Base.upto_(other));
 }
Esempio n. 29
0
 public Reach after(Reach other)
 {
     Base.upd(); other.upd(); return((pure) ? (bufop)? (Reach)Base.rplafter_(other, this)              : (Reach)Base.rplafter(other, this)              : (bufop) ? (Reach)Base.rplafter(other, (Rch)rTxt)              : (Reach)Base.rplafter(other, (Rch)rTxt));
 }
Esempio n. 30
0
 internal Reach(Reach source, Restrict rt) : base(source, rt)
 {
     init();
 }