• R/O
  • SSH
  • HTTPS

sf-04webserver: Commit


Commit MetaInfo

Revisión477 (tree)
Tiempo2015-12-05 11:45:20
Autoryuh

Log Message

・CWorkspace::GetKeySwapStringで、自動置き換えが正常に動作しないバグを修正
・CWorkspaceで無駄に引数を参照渡しにしていたのを値渡しに修正(CString型のコピーは高速なので、実行速度への影響は小さい)

Cambiar Resumen

Diferencia incremental

--- 1xx/04WebServer/trunk/Workspace.cpp (revision 476)
+++ 1xx/04WebServer/trunk/Workspace.cpp (revision 477)
@@ -400,14 +400,31 @@
400400 if(tempSwap != NULL)
401401 AddAutoSwap(tempSwap);
402402
403+ // ノードパスに
404+ path = ToNodePath(path);
405+
406+ // 対象ノードを取得
403407 CString key;
404- CWorkspaceNode * node = GetSubNode(path,key);
405- CString data = node->GetKeySwapString(str,noData);
408+ CWorkspaceNode * node = GetSubNode(path, key);
406409
410+ // 全キーを取得
411+ CStringArray keyList;
412+ node->GetAllKey(keyList);
413+
414+ // 全部置換
415+ for(int i=0;i<keyList.GetCount();i++)
416+ {
417+ str.Replace("%" + keyList[i] + "%", GetKeyData(path + keyList[i], _T(""), FALSE));
418+ }
419+
420+ // 残った%〜%を置換
421+ if(!noData.IsEmpty() && noData.Find("%") == -1)
422+ str = CTextTools::SwapKeySandString(_T("%"), str, noData);
423+
407424 if(tempSwap != NULL)
408425 DelAutoSwap(tempSwap);
409426
410- return(data);
427+ return(str);
411428 }
412429
413430 /////////////////////////////////////////////////////////////////////////////////////
--- 1xx/04WebServer/trunk/TextTools.h (revision 476)
+++ 1xx/04WebServer/trunk/TextTools.h (revision 477)
@@ -47,6 +47,12 @@
4747 static int FindStrIndex(CStringArray &list, CString find, int noCase = 0);
4848
4949 //////////////////////////////////////////////////////////////
50+ // 置換処理
51+ //////////////////////////////////////////////////////////////
52+ //! <KEY>〜<KEY>を置換する。<KEY><KEY>は残す
53+ static CString SwapKeySandString(CString sandKey, CString str, CString swap);
54+
55+ //////////////////////////////////////////////////////////////
5056 // 文字列変換
5157 //////////////////////////////////////////////////////////////
5258 //! Unicodeから、ANSI文字列へ
--- 1xx/04WebServer/trunk/WorkspaceNode.h (revision 476)
+++ 1xx/04WebServer/trunk/WorkspaceNode.h (revision 477)
@@ -39,16 +39,16 @@
3939 Keyに関する処理
4040 **********************************************************/
4141 //! データの設定
42- void SetKeyData(CString &key, CString &data,int noCase);
42+ void SetKeyData(CString key, CString data,int noCase);
4343
4444 //! データの取得
45- CString GetKeyData(CString &key, CString &defaultData, int noCase);
45+ CString GetKeyData(CString key, CString defaultData, int noCase);
4646
4747 //! キーの存在を確認
48- virtual int KeyIsExist(CString &key,int noCase=FALSE);
48+ virtual int KeyIsExist(CString key,int noCase=FALSE);
4949
5050 //! データの削除
51- void DeleteKey(CString &key,int noCase=FALSE);
51+ void DeleteKey(CString key,int noCase=FALSE);
5252
5353 //! キー数を取得
5454 int GetKeyCount();
@@ -60,7 +60,7 @@
6060 void CopyAllKeys(CKeyDataArray &keyData);
6161
6262 //! 文字列中のキー名をデータに置き換えた文字列を取得する
63- CString GetKeySwapString(CString str,CString noData);
63+// CString GetKeySwapString(CString str,CString noData);
6464
6565 //! キーを検索
6666 int FindKeyData(CString sData, int noCase = FALSE);
--- 1xx/04WebServer/trunk/WorkspaceNode.cpp (revision 476)
+++ 1xx/04WebServer/trunk/WorkspaceNode.cpp (revision 477)
@@ -44,7 +44,7 @@
4444
4545 このノードのデータに対するアクセス
4646 */
47-void CWorkspaceNode::SetKeyData(CString &key, CString &data,int noCase)
47+void CWorkspaceNode::SetKeyData(CString key, CString data,int noCase)
4848 {
4949 int index = FindKeyIndex(key,noCase);
5050 if(index == -1)
@@ -62,7 +62,7 @@
6262
6363 このノードのデータに対するアクセス
6464 */
65-CString CWorkspaceNode::GetKeyData(CString &key, CString &defaultData, int noCase)
65+CString CWorkspaceNode::GetKeyData(CString key, CString defaultData, int noCase)
6666 {
6767 int index = FindKeyIndex(key,noCase);
6868 if(index == -1)
@@ -80,7 +80,7 @@
8080
8181 このノードのデータに対するアクセス
8282 */
83-int CWorkspaceNode::KeyIsExist(CString &key, int noCase)
83+int CWorkspaceNode::KeyIsExist(CString key, int noCase)
8484 {
8585 int index = FindKeyIndex(key,noCase);
8686 if(index != -1)
@@ -93,7 +93,7 @@
9393
9494 このノードのデータに対するアクセス
9595 */
96-void CWorkspaceNode::DeleteKey(CString &key, int noCase)
96+void CWorkspaceNode::DeleteKey(CString key, int noCase)
9797 {
9898 int index = FindKeyIndex(key,noCase);
9999 if(index != -1)
@@ -139,6 +139,7 @@
139139 %Key-Name% を、該当するキーのデータで置き換えます
140140 noDataが設定されている場合、見つからない場合は、noDataに置き換えます
141141 */
142+/*
142143 CString CWorkspaceNode::GetKeySwapString(CString str,CString noData)
143144 {
144145 int count = (int)m_keyData.GetSize();
@@ -146,16 +147,6 @@
146147 // 全部検索
147148 for(int i=0;i<count;i++)
148149 {
149- /*
150- int index = str.Find("%" + m_keyData[i].m_key + "%");
151-
152- for(int j=0;j<100 && index != -1;j++)
153- {
154- str = str.Mid(0,index) + m_keyData[i].m_data + str.Mid(index + 2 + m_keyData[i].m_key.GetLength());
155- index = str.Find("%" + m_keyData[i].m_key + "%");
156- }
157- */
158-
159150 str.Replace("%" + m_keyData[i].m_key + "%",m_keyData[i].m_data);
160151 }
161152
@@ -200,6 +191,7 @@
200191
201192 return(str);
202193 }
194+*/
203195
204196 /*!
205197 キーを検索
--- 1xx/04WebServer/trunk/TextTools.cpp (revision 476)
+++ 1xx/04WebServer/trunk/TextTools.cpp (revision 477)
@@ -250,6 +250,48 @@
250250 }
251251
252252 //////////////////////////////////////////////////////////////
253+// 置換処理
254+//////////////////////////////////////////////////////////////
255+/*!
256+ <KEY>〜<KEY>を置換する。<KEY><KEY>は残す
257+*/
258+CString CTextTools::SwapKeySandString(CString sandKey, CString str, CString swap)
259+{
260+ CString ret;
261+ while(1)
262+ {
263+ // 最初のキーを検索
264+ int index = str.Find(sandKey);
265+ if(index == -1)
266+ {
267+ ret += str;
268+ break;
269+ }
270+
271+ // 最初のキーまで切り出し
272+ ret += str.Mid(0, index);
273+ str = str.Mid(index + sandKey.GetLength());
274+
275+ // 挟むキーを検索
276+ int index2 = str.Find(sandKey);
277+ if(index == -1)
278+ {
279+ ret += str;
280+ break;
281+ }
282+
283+ // <KEY><KEY>
284+ if(index2 == 0)
285+ ret += sandKey;
286+ else
287+ ret += swap;
288+ str = str.Mid(index2 + + sandKey.GetLength());
289+ }
290+
291+ return(ret);
292+}
293+
294+//////////////////////////////////////////////////////////////
253295 // 文字列変換
254296 //////////////////////////////////////////////////////////////
255297 /*!
Show on old repository browser