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",
150 error (
"whos_line_format: command '%c' unknown",
155 << std::resetiosflags (std::ios::right);
170 for (
const auto& syminfo :
m_lst)
172 if (
name == syminfo.name ())
173 return syminfo.value ();
181 std::list<std::string>
retval;
183 for (
const auto& syminfo :
m_lst)
184 retval.push_back (syminfo.name ());
191 int nesting_level)
const
207 for (
const auto& syminfo :
m_lst)
211 ni.
assign (
"function", caller_function_name);
212 ni.
assign (
"level", nesting_level);
214 name_info(j) = syminfo.name ();
215 global_info(j) = syminfo.is_global ();
216 persistent_info(j) = syminfo.is_persistent ();
220 size_info(j) = val.
size ();
225 nesting_info(j) = ni;
232 info.
assign (
"name", name_info);
233 info.
assign (
"size", size_info);
234 info.
assign (
"bytes", bytes_info);
235 info.
assign (
"class", class_info);
236 info.
assign (
"global", global_info);
237 info.
assign (
"sparse", sparse_info);
238 info.
assign (
"complex", complex_info);
239 info.
assign (
"nesting", nesting_info);
240 info.
assign (
"persistent", persistent_info);
247 const std::list<whos_parameter> params)
const
249 std::ostringstream param_buf;
253 for (
const auto& param : params)
255 if (param.command !=
'\0')
258 switch (param.modifier)
262 << std::setw (param.parameter_length);
264 << std::setw (param.parameter_length);
268 os << std::setiosflags (std::ios::right)
269 << std::setw (param.parameter_length);
270 param_buf << std::setiosflags (std::ios::right)
271 << std::setw (param.parameter_length);
275 if (param.command !=
's')
278 << std::setw (param.parameter_length);
280 << std::setw (param.parameter_length);
286 << std::setw (param.parameter_length);
288 << std::setw (param.parameter_length);
291 if (param.command ==
's' && param.modifier ==
'c')
293 int a = param.first_parameter_length - param.balance;
295 int b = param.parameter_length - a - param.text.length ();
300 << std::setw (b) <<
""
307 << std::setw (b) <<
""
313 param_buf << param.line;
316 << std::resetiosflags (std::ios::right);
318 << std::resetiosflags (std::ios::right);
323 param_buf << param.line;
327 os << param_buf.str ();
331 const std::string&
format)
const
333 if (!
m_lst.empty ())
344 for (
const auto& syminfo :
m_lst)
346 syminfo.display_line (os, params);
350 elements += val.
numel ();
354 os <<
"\nTotal is " << elements
355 << (elements == 1 ?
" element" :
" elements")
356 <<
" using " << bytes << (bytes == 1 ?
" byte" :
" bytes")
361 std::list<whos_parameter>
365 size_t format_len =
format.length ();
367 std::list<whos_parameter> params;
372 std::string param_string =
"abcenst";
375 size_t pos_a, pos_b, pos_c, pos_e, pos_n, pos_s, pos_t;
377 pos_a = param_string.find (
'a');
378 pos_b = param_string.find (
'b');
379 pos_c = param_string.find (
'c');
380 pos_e = param_string.find (
'e');
381 pos_n = param_string.find (
'n');
382 pos_s = param_string.find (
's');
383 pos_t = param_string.find (
't');
385 param_names(pos_a) =
"Attr";
386 param_names(pos_b) =
"Bytes";
387 param_names(pos_c) =
"Class";
388 param_names(pos_e) =
"Elements";
389 param_names(pos_n) =
"Name";
390 param_names(pos_s) =
"Size";
391 param_names(pos_t) =
"Type";
393 for (
size_t i = 0; i < param_string.length (); i++)
394 param_length(i) = param_names(i).length ();
397 param_length(pos_a) = 5;
402 for (
const auto& syminfo :
m_lst)
404 std::stringstream ss1, ss2;
407 str = syminfo.name ();
408 param_length(pos_n) = ((str.length ()
409 >
static_cast<size_t> (param_length(pos_n)))
410 ? str.length () : param_length(pos_n));
415 param_length(pos_t) = ((str.length ()
416 >
static_cast<size_t> (param_length(pos_t)))
417 ? str.length () : param_length(pos_t));
419 elements1 = val.
numel ();
422 param_length(pos_e) = ((str.length ()
423 >
static_cast<size_t> (param_length(pos_e)))
424 ? str.length () : param_length(pos_e));
429 param_length(pos_b) = ((str.length ()
430 >
static_cast<size_t> (param_length(pos_b)))
431 ? str.length () : param_length (pos_b));
435 while (
static_cast<size_t> (idx) < format_len)
454 pos = cmd.find (
';');
455 if (pos == std::string::npos)
456 error (
"parameter without ; in format");
458 cmd = cmd.substr (0, pos+1);
460 idx += cmd.length ();
464 if (cmd.find_first_of (
"crl") != 1)
465 items = sscanf (cmd.c_str (),
"%c%c:%d:%d:%d;",
466 &garbage, ¶m.
command, &a, &b, &balance);
468 items = sscanf (cmd.c_str (),
"%c%c%c:%d:%d:%d;",
470 &a, &b, &balance) - 1;
473 error (
"whos_line_format: found parameter structure without command");
477 && param_string.find (param.
command) == std::string::npos)
485 pos = param_string.find (param.
command);
486 if (pos == std::string::npos)
487 error (
"whos_line_format: '%c' is not a command", param.
command);
490 param.
text = param_names(pos);
491 param.
line.assign (param_names(pos).
length (),
'=');
510 for (
const auto& syminfo :
m_lst)
514 int first1 = dims_str.find (
'x');
515 int total1 = dims_str.length ();
516 int rest1 = total1 - first1;
517 rest = (rest1 > rest ? rest1 : rest);
518 first = (first1 > first ? first1 : first);
519 total = (total1 > total ? total1 : total);
525 first += balance - first;
540 error (
"whos_line_format: modifier 'c' not available for command '%c'",
552 < param_length(pos_s)
553 ? param_length(pos_s)
556 params.push_back (param);
564 pos =
text.find (
'%');
565 if (pos != std::string::npos)
569 idx +=
text.length ();
571 param.
line.assign (
text.length (),
' ');
572 params.push_back (param);
Vector representing the dimensions (size) of an Array.
size_t length(void) const
std::list< symbol_info > m_lst
octave_map map_value(const std::string &caller_function_name, int nesting_level) const
std::list< whos_parameter > parse_whos_line_format(const std::string &format) const
octave_value varval(const std::string &name) 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< std::string > names(void) const
void display_line(std::ostream &os, const std::list< whos_parameter > ¶ms) const
void assign(const std::string &k, const Cell &val)
void assign(const std::string &k, const octave_value &val)
std::string get_dims_str(void) const
bool issparse(void) const
octave_idx_type numel(void) const
std::string class_name(void) const
size_t byte_size(void) const
bool iscomplex(void) const
std::string type_name(void) const
void error(const char *fmt,...)
size_t format(std::ostream &os, 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()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
int first_parameter_length