Delete parse_flags/parse_flags_qcs
[deliverable/binutils-gdb.git] / gdb / cli / cli-utils.h
index 0c25a7e21e6bb43a4831bf95c0ad5f1389e4a5d6..c2a0f374a6e0d3d30327298a41c956fc7c2ba8b2 100644 (file)
@@ -1,6 +1,6 @@
 /* CLI utilities.
 
-   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,8 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef CLI_UTILS_H
-#define CLI_UTILS_H
+#ifndef CLI_CLI_UTILS_H
+#define CLI_CLI_UTILS_H
 
 /* *PP is a string denoting a number.  Get the number.  Advance *PP
    after the string and any trailing whitespace.
@@ -39,6 +39,40 @@ extern int get_number (const char **);
 
 extern int get_number (char **);
 
+/* Like get_number_trailer, but works with ULONGEST, and throws on
+   error instead of returning 0.  */
+extern ULONGEST get_ulongest (const char **pp, int trailer = '\0');
+
+/* Extract from ARGS the arguments [-q] [-t TYPEREGEXP] [--] NAMEREGEXP.
+
+   The caller is responsible to initialize *QUIET to false, *REGEXP
+   and *T_REGEXP to "".
+   extract_info_print_args can then be called iteratively to search
+   for valid arguments, as part of a 'main parsing loop' searching for
+   -q/-t/-- arguments together with other flags and options.
+
+   Returns true and updates *ARGS + one of *QUIET, *REGEXP, *T_REGEXP if
+   it finds a valid argument.
+   Returns false if no valid argument is found at the beginning of ARGS.  */
+
+extern bool extract_info_print_args (const char **args,
+                                    bool *quiet,
+                                    std::string *regexp,
+                                    std::string *t_regexp);
+
+/* Throws an error telling the user that ARGS starts with an option
+   unrecognized by COMMAND.  */
+
+extern void report_unrecognized_option_error (const char *command,
+                                             const char *args);
+
+
+/* Builds the help string for a command documented by PREFIX,
+   followed by the extract_info_print_args help for ENTITY_KIND.  */
+
+const char *info_print_args_help (const char *prefix,
+                                 const char *entity_kind);
+
 /* Parse a number or a range.
    A number will be of the form handled by get_number.
    A range will be of the form <number1> - <number2>, and
@@ -75,8 +109,7 @@ public:
                    const char *end_ptr);
 
   /* Returns true if parsing has completed.  */
-  bool finished () const
-  { return m_finished; }
+  bool finished () const;
 
   /* Return the string being parsed.  When parsing has finished, this
      points past the last parsed token.  */
@@ -96,6 +129,7 @@ public:
   {
     gdb_assert (m_in_range);
     m_cur_tok = m_end_ptr;
+    m_in_range = false;
   }
 
 private:
@@ -103,9 +137,6 @@ private:
   number_or_range_parser (const number_or_range_parser &);
   number_or_range_parser &operator= (const number_or_range_parser &);
 
-  /* True if parsing has completed.  */
-  bool m_finished;
-
   /* The string being parsed.  When parsing has finished, this points
      past the last parsed token.  */
   const char *m_cur_tok;
@@ -149,24 +180,31 @@ remove_trailing_whitespace (const char *start, char *s)
 }
 
 /* A helper function to extract an argument from *ARG.  An argument is
-   delimited by whitespace.  The return value is either NULL if no
-   argument was found, or an xmalloc'd string.  */
-
-extern char *extract_arg (char **arg);
+   delimited by whitespace.  The return value is empty if no argument
+   was found.  */
 
-/* A const-correct version of the above.
+extern std::string extract_arg (char **arg);
 
-   Since the returned value is xmalloc'd, it eventually needs to be
-   xfree'ed, which prevents us from making it const as well.  */
+/* A const-correct version of the above.  */
 
-extern char *extract_arg (const char **arg);
+extern std::string extract_arg (const char **arg);
 
 /* A helper function that looks for an argument at the start of a
    string.  The argument must also either be at the end of the string,
    or be followed by whitespace.  Returns 1 if it finds the argument,
-   0 otherwise.  If the argument is found, it updates *STR.  */
+   0 otherwise.  If the argument is found, it updates *STR to point
+   past the argument and past any whitespace following the
+   argument.  */
 extern int check_for_argument (const char **str, const char *arg, int arg_len);
 
+/* Same as above, but ARG's length is computed.  */
+
+static inline int
+check_for_argument (const char **str, const char *arg)
+{
+  return check_for_argument (str, arg, strlen (arg));
+}
+
 /* Same, for non-const STR.  */
 
 static inline int
@@ -176,4 +214,25 @@ check_for_argument (char **str, const char *arg, int arg_len)
                             arg, arg_len);
 }
 
-#endif /* CLI_UTILS_H */
+static inline int
+check_for_argument (char **str, const char *arg)
+{
+  return check_for_argument (str, arg, strlen (arg));
+}
+
+/* qcs_flags struct groups the -q, -c, and -s flags parsed by "thread
+   apply" and "frame apply" commands */
+
+struct qcs_flags
+{
+  int quiet = false;
+  int cont = false;
+  int silent = false;
+};
+
+/* Validate FLAGS.  Throws an error if both FLAGS->CONT and
+   FLAGS->SILENT are true.  WHICH_COMMAND is included in the error
+   message.  */
+extern void validate_flags_qcs (const char *which_command, qcs_flags *flags);
+
+#endif /* CLI_CLI_UTILS_H */
This page took 0.02634 seconds and 4 git commands to generate.