changeset 17554:f0d21e7d4653

avoid Cell arrays in usr_transfer classes * urlwrite.cc (Furlwrite, Furlread): Require property value pairs to be passed as a cell array of character strings. Extract as Array<std::string>. (base_url_transfer::base_url_transfer, curl_transfer::curl_transfer, curl_transfer::form_query_string, url_transfer::url_transfer): Accept Array<std::string> for parameters instead of Cell object.
author John W. Eaton <jwe@octave.org>
date Thu, 03 Oct 2013 14:33:31 -0400
parents 2d01e20abd85
children 0946b0e06544
files libinterp/dldfcn/urlwrite.cc liboctave/util/action-container.h liboctave/util/unwind-prot.cc liboctave/util/unwind-prot.h
diffstat 1 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/urlwrite.cc	Thu Oct 03 14:27:47 2013 -0400
+++ b/libinterp/dldfcn/urlwrite.cc	Thu Oct 03 14:33:31 2013 -0400
@@ -82,7 +82,8 @@
 
   base_url_transfer (const std::string& /* url */,
                      const std::string& /* method */,
-                     const Cell& /* param */, std::ostream& /* os */)
+                     const Array<std::string>& /* param */,
+                     std::ostream& /* os */)
     : count (1), host (), userpwd (), valid (false), ascii_mode (false),
       ok (true), errmsg () { }
 
@@ -411,7 +412,7 @@
   }
 
   curl_transfer (const std::string& url, const std::string& method,
-                 const Cell& param, std::ostream& os)
+                 const Array<std::string>& param, std::ostream& os)
     : base_url_transfer (url, method, param, os),
       curl (curl_easy_init ()), errnum ()
   {
@@ -823,14 +824,14 @@
     SETOPT (CURLOPT_QUOTE, 0);
   }
 
-  std::string form_query_string (const Cell& param)
+  std::string form_query_string (const Array<std::string>& param)
   {
     std::ostringstream query;
 
     for (int i = 0; i < param.numel (); i += 2)
       {
-        std::string name = param(i).string_value ();
-        std::string text = param(i+1).string_value ();
+        std::string name = param(i);
+        std::string text = param(i+1);
 
         // Encode strings.
         char *enc_name = curl_easy_escape (curl, name.c_str (),
@@ -892,7 +893,7 @@
   }
 
   url_transfer (const std::string& url, const std::string& method,
-                const Cell& param, std::ostream& os)
+                const Array<std::string>& param, std::ostream& os)
     : rep (new REP_CLASS (url, method, param, os))
   {
 #if !defined (HAVE_CURL)
@@ -1295,7 +1296,7 @@
     }
 
   std::string method;
-  Cell param; // empty cell array
+  Array<std::string> param;
 
   if (nargin == 4)
     {
@@ -1313,11 +1314,11 @@
           return retval;
         }
 
-      param = args(3).cell_value ();
+      param = args(3).cellstr_value ();
 
       if (error_state)
         {
-          error ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell");
+          error ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of character strings");
           return retval;
         }
 
@@ -1437,7 +1438,7 @@
     }
 
   std::string method;
-  Cell param; // empty cell array
+  Array<std::string> param;
 
   if (nargin == 3)
     {
@@ -1455,11 +1456,11 @@
           return retval;
         }
 
-      param = args(2).cell_value ();
+      param = args(2).cellstr_value ();
 
       if (error_state)
         {
-          error ("urlread: parameters (PARAM) for get and post requests must be given as a cell");
+          error ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of character strings");
           return retval;
         }