cyt
導航
C++博客
首頁
新隨筆
聯系
聚合
管理
<
2007年3月
>
日
一
二
三
四
五
六
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
統計
隨筆 - 36
文章 - 0
評論 - 87
引用 - 0
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(12)
給我留言
查看公開留言
查看私人留言
隨筆分類
Work(20)
(rss)
隨筆檔案
2008年1月 (1)
2007年9月 (1)
2007年3月 (3)
2006年11月 (2)
2006年4月 (2)
2006年3月 (2)
2006年1月 (3)
2005年11月 (2)
2005年10月 (20)
文章分類
C/C++
(rss)
Libraries
(rss)
好友Blog
hongrui
Rayman
(rss)
Turing
廢人廢語
(rss)
搜索
最新評論
1.?re: OCI訪問Oracle的一些刁鉆問題[未登錄]
這個有沒有具體的代碼?目前正好遇上這個問題了
--paul
2.?re: 使用std::vector的一個誤區
很同意的你看法
--lancen
3.?re: 新版本的Qu
評論內容較長,點擊標題查看
--home page
4.?re: 新版本的Qu
評論內容較長,點擊標題查看
--Web site
5.?re: 新版本的Qu
評論內容較長,點擊標題查看
--this link
閱讀排行榜
1.?使用std::vector的一個誤區(7949)
2.?epoll的安裝和調試(5845)
3.?我自己的signal / slot實現(5406)
4.?如何在windows service里面控制console程序退出(4591)
5.?OCI訪問Oracle的一些刁鉆問題(4513)
評論排行榜
1.?新版本的Qu(19)
2.?使用std::vector的一個誤區(8)
3.?C++博客的精華區分類構想(意見收集)(8)
4.?drupal安裝心得(7)
5.?補充 BVRDE 使用的一些注意問題(6)
簡單的類型安全format輸出后記
以前曾經寫過一個類型安全的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() );
posted on 2006-03-02 16:17
cyt
閱讀(1162)
評論(0)
編輯
收藏
引用
所屬分類:
Work
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
相關文章:
如何在windows service里面控制console程序退出
補充一個OCI的問題
OpenDBX 一個訪問多數據庫的C類庫
移植代碼到64bits碰上的問題
db4o and GigaBase
實在慚愧
新版本的Qu
OCI訪問Oracle的一些刁鉆問題
Linux的系統性能監測參數獲取
簡單的類型安全format輸出后記
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © cyt
久久国产精品久久
|
久久久久久无码Av成人影院
|
久久午夜无码鲁丝片午夜精品
|
狠狠精品久久久无码中文字幕
|
7国产欧美日韩综合天堂中文久久久久
|
精品国产婷婷久久久
|
色偷偷91久久综合噜噜噜噜
|
偷窥少妇久久久久久久久
|
久久亚洲精品国产精品
|
伊人丁香狠狠色综合久久
|
久久人妻少妇嫩草AV无码蜜桃
|
亚洲人成伊人成综合网久久久
|
久久久久亚洲av无码专区
|
99久久精品费精品国产
|
久久人妻无码中文字幕
|
99精品国产在热久久
|
色偷偷91久久综合噜噜噜噜
|
久久av无码专区亚洲av桃花岛
|
中文精品久久久久国产网址
|
久久亚洲AV无码精品色午夜
|
久久青草国产手机看片福利盒子
|
热久久最新网站获取
|
久久99中文字幕久久
|
亚洲人成电影网站久久
|
亚洲国产成人久久综合一
|
狠狠色丁香久久婷婷综合
|
国产午夜精品久久久久九九电影
|
亚洲精品无码久久久久
|
精品久久久久久久久久久久久久久
|
久久午夜无码鲁丝片秋霞
|
国产精品久久久天天影视香蕉
|
亚洲另类欧美综合久久图片区
|
波多野结衣久久精品
|
久久久久久夜精品精品免费啦
|
国产精品中文久久久久久久
|
亚洲AⅤ优女AV综合久久久
|
99久久精品日本一区二区免费
|
亚洲精品无码久久毛片
|
国产精品美女久久久免费
|
国产午夜免费高清久久影院
|
久久婷婷五月综合成人D啪
|