IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
itemlist2cell.m
Go to the documentation of this file.
1 %> @file
2 %> @ingroup introspection conversion
3 %> @brief Returns an array of mapitem objects matching the informed criteria.
4 %
5 %> @brief Converts an array of mapitem objects to a cell of indented strings.
6 %> @param list Array of mapitem objects
7 %> @param verboselevel = 3. Enters debug mode at verboselevel <= 2
8 %> @param style = 0. 0-style for blockmenu; 1-suitable for documents
9 %> @retval cc Cell of strings
10 function dd = itemlist2cell(list, verboselevel, style)
11 
12 NINDENT = 2;
13 
14 if ~exist('verboselevel', 'var')
15  verboselevel = 0;
16 end;
17 if ~exist('style', 'var')
18  style = 0;
19 end;
20 n = length(list);
21 if style == 0
22  if verboselevel <= 2 % Debug
23  nc = 3;
24  else
25  nc = 2;
26  end;
27 elseif style == 1
28  nc = 3;
29 else
30  irerror(sprintt('Invalid style: %d', style));
31 end;
32 cc = cell(n, nc);
33 for i = 1:n
34  if list(i).flag_final
35  sep1 = ''; sep2 = '';
36  c1 = '.';
37  sp = 32;
38  else
39  sep1 = ''; sep2 = '';
40  c1 = '+';
41  if style == 0
42  sp = '-';
43  elseif style == 1
44  sp = ' ';
45  end;
46  end;
47  spaces = char(sp*ones(1, NINDENT*(list(i).level-1)));
48 
49  if style == 0
50  if verboselevel <= 2 % Debug
51  cc(i, :) = {c1, ...
52  [spaces, sep1, list(i).title, sep2], ...
53  [' ::', list(i).name, '::']};
54 
55  else
56  cc(i, :) = {c1, ...
57  [spaces, sep1, list(i).title, sep2]};
58  end;
59  elseif style == 1
60  cc(i, :) = {c1, ...
61  [spaces, list(i).name], ...
62  [spaces, list(i).title]};
63  end;
64 
65 end;
66 
67 if style == 0
68  for i = 1:nc
69  cols{i} = char(cc(:, i));
70  end;
71  dd = cellstr(cat(2, cols{:}));
72 elseif style == 1
73  dd = cc;
74 end;
75 
76 % dd = sort(dd);
function irerror(in s)
function blockmenu(in varargin)
Map item.
Definition: mapitem.m:3
function itemlist2cell(in list, in verboselevel, in style)
Converts an array of mapitem objects to a cell of indented strings.