• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            cyt
            以前曾經寫過一個類型安全的format輸出,(見http://www.shnenglu.com/cyt/archive/2005/10/08/578.html)。
            今天又在codeporject里面發現有類似的CFormat(另外一個麻煩的就是輸出16進制數的時候,那個argWithFormat參數也太多了點,有時候想簡單輸出一下都要填半天參數,估計參考CFormat的Hex實現也是一個不錯的選擇。反正只要能支持 << 操作的對象都能用在format_string里面。
            format_stream/format_string的確是目前開發中用得最多的類。不過有時候討論起來,為什么非要用format方式,難道就是因為好看的原因?前幾天在看i18n,終于看到一個format_xxxx的優勢:輸出字符串的替換明顯工作量少了很多很多。

            在用javascript開發的日子,還是忘不了 format_xxxxx,于是有寫了個javascript的版本:

            function _formatString( strFormat ) {
                
            this.format( strFormat );
            }
            ;

            _formatString.prototype.format 
            = function ( strPattern ) {
                
            this._pattern = strPattern;
                
            this._p = 0;
                
            this._res = "";
            }
            ;

            _formatString.prototype._moveToNext 
            = function () {
                
            for ( ; this._p < this._pattern.length; ++this._p ) {
                    
            var ch = this._pattern.charAt( this._p );
                    
            if ( ch == "%" ) {
                        
            ++this._p;
                        
            if ( this._p < this._pattern.length && this._pattern.charAt( this._p ) == "%" ) {
                            
            this._res += "%";
                        }
             else {
                            
            break;
                        }
                
                    }

                    
            else
                        
            this._res += ch;
                }

                
            return this;
            }
            ;

            _formatString.prototype.str 
            = function () {
                
            this._res += this._pattern.substr( this._p );
                
            return this._res;
            }
            ;

            function fmt( strPattern ) {
                
            return new _formatString( strPattern );
            }
            ;

            _formatString.prototype.a 
            = function () {
                
            this._moveToNext();
                
            for (var i = 0; i < arguments.length; i++{
                    
            this._res += arguments[i];
                }
              
                
            return this;
            }


            _formatString.prototype.s 
            = function () {
                
            return this.str();
            }

            用起來大概就是:

            var width = 400;
            var height = 340;
            var left = (screen.availWidth - width) / 2;
            var top  = (screen.availHeight - height) / 2;
            window.open('RYFL_lx.jsp', null,  fmt( 'width=%,height=%,left=%,top=%').a(width).a(height).a(left).a(top).s() ); 
             
            久久精品18| 精品综合久久久久久98| 久久久久久久人妻无码中文字幕爆 | 波多野结衣中文字幕久久| 久久综合丁香激情久久| 亚洲伊人久久综合影院| 精品国产乱码久久久久久浪潮 | 久久受www免费人成_看片中文| 成人精品一区二区久久久| 成人免费网站久久久| 性高湖久久久久久久久| 久久精品国产亚洲AV影院| 九九久久99综合一区二区| 97精品久久天干天天天按摩| 久久这里只有精品视频99| 久久国产精品一区| 99久久无码一区人妻a黑| 久久久午夜精品福利内容| 日韩精品久久久久久| 天堂久久天堂AV色综合| 狠狠色婷婷久久综合频道日韩| 久久精品国产2020| 久久99亚洲综合精品首页| 91视频国产91久久久| 欧美噜噜久久久XXX| 国产精品久久久久久久| 欧美亚洲色综久久精品国产| 久久婷婷午色综合夜啪| 亚洲国产成人精品91久久久 | 久久人人妻人人爽人人爽| 久久久久久精品无码人妻| 亚洲欧美日韩精品久久亚洲区| 久久精品无码一区二区日韩AV| 国产精品久久久久一区二区三区| 久久成人精品视频| 国产精品美女久久久久网| 精品久久久久久中文字幕| 国产精品一久久香蕉产线看| 女人香蕉久久**毛片精品| 国产精品久久久久久久午夜片 | 久久精品中文字幕一区|