void
mi_parse::parse_argv ()
{
- const char *chp = m_args.get ();
+ const char *chp = m_args.c_str ();
int argc = 0;
char **argv = XNEWVEC (char *, argc + 1);
}
std::unique_ptr<struct mi_parse>
-mi_parse (const char *cmd, char **token)
+mi_parse::make (const char *cmd, char **token)
{
const char *chp;
}
/* Save the rest of the arguments for the command. */
- parse->set_args (chp);
+ parse->m_args = chp;
/* Fully parsed, flag as an MI command. */
parse->op = MI_COMMAND;
struct mi_parse
{
- mi_parse () = default;
+ /* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is
+ invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS
+ and OP are initialized. Un-initialized fields are zero. *TOKEN is
+ set to the token, even if an exception is thrown. It is allocated
+ with xmalloc; it must either be freed with xfree, or assigned to
+ the TOKEN field of the resultant mi_parse object, to be freed by
+ mi_parse_free. */
+
+ static std::unique_ptr<struct mi_parse> make (const char *cmd,
+ char **token);
+
~mi_parse ();
DISABLE_COPY_AND_ASSIGN (mi_parse);
const char *args () const
{ return m_args.c_str (); }
- void set_args (const char *args)
- { m_args = args; }
-
enum mi_command_type op = MI_COMMAND;
char *command = nullptr;
char *token = nullptr;
private:
+ mi_parse () = default;
+
std::string m_args;
};
-/* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is
- invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS
- and OP are initialized. Un-initialized fields are zero. *TOKEN is
- set to the token, even if an exception is thrown. It is allocated
- with xmalloc; it must either be freed with xfree, or assigned to
- the TOKEN field of the resultant mi_parse object, to be freed by
- mi_parse_free. */
-
-extern std::unique_ptr<struct mi_parse> mi_parse (const char *cmd,
- char **token);
-
/* Parse a string argument into a print_values value. */
enum print_values mi_parse_print_values (const char *name);