26 #if defined (HAVE_CONFIG_H)
47 const std::list<whos_parameter>& params)
const
51 auto i = params.begin ();
55 while (i != params.end ())
71 os << std::setiosflags (std::ios::right)
79 - dims_str.find (
'x');
83 front = (front > 0) ? front : 0;
84 back = (back > 0) ? back : 0;
104 error (
"whos_line_format: modifier '%c' unknown",
151 error (
"whos_line_format: command '%c' unknown",
156 << std::resetiosflags (std::ios::right);
171 for (
const auto& syminfo :
m_lst)
173 if (name == syminfo.name ())
174 return syminfo.value ();
182 std::list<std::string> retval;
184 for (
const auto& syminfo :
m_lst)
185 retval.push_back (syminfo.name ());
192 int nesting_level)
const
208 for (
const auto& syminfo :
m_lst)
212 ni.
assign (
"function", caller_function_name);
213 ni.
assign (
"level", nesting_level);
215 name_info(j) = syminfo.name ();
216 global_info(j) = syminfo.is_global ();
217 persistent_info(j) = syminfo.is_persistent ();
221 size_info(j) = val.
size ();
226 nesting_info(j) = ni;
233 info.
assign (
"name", name_info);
234 info.
assign (
"size", size_info);
235 info.
assign (
"bytes", bytes_info);
236 info.
assign (
"class", class_info);
237 info.
assign (
"global", global_info);
238 info.
assign (
"sparse", sparse_info);
239 info.
assign (
"complex", complex_info);
240 info.
assign (
"nesting", nesting_info);
241 info.
assign (
"persistent", persistent_info);
248 const std::list<whos_parameter> params)
const
250 std::ostringstream param_buf;
254 for (
const auto& param : params)
256 if (param.command !=
'\0')
259 switch (param.modifier)
263 << std::setw (param.parameter_length);
265 << std::setw (param.parameter_length);
269 os << std::setiosflags (std::ios::right)
270 << std::setw (param.parameter_length);
271 param_buf << std::setiosflags (std::ios::right)
272 << std::setw (param.parameter_length);
276 if (param.command !=
's')
279 << std::setw (param.parameter_length);
281 << std::setw (param.parameter_length);
287 << std::setw (param.parameter_length);
289 << std::setw (param.parameter_length);
292 if (param.command ==
's' && param.modifier ==
'c')
294 int a = param.first_parameter_length - param.balance;
296 int b = param.parameter_length - a - param.text.length ();
301 << std::setw (b) <<
""
308 << std::setw (b) <<
""
314 param_buf << param.line;
317 << std::resetiosflags (std::ios::right);
319 << std::resetiosflags (std::ios::right);
324 param_buf << param.line;
328 os << param_buf.str ();
332 const std::string&
format)
const
334 if (!
m_lst.empty ())
336 std::size_t bytes = 0;
337 std::size_t elements = 0;
345 for (
const auto& syminfo :
m_lst)
347 syminfo.display_line (os, params);
351 elements += val.
numel ();
355 os <<
"\nTotal is " << elements
356 << (elements == 1 ?
" element" :
" elements")
357 <<
" using " << bytes << (bytes == 1 ?
" byte" :
" bytes")
362 std::list<whos_parameter>
366 std::size_t format_len =
format.length ();
368 std::list<whos_parameter> params;
373 std::string param_string =
"abcenst";
376 std::size_t pos_a, pos_b, pos_c, pos_e, pos_n, pos_s, pos_t;
378 pos_a = param_string.find (
'a');
379 pos_b = param_string.find (
'b');
380 pos_c = param_string.find (
'c');
381 pos_e = param_string.find (
'e');
382 pos_n = param_string.find (
'n');
383 pos_s = param_string.find (
's');
384 pos_t = param_string.find (
't');
386 param_names(pos_a) =
"Attr";
387 param_names(pos_b) =
"Bytes";
388 param_names(pos_c) =
"Class";
389 param_names(pos_e) =
"Elements";
390 param_names(pos_n) =
"Name";
391 param_names(pos_s) =
"Size";
392 param_names(pos_t) =
"Type";
394 for (std::size_t i = 0; i < param_string.length (); i++)
395 param_length(i) = param_names(i).length ();
398 param_length(pos_a) = 6;
403 for (
const auto& syminfo :
m_lst)
405 std::stringstream ss1, ss2;
408 str = syminfo.name ();
409 param_length(pos_n) = ((str.length ()
410 >
static_cast<std::size_t
> (param_length(pos_n)))
411 ? str.length () : param_length(pos_n));
416 param_length(pos_t) = ((str.length ()
417 >
static_cast<std::size_t
> (param_length(pos_t)))
418 ? str.length () : param_length(pos_t));
420 elements1 = val.
numel ();
423 param_length(pos_e) = ((str.length ()
424 >
static_cast<std::size_t
> (param_length(pos_e)))
425 ? str.length () : param_length(pos_e));
430 param_length(pos_b) = ((str.length ()
431 >
static_cast<std::size_t
> (param_length(pos_b)))
432 ? str.length () : param_length (pos_b));
436 while (
static_cast<std::size_t
> (idx) < format_len)
455 pos = cmd.find (
';');
456 if (pos == std::string::npos)
457 error (
"parameter without ; in format");
459 cmd = cmd.substr (0, pos+1);
461 idx += cmd.length ();
465 if (cmd.find_first_of (
"crl") != 1)
466 items = sscanf (cmd.c_str (),
"%c%c:%d:%d:%d;",
467 &garbage, ¶m.
command, &a, &b, &balance);
469 items = sscanf (cmd.c_str (),
"%c%c%c:%d:%d:%d;",
471 &a, &b, &balance) - 1;
474 error (
"whos_line_format: found parameter structure without command");
478 && param_string.find (param.
command) == std::string::npos)
486 pos = param_string.find (param.
command);
487 if (pos == std::string::npos)
488 error (
"whos_line_format: '%c' is not a command", param.
command);
491 param.
text = param_names(pos);
492 param.
line.assign (param_names(pos).
length (),
'=');
511 for (
const auto& syminfo :
m_lst)
515 int first1 = dims_str.find (
'x');
516 int total1 = dims_str.length ();
517 int rest1 = total1 - first1;
518 rest = (rest1 > rest ? rest1 : rest);
519 first = (first1 > first ? first1 : first);
520 total = (total1 > total ? total1 : total);
526 first += balance - first;
541 error (
"whos_line_format: modifier 'c' not available for command '%c'",
553 < param_length(pos_s)
554 ? param_length(pos_s)
557 params.push_back (param);
565 pos = text.find (
'%');
566 if (pos != std::string::npos)
567 text = text.substr (0, pos);
570 idx += text.length ();
572 param.
line.assign (text.length (),
' ');
573 params.push_back (param);
std::list< symbol_info > m_lst
std::size_t length(void) const
Vector representing the dimensions (size) of an Array.
void assign(const std::string &k, const Cell &val)
void assign(const std::string &k, const octave_value &val)
bool issparse(void) const
octave_idx_type numel(void) const
std::string class_name(void) const
std::size_t byte_size(void) const
OCTINTERP_API std::string get_dims_str(void) const
bool iscomplex(void) const
std::string type_name(void) const
void print_descriptor(std::ostream &os, const std::list< whos_parameter > params) const
void display(std::ostream &os, const std::string &format) const
std::list< whos_parameter > parse_whos_line_format(const std::string &format) const
octave_value varval(const std::string &name) const
std::list< std::string > names(void) const
octave_map map_value(const std::string &caller_function_name, int nesting_level) const
void display_line(std::ostream &os, const std::list< whos_parameter > ¶ms) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
int first_parameter_length
std::size_t format(std::ostream &os, const char *fmt,...)