type_print (type, "", &tmp_stream, -1);
- return std::move (tmp_stream.string ());
+ return tmp_stream.release ();
}
/* Given a type TYPE, look up the type of the component of type named NAME.
print_floating (valaddr, type, &tmp_stream);
- std::string &s = tmp_stream.string ();
+ std::string s = tmp_stream.release ();
size_t skip_count = 0;
/* Modify for Ada rules. */
string_file buf;
ada_print_scalar (type, val, &buf);
- return std::move (buf.string ());
+ return buf.release ();
}
/* Assuming that the (PARENT_VALUE, PARENT_TYPE) pair designates
string_file buffer;
common_val_print (value, &buffer, 0, opts, current_language);
- return std::move (buffer.string ());
+ return buffer.release ();
}
/* Assuming that the (VALUE, TYPE) pair designates an array varobj,
| OPERATOR OBJC_LBRAC ']'
{ $$ = operator_stoken ("[]"); }
| OPERATOR conversion_type_id
- { string_file buf;
-
+ {
+ string_file buf;
c_print_type ($2, NULL, &buf, -1, 0,
&type_print_raw_options);
- std::string name = std::move (buf.string ());
+ std::string name = buf.release ();
/* This also needs canonicalization. */
gdb::unique_xmalloc_ptr<char> canon
gdb_assert_not_reached ("bad var_type");
}
- return std::move (stb.string ());
+ return stb.release ();
}
PopUserExpressionPolicy::pop_user_expression (&buf);
AddCodeFooterPolicy::add_code_footer (m_instance->scope (), &buf);
- return buf.string ();
+ return buf.release ();
}
private:
string_file stb;
LA_PRINT_TYPE (type, "", &stb, -1, 0, &type_print_raw_options);
- return std::move (stb.string ());
+ return stb.release ();
}
catch (const gdb_exception &except)
{
explicit_loc->line_offset.offset);
}
- return std::move (buf.string ());
+ return buf.release ();
}
/* See description in location.h. */
stream.puts ("1 ");
opts.dump (&stream, text);
- maintenance_test_options_command_completion_text
- = std::move (stream.string ());
+ maintenance_test_options_command_completion_text = stream.release ();
}
else
{
string_file stb;
stb.putstrn (buf, n, '\\');
- return std::move (stb.string ());
+ return stb.release ();
}
int
}
/* Capture the disassembled instruction. */
- tal.insn = std::move (gdb_dis_out.string ());
- gdb_dis_out.clear ();
+ tal.insn = gdb_dis_out.release ();
/* And capture the address the instruction is at. */
tal.addr = orig_pc;
print_address (gdbarch, orig_pc, &gdb_dis_out);
- tal.addr_string = std::move (gdb_dis_out.string ());
- gdb_dis_out.clear ();
+ tal.addr_string = std::move (gdb_dis_out.release ());
if (addr_size != nullptr)
{
gdbarch_print_registers_info (gdbarch, &stream, frame, regnum, 1);
/* Remove the possible \n. */
- std::string &str = stream.string ();
+ std::string str = stream.release ();
if (!str.empty () && str.back () == '\n')
str.resize (str.size () - 1);
string.puts (pc_buf);
}
+ std::string string_val = string.release ();
+
if (string.size () < status_size)
- string.puts (n_spaces (status_size - string.size ()));
+ string_val.append (status_size - string.size (), ' ');
else if (string.size () > status_size)
- string.string ().erase (status_size, string.size ());
+ string_val.erase (status_size, string.size ());
- return std::move (string.string ());
+ return string_val;
}
/* Get a printable name for the function at the address. The symbol
string_file stb;
type_print (type, "", &stb, -1);
- return std::move (stb.string ());
+ return stb.release ();
}
catch (const gdb_exception &except)
{
/* string_file-specific public API. */
/* Accesses the std::string containing the entire output collected
- so far.
+ so far. */
+ const std::string &string () { return m_string; }
- Returns a non-const reference so that it's easy to move the
- string contents out of the string_file. E.g.:
+ /* Return an std::string containing the entire output collected so far.
- string_file buf;
- buf.printf (....);
- buf.printf (....);
- return std::move (buf.string ());
- */
- std::string &string () { return m_string; }
+ The internal buffer is cleared, such that it's ready to build a new
+ string. */
+ std::string release ()
+ {
+ std::string ret = std::move (m_string);
+ m_string.clear ();
+ return ret;
+ }
/* Provide a few convenience methods with the same API as the
underlying std::string. */
/* Print the message. */
string_file sfile;
cli_ui_out (&sfile, 0).vmessage (ui_file_style (), format, args);
- std::string linebuffer = std::move (sfile.string ());
+ const std::string &linebuffer = sfile.string ();
fputs_unfiltered (linebuffer.c_str (), stream);
size_t len = linebuffer.length ();
/* All other cases. */
common_val_print (value, &stb, 0, &opts, current_language);
- return std::move (stb.string ());
+ return stb.release ();
}
bool