|
93 | 93 | for i = 1:numel(obj) |
94 | 94 | yamldocs{i} = obj2yaml('', obj{i}, rootlevel, opt); |
95 | 95 | end |
96 | | - yaml = ['---' sprintf('\n') strjoin(yamldocs, [sprintf('\n') '---' sprintf('\n')])]; |
| 96 | + yaml = ['---' sprintf('\n') joinlines(yamldocs, [sprintf('\n') '---' sprintf('\n')])]; |
97 | 97 | else |
98 | 98 | yaml = obj2yaml(rootname, obj, rootlevel, opt); |
99 | 99 | end |
|
171 | 171 | lines{i} = sprintf('%s- %s', repmat(' ', 1, (level + 1) * opt.indent), strtrim(lines{i})); |
172 | 172 | end |
173 | 173 | end |
174 | | - txt = sprintf('%s\n%s', txt, strjoin(lines, sprintf('\n'))); |
| 174 | + txt = sprintf('%s\n%s', txt, joinlines(lines, sprintf('\n'))); |
175 | 175 | else |
176 | 176 | lines = cell(1, len); |
177 | 177 | for i = 1:len |
|
180 | 180 | lines{i} = sprintf('%s- %s', repmat(' ', 1, level * opt.indent), strtrim(lines{i})); |
181 | 181 | end |
182 | 182 | end |
183 | | - txt = strjoin(lines, sprintf('\n')); |
| 183 | + txt = joinlines(lines, sprintf('\n')); |
184 | 184 | end |
185 | 185 |
|
186 | 186 | %% ------------------------------------------------------------------------- |
|
243 | 243 | for e = 1:length(names) |
244 | 244 | lines{e} = obj2yaml(names{e}, item.(names{e}), level + 1, varargin{:}); |
245 | 245 | end |
246 | | - txt = sprintf('%s\n%s', txt, strjoin(lines, sprintf('\n'))); |
| 246 | + txt = sprintf('%s\n%s', txt, joinlines(lines, sprintf('\n'))); |
247 | 247 | else |
248 | 248 | lines = cell(1, length(names)); |
249 | 249 | for e = 1:length(names) |
250 | 250 | lines{e} = obj2yaml(names{e}, item.(names{e}), level, varargin{:}); |
251 | 251 | end |
252 | | - txt = strjoin(lines, sprintf('\n')); |
| 252 | + txt = joinlines(lines, sprintf('\n')); |
253 | 253 | end |
254 | 254 | end |
255 | 255 |
|
|
295 | 295 | lines{i} = obj2yaml(num2str(names{i}), val{i}, level + 1, varargin{:}); |
296 | 296 | end |
297 | 297 | end |
298 | | - txt = sprintf('%s\n%s', txt, strjoin(lines, sprintf('\n'))); |
| 298 | + txt = sprintf('%s\n%s', txt, joinlines(lines, sprintf('\n'))); |
299 | 299 | else |
300 | 300 | lines = cell(1, length(names)); |
301 | 301 | for i = 1:length(names) |
|
305 | 305 | lines{i} = obj2yaml(num2str(names{i}), val{i}, level, varargin{:}); |
306 | 306 | end |
307 | 307 | end |
308 | | - txt = strjoin(lines, sprintf('\n')); |
| 308 | + txt = joinlines(lines, sprintf('\n')); |
309 | 309 | end |
310 | 310 |
|
311 | 311 | %% ------------------------------------------------------------------------- |
|
561 | 561 | else |
562 | 562 | valstr = 'null'; |
563 | 563 | end |
| 564 | + |
| 565 | +%% ------------------------------------------------------------------------- |
| 566 | + |
| 567 | +function str = joinlines(lines, sep) |
| 568 | + |
| 569 | +str = [sprintf(['%s' sep], lines{1:end - 1}) lines{end}]; |
0 commit comments