- HttpQueryString implements ArrayAccess
authorMichael Wallner <mike@php.net>
Sat, 8 Jul 2006 12:28:25 +0000 (12:28 +0000)
committerMichael Wallner <mike@php.net>
Sat, 8 Jul 2006 12:28:25 +0000 (12:28 +0000)
docs/functions.html
http_querystring_object.c
package2.xml
php_http_querystring_object.h

index f78ada38c405890cf19963f4c2f7cb172c9b9a90..743a151fc7ad938c919560bdb374cfd19c912321 100644 (file)
@@ -663,6 +663,14 @@ WARNING: Don't use any character set that can contain NUL bytes like UTF-16.</p>
 <p>Implements Serializable.</p>
 <h3 id="HttpQueryString_unserialize">void HttpQueryString::unserialize(string serialized)</h3>
 <p>Implements Serializable.</p>
+<h3 id="HttpQueryString_offsetGet">mixed HttpQueryString::offsetGet(string offset)</h3>
+<p>Implements ArrayAccess.</p>
+<h3 id="HttpQueryString_offsetSet">void HttpQueryString::offsetSet(string offset, mixed value)</h3>
+<p>Implements ArrayAccess.</p>
+<h3 id="HttpQueryString_offsetExists">bool HttpQueryString::offsetExists(string offset)</h3>
+<p>Implements ArrayAccess.</p>
+<h3 id="HttpQueryString_offsetUnset">void HttpQueryString::offsetUnset(string offset)</h3>
+<p>Implements ArrayAccess.</p>
 <hr noshade>
 <h1 id="http_request_object.c">http_request_object.c</h1>
 <h2 id="HttpRequest" class="o">HttpRequest</h2>
@@ -1337,6 +1345,10 @@ http.cache_log is set.</p>
 <li><a href="#HttpQueryString_xlate">HttpQueryString::xlate()</a></li>
 <li><a href="#HttpQueryString_serialize">HttpQueryString::serialize()</a></li>
 <li><a href="#HttpQueryString_unserialize">HttpQueryString::unserialize()</a></li>
+<li><a href="#HttpQueryString_offsetGet">HttpQueryString::offsetGet()</a></li>
+<li><a href="#HttpQueryString_offsetSet">HttpQueryString::offsetSet()</a></li>
+<li><a href="#HttpQueryString_offsetExists">HttpQueryString::offsetExists()</a></li>
+<li><a href="#HttpQueryString_offsetUnset">HttpQueryString::offsetUnset()</a></li>
 </li>
 </ul>
 </li>
@@ -1453,7 +1465,7 @@ http.cache_log is set.</p>
 </li>
 </ul>
 </div>
-    <p><b>Generated at: Fri, 07 Jul 2006 13:48:43 +0200</b></p>
+    <p><b>Generated at: Fri, 07 Jul 2006 21:23:59 +0200</b></p>
 </body>
 </html>
 
index 3ae00fdd87d9251af2c22cb2655fbe277395e66e..33e4356f947bbd4a31dd12d71e6afa1b614aaf1a 100644 (file)
@@ -77,6 +77,24 @@ HTTP_BEGIN_ARGS(unserialize, 1)
        HTTP_ARG_VAL(serialized, 0)
 HTTP_END_ARGS;
 
