コード例 #1
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
        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);
        }
コード例 #2
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
        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"));
        }
コード例 #3
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach Load()
 {
     return(Reach.Load(location.ToString()));
 }
コード例 #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));
 }
コード例 #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));
        }
コード例 #6
0
 internal ReplaceWith(bool bufop, Reach Base, string txt)
 {
     this.bufop = bufop; this.Base = Base; sTxt = txt; pure = true;
 }
コード例 #7
0
ファイル: Delete.cs プロジェクト: GeraldTrost/xxDevPlus
 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));
 }
コード例 #8
0
ファイル: Delete.cs プロジェクト: GeraldTrost/xxDevPlus
 internal Delete(bool bufop, Reach Base, int cnt)
 {
     this.bufop = bufop; this.Base = Base; this.cnt = cnt; pure = false;
 }
コード例 #9
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach after(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.after__(other)              : (Reach)Base.after_(other));
 }
コード例 #10
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach after(Reach other)
 {
     upd(); other.upd(); return((Reach)base.after(other));
 }
コード例 #11
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach from(Reach other)
 {
     upd(); other.upd(); return((Reach)base.from(other));
 }
コード例 #12
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach at(Reach other)
 {
     upd(); other.upd(); return((Reach)base.at(other));
 }
コード例 #13
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach upto(Reach other)
 {
     upd(); other.upd(); return((Reach)base.upto(other));
 }
コード例 #14
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
// ******************* (Rch other)
        public Reach before(Reach other)
        {
            upd(); other.upd(); return((Reach)base.before(other));
        }
コード例 #15
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
        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
                }
            }
        }
コード例 #16
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach at(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.at__(other)              : (Reach)Base.at_(other));
 }
コード例 #17
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach from(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.from__(other)              : (Reach)Base.from_(other));
 }
コード例 #18
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 public bool    Equals(Reach other)
 {
     upd(); other.upd(); return(base.Equals((Rch)other));
 }
コード例 #19
0
ファイル: Delete.cs プロジェクト: GeraldTrost/xxDevPlus
 internal Delete(bool bufop, Reach Base)
 {
     this.bufop = bufop; this.Base = Base; pure = true;
 }
コード例 #20
0
 internal Insert(bool bufop, Reach Base, string txt)
 {
     this.bufop = bufop; this.Base = Base; sTxt = txt; pure = true;
 }
コード例 #21
0
ファイル: Delete.cs プロジェクト: GeraldTrost/xxDevPlus
 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));
 }
コード例 #22
0
 internal Insert(bool bufop, Reach Base, Reach txt)
 {
     this.bufop = bufop; this.Base = Base; rTxt = txt; pure = false; rTxt.upd();
 }
コード例 #23
0
ファイル: Delete.cs プロジェクト: GeraldTrost/xxDevPlus
 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));
 }
コード例 #24
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
 internal Extract(Reach Base)
 {
     this.Base = Base;
 }
コード例 #25
0
 internal ReplaceWith(bool bufop, Reach Base, Reach txt)
 {
     this.bufop = bufop; this.Base = Base; rTxt = txt; pure = false; rTxt.upd();
 }
コード例 #26
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
// ******************* (Rch other)
        public Reach before(Reach other)
        {
            Base.upd(); other.upd(); return((strong) ? (Reach)Base.before__(other)              : (Reach)Base.before_(other));
        }
コード例 #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));
 }
コード例 #28
0
ファイル: Extract.cs プロジェクト: GeraldTrost/xxDevPlus
 public Reach upto(Reach other)
 {
     Base.upd(); other.upd(); return((strong) ? (Reach)Base.upto__(other)              : (Reach)Base.upto_(other));
 }
コード例 #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));
 }
コード例 #30
0
ファイル: Reach.cs プロジェクト: GeraldTrost/xxDevPlus
 internal Reach(Reach source, Restrict rt) : base(source, rt)
 {
     init();
 }