// ** This class was generated with DemFGen (vers:11/17/2009) namespace edu.neu.ccs.demeterf.http.classes{ using System; using Fields = edu.neu.ccs.demeterf.Fields; using ident = edu.neu.ccs.demeterf.lib.ident; using verbatim = edu.neu.ccs.demeterf.lib.verbatim; using edu.neu.ccs.demeterf.lib; using System.Net.Sockets; using System.Text; using System.IO; /** Computes a String representation in CD Syntax, named as a ToString method */ public class PrintToString : edu.neu.ccs.demeterf.FC{ /** Static stub method for calling ToString */ public static String PrintToStringM(Object o){ return new edu.neu.ccs.demeterf.Traversal(new PrintToString(),edu.neu.ccs.demeterf.Control.builtins()).traverse(o).toString(); } public _LT combine(byte _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(short _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(int _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(long _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(float _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(double _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(char _h_){ return empty.append(new _S("\'"+escape(""+_h_)+"\'")); } public _LT combine(bool _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(string _h_){ return empty.append(new _S("\""+escape(""+_h_)+"\"")); } public _LT combine(ident _h_){ return empty.append(new _S(""+_h_)); } public _LT combine(verbatim _h_){ return empty.append(new _S(""+_h_)); } static _LT empty = new _LT(); public class _LT{ edu.neu.ccs.demeterf.lib.List<_T> l; public _LT(){ l = new edu.neu.ccs.demeterf.lib.Empty<_T>(); } public _LT(edu.neu.ccs.demeterf.lib.List<_T> ll){ l = ll; } public _LT push(_T t){ return new _LT(l.push(t)); } public _LT append(_T t){ return new _LT(l.append(t)); } public _LT append(_LT t){ return new _LT(l.append(t.l)); } public String toString(){ return l.fold(new _F(),""); } public _LT compress(){ return l.isEmpty()?this:compress(new _E(), l); } public static _LT compress(_S s, edu.neu.ccs.demeterf.lib.List<_T> r){ if(r.isEmpty())return (s.isE())?empty:empty.push(s); _T top = r.top(); if(top.isS())return compress(s.append((_S)top), r.pop()); if(s.isE())return compress(s, r.pop()).push(top); return compress(new _E(), r.pop()).push(top).push(s); } } public class _T{ public virtual bool isS(){ return false; } public virtual bool isE(){ return false; } } public class _P : _T{ public static _P p = new _P(); } public class _M : _T{ public static _M m = new _M(); } public class _N : _T{ public static _N n = new _N(); } public class _R : _T{ public static _R r = new _R(); } public class _S : _T{ public System.Text.StringBuilder s; public _S(String ss){ s = new System.Text.StringBuilder(ss); } public _S append(_S ss){ s.Append(ss.s); return this; } public override bool isS(){ return true; } } public class _E : _S{ public _E():base(""){ } public override bool isS(){ return true; } } public class _F : edu.neu.ccs.demeterf.lib.List<_T>.Fold{ int idt = 0; public override String fold(_T t, String s){ if(t == _P.p)plus(); else if(t == _M.m)minus(); else if(t == _R.r)s += "\r"; else if(t == _N.n)s += "\n"+indent(); else s += ((_S)t).s; return s; } void plus(){ idt++; } void minus(){ idt--; } String indent(){ return indent(idt); } static String indent(int i){ return (i <= 0)?"":" "+indent(i-1); } } public static string escape(string s){ string ret = ""; foreach(char c in s)ret += escape(c); return ret; } public static String escape(char c){ switch(c){ case '\n':return "\\n"; case '\t':return "\\t"; case '\b':return "\\b"; case '\r':return "\\r"; case '\f':return "\\f"; case '\\':return "\\\\"; case '\'':return "\\'"; case '\"':return "\\\""; default: return ""+c; } } public _LT combine(HTTPReq _h_, _LT head, _LT keys, _LT body){ return empty.append(head).append(keys).append(_R.r).append(_N.n).append(body).compress(); } public _LT combine(HTTPResp _h_, _LT ver, _LT resp, _LT label, _LT keys, _LT body){ return empty.append(ver).append(new _S(" ")).append(resp).append(new _S(" ")).append(label).append(_R.r).append(_N.n).append(keys).append(_R.r).append(_N.n).append(body).compress(); } public _LT combine(GetReq _h_, _LT url, _LT ver){ return empty.append(new _S("GET")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(HeadReq _h_, _LT url, _LT ver){ return empty.append(new _S("HEAD")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(PostReq _h_, _LT url, _LT ver){ return empty.append(new _S("POST")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(PutReq _h_, _LT url, _LT ver){ return empty.append(new _S("PUT")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(DeleteReq _h_, _LT url, _LT ver){ return empty.append(new _S("DELETE")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(TraceReq _h_, _LT url, _LT ver){ return empty.append(new _S("TRACE")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(ConnectReq _h_, _LT url, _LT ver){ return empty.append(new _S("CONNECT")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(OptionsReq _h_, _LT url, _LT ver){ return empty.append(new _S("OPTIONS")).append(new _S(" ")).append(url).append(new _S(" ")).append(ver).append(_R.r).append(_N.n).compress(); } public _LT combine(BaseURL _h_, _LT rest){ return empty.append(new _S("/")).append(rest).compress(); } public _LT combine(MidURL _h_, _LT id, _LT rest){ return empty.append(id).append(rest).compress(); } public _LT combine(NoURL _h_){ return empty; } public _LT combine(HTTPVer _h_, _LT ver){ return empty.append(new _S("HTTP/")).append(ver).compress(); } public _LT combine(MsgHead _h_, _LT key, _LT value){ return empty.append(key).append(new _S(":")).append(new _S(" ")).append(value).compress(); } public _LT combine(Empty _h_){ return empty; } public _LT combine(Cons _h_, _LT first, _LT rest){ return empty.append(first).append(_R.r).append(_N.n).append(rest).compress(); } } }