+HTTP_BEGIN_ARGS(offsetGet, 1)
+       HTTP_ARG_VAL(offset, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(offsetSet, 2)
+       HTTP_ARG_VAL(offset, 0)
+       HTTP_ARG_VAL(value, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(offsetExists, 1)
+       HTTP_ARG_VAL(offset, 0)
+HTTP_END_ARGS;
+
+HTTP_BEGIN_ARGS(offsetUnset, 1)
+       HTTP_ARG_VAL(offset, 0)
+HTTP_END_ARGS;
+
+
 #define OBJ_PROP_CE http_querystring_object_ce
 zend_class_entry *http_querystring_object_ce;
 zend_function_entry http_querystring_object_fe[] = {
@@ -108,6 +126,12 @@ zend_function_entry http_querystring_object_fe[] = {
        HTTP_QUERYSTRING_ME(serialize, ZEND_ACC_PUBLIC)
        HTTP_QUERYSTRING_ME(unserialize, ZEND_ACC_PUBLIC)
        
+       /* Implements ArrayAccess */
+       HTTP_QUERYSTRING_ME(offsetGet, ZEND_ACC_PUBLIC)
+       HTTP_QUERYSTRING_ME(offsetSet, ZEND_ACC_PUBLIC)
+       HTTP_QUERYSTRING_ME(offsetExists, ZEND_ACC_PUBLIC)
+       HTTP_QUERYSTRING_ME(offsetUnset, ZEND_ACC_PUBLIC)
+       
        EMPTY_FUNCTION_ENTRY
 };
 static zend_object_handlers http_querystring_object_handlers;
@@ -117,7 +141,7 @@ PHP_MINIT_FUNCTION(http_querystring_object)
        HTTP_REGISTER_CLASS_EX(HttpQueryString, http_querystring_object, NULL, 0);
        
 #ifndef WONKY
-       zend_class_implements(http_querystring_object_ce TSRMLS_CC, 1, zend_ce_serializable);
+       zend_class_implements(http_querystring_object_ce TSRMLS_CC, 2, zend_ce_serializable, zend_ce_arrayaccess);
 #endif
        
        DCL_STATIC_PROP_N(PRIVATE, instance);
@@ -535,6 +559,78 @@ PHP_METHOD(HttpQueryString, unserialize)
 }
 /* }}} */
 
+/* {{{ proto mixed HttpQueryString::offsetGet(string offset)
+ *
+ * Implements ArrayAccess.
+ */
+PHP_METHOD(HttpQueryString, offsetGet)
+{
+       char *offset_str;
+       int offset_len;
+       zval **value;
+       
+       if (    (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &offset_str, &offset_len)) &&
+                       (SUCCESS == zend_hash_find(Z_ARRVAL_P(GET_PROP(queryArray)), offset_str, offset_len + 1, (void *) &value))) {
+               RETVAL_ZVAL(*value, 1, 0);
+       }
+}
+/* }}} */
+
+/* {{{ proto void HttpQueryString::offsetSet(string offset, mixed value)
+ *
+ * Implements ArrayAccess.
+ */
+PHP_METHOD(HttpQueryString, offsetSet)
+{
+       char *offset_str;
+       int offset_len;
+       zval *value;
+       
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &offset_str, &offset_len, &value)) {
+               zval *qarr = GET_PROP(queryArray), *qstr = GET_PROP(queryString);
+               
+               ZVAL_ADDREF(value);
+               add_assoc_zval_ex(qarr, offset_str, offset_len + 1, value);
+               http_querystring_update(qarr, qstr);
+       }
+}
+/* }}} */
+
+/* {{{ proto bool HttpQueryString::offsetExists(string offset)
+ *
+ * Implements ArrayAccess.
+ */
+PHP_METHOD(HttpQueryString, offsetExists)
+{
+       char *offset_str;
+       int offset_len;
+       zval **value;
+       
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &offset_str, &offset_len)) {
+               RETURN_BOOL((SUCCESS == zend_hash_find(Z_ARRVAL_P(GET_PROP(queryArray)), offset_str, offset_len + 1, (void *) &value)) && (Z_TYPE_PP(value) != IS_NULL));
+       }
+}
+/* }}} */
+
+/* {{{ proto void HttpQueryString::offsetUnset(string offset)
+ *
+ * Implements ArrayAccess.
+ */
+PHP_METHOD(HttpQueryString, offsetUnset)
+{
+       char *offset_str;
+       int offset_len;
+       
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &offset_str, &offset_len)) {
+               zval *qarr = GET_PROP(queryArray);
+               
+               if (SUCCESS == zend_hash_del(Z_ARRVAL_P(qarr), offset_str, offset_len + 1)) {
+                       http_querystring_update(qarr, GET_PROP(queryString));
+               }
+       }
+}
+/* }}} */
+
 #endif /* ZEND_ENGINE_2 */
 
 /*
index 646928ffe2ff9195101e9571e86e9aca07fe40fb..2a1c73b7226bcf8bcd4e831a663cf691fced8129 100644 (file)
@@ -41,7 +41,8 @@ support. Parallel requests are available for PHP 5 and greater.
  <notes><![CDATA[
 * Fixed HttpResponse::capture() failure if buffered output exceeds 40k
 * Added HttpQueryString::mod(array $params) method
-* Added HttpMessage::get(string $name) method
+* Added ArrayAccess to interfaces implemented by HttpQueryString
+* Added HttpMessage::getHeader(string $name) method
 ]]></notes>
  <contents>
   <dir name="/">
index 26b3070ce2e0b33c9b33073060f922e7cf896aeb..56e1a0f3e63e8afef2025e6e2a4616a77e053636 100644 (file)
@@ -59,7 +59,10 @@ PHP_METHOD(HttpQueryString, singleton);
 #endif
 PHP_METHOD(HttpQueryString, serialize);
 PHP_METHOD(HttpQueryString, unserialize);
-
+PHP_METHOD(HttpQueryString, offsetGet);
+PHP_METHOD(HttpQueryString, offsetSet);
+PHP_METHOD(HttpQueryString, offsetExists);
+PHP_METHOD(HttpQueryString, offsetUnset);
 #endif
 #endif