[P2-php-svn] [758] expack:

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 1日 (金) 21:11:16 JST


Revision: 758
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=758
Author:   rsk
Date:     2010-01-01 21:11:16 +0900 (Fri, 01 Jan 2010)

Log Message:
-----------
expack:
- P2KeyValueStore クラスに保存するデータタイプを
  指定する定数を追加。
- P2KeyValueStore_SJIS クラスを
  P2KeyValueStore_ShiftJIS にリネーム。

Modified Paths:
--------------
    p2ex/trunk/lib/P2Client.php
    p2ex/trunk/lib/P2KeyValueStore.php

Added Paths:
-----------
    p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php

Removed Paths:
-------------
    p2ex/trunk/lib/P2KeyValueStore/SJIS.php


-------------- next part --------------
Modified: p2ex/trunk/lib/P2Client.php
===================================================================
--- p2ex/trunk/lib/P2Client.php	2010-01-01 11:06:33 UTC (rev 757)
+++ p2ex/trunk/lib/P2Client.php	2010-01-01 12:11:16 UTC (rev 758)
@@ -111,7 +111,8 @@
     {
         try {
             $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME;
-            $cookieStore = P2KeyValueStore::getStore($cookieSavePath, 'Serializing');
+            $cookieStore = P2KeyValueStore::getStore($cookieSavePath,
+                                                     P2KeyValueStore::KVS_SERIALIZING);
         } catch (Exception $e) {
             throw new P2Exception(get_class($e) . ': ' . $e->getMessage());
         }

Deleted: p2ex/trunk/lib/P2KeyValueStore/SJIS.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/SJIS.php	2010-01-01 11:06:33 UTC (rev 757)
+++ p2ex/trunk/lib/P2KeyValueStore/SJIS.php	2010-01-01 12:11:16 UTC (rev 758)
@@ -1,108 +0,0 @@
-<?php
-require_once dirname(__FILE__) . '/../P2KeyValueStore.php';
-
-// {{{ P2KeyValueStore_SJIS
-
-/**
- * Shift_JIS‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚µ‚ĉi‘±‰»‚·‚é
- */
-class P2KeyValueStore_SJIS extends P2KeyValueStore
-{
-    // {{{ _encode()
-
-    /**
-     * Shift_JIS (CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
-     *
-     * @param string $str
-     * @return string
-     */
-    private function _encode($str)
-    {
-        return mb_convert_encoding($str, 'UTF-8', 'CP932');
-    }
-
-    // }}}
-    // {{{ _decode()
-
-    /**
-     * UTF-8‚Ì•¶Žš—ñ‚ðShift_JIS (CP932) ‚É•ÏŠ·‚·‚é
-     *
-     * @param string $str
-     * @return string
-     */
-    private function _decode($str)
-    {
-        return mb_convert_encoding($str, 'CP932', 'UTF-8');
-    }
-
-    // }}}
-    // {{{ _encodeKey()
-
-    /**
-     * ƒL[‚ðƒGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    protected function _encodeKey($key)
-    {
-        return $this->_encode($key);
-    }
-
-    // }}}
-    // {{{ _decodeKey()
-
-    /**
-     * ƒL[‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    protected function _decodeKey($key)
-    {
-        return $this->_decode($key);
-    }
-
-    // }}}
-    // {{{ _encodeValue()
-
-    /**
-     * ’l‚ðƒGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    protected function _encodeValue($value)
-    {
-        return $this->_encode($value);
-    }
-
-    // }}}
-    // {{{ _decodeValue()
-
-    /**
-     * ’l‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    protected function _decodeValue($value)
-    {
-        return $this->_decode($value);
-    }
-
-    // }}}
-}
-
-// }}}
-
-/*
- * Local Variables:
- * mode: php
- * coding: cp932
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
-// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Copied: p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php (from rev 757, p2ex/trunk/lib/P2KeyValueStore/SJIS.php)
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	2010-01-01 12:11:16 UTC (rev 758)
@@ -0,0 +1,108 @@
+<?php
+require_once dirname(__FILE__) . '/../P2KeyValueStore.php';
+
+// {{{ P2KeyValueStore_ShiftJIS
+
+/**
+ * Shift_JIS‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚µ‚ĉi‘±‰»‚·‚é
+ */
+class P2KeyValueStore_ShiftJIS extends P2KeyValueStore
+{
+    // {{{ _encode()
+
+    /**
+     * Shift_JIS (CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
+     *
+     * @param string $str
+     * @return string
+     */
+    private function _encode($str)
+    {
+        return mb_convert_encoding($str, 'UTF-8', 'CP932');
+    }
+
+    // }}}
+    // {{{ _decode()
+
+    /**
+     * UTF-8‚Ì•¶Žš—ñ‚ðShift_JIS (CP932) ‚É•ÏŠ·‚·‚é
+     *
+     * @param string $str
+     * @return string
+     */
+    private function _decode($str)
+    {
+        return mb_convert_encoding($str, 'CP932', 'UTF-8');
+    }
+
+    // }}}
+    // {{{ _encodeKey()
+
+    /**
+     * ƒL[‚ðƒGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    protected function _encodeKey($key)
+    {
+        return $this->_encode($key);
+    }
+
+    // }}}
+    // {{{ _decodeKey()
+
+    /**
+     * ƒL[‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    protected function _decodeKey($key)
+    {
+        return $this->_decode($key);
+    }
+
+    // }}}
+    // {{{ _encodeValue()
+
+    /**
+     * ’l‚ðƒGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    protected function _encodeValue($value)
+    {
+        return $this->_encode($value);
+    }
+
+    // }}}
+    // {{{ _decodeValue()
+
+    /**
+     * ’l‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    protected function _decodeValue($value)
+    {
+        return $this->_decode($value);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Modified: p2ex/trunk/lib/P2KeyValueStore.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore.php	2010-01-01 11:06:33 UTC (rev 757)
+++ p2ex/trunk/lib/P2KeyValueStore.php	2010-01-01 12:11:16 UTC (rev 758)
@@ -34,6 +34,12 @@
     const Q_CLEAN       = 'DELETE FROM $__table';
     const Q_GC          = 'DELETE FROM $__table WHERE mtime < :expires';
 
+    const KVS_DEFAULT       = 'default';
+    const KVS_BINARY        = 'Binary';
+    const KVS_COMPRESSING   = 'Compressing';
+    const KVS_SHIFTJS       = 'ShiftJIS';
+    const KVS_SERIALIZING   = 'Serializing';
+
     // }}}
     // {{{ staric private properties
 
@@ -80,7 +86,7 @@
      * @return P2KeyValueStore
      * @throws InvalidArgumentException, UnexpectedValueException, RuntimeException, PDOException
      */
-    static public function getStore($fileName, $type = 'default', &$openedPath = null)
+    static public function getStore($fileName, $type = self::KVS_DEFAULT, &$openedPath = null)
     {
         // ˆø”‚ÌŒ^‚ðƒ`ƒFƒbƒN
         if (!is_string($fileName)) {
@@ -91,7 +97,7 @@
         }
 
         // ƒNƒ‰ƒX–¼‚ðƒ`ƒFƒbƒN
-        if ($type == 'default') {
+        if ($type == self::KVS_DEFAULT) {
             $className = 'P2KeyValueStore';
         } else {
             $className = 'P2KeyValueStore_' . $type;



P2-php-svn メーリングリストの案内
Back to archive index