diff m-toolbox/classes/+utils/@xml/cellstr2str.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@xml/cellstr2str.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,32 @@
+
+function str = cellstr2str(c)
+  
+  if ~isempty(c)
+    
+    str = '{';
+    
+    if ~iscellstr(c)
+      error('### The input cell must be a cell of strings. [%s]', utils.helper.val2str(c));
+    end
+    
+    for cc = 1:size(c,1)
+      
+      str = [str, '''', maskQuote(c{cc, 1}), ''''];
+      for rr = 2:size(c,2)
+        str = [str, ', ''', maskQuote(c{cc, rr}), '''' ];
+      end
+      
+      str = [str '; '];
+    end
+    
+    str = [str(1:end-2), '}'];
+    
+  else
+    str = sprintf('cell(%d,%d)', size(c));
+  end
+  
+end
+
+function str = maskQuote(str)
+  str = strrep(str, '''', '''''');
+end