rotate gdb/ChangeLog
[deliverable/binutils-gdb.git] / gdb / common / format.h
index f3a94b8bbb6c06b2000fe622b90936c881b2578a..7b053f1e624e7ffcec5195f4488e83e7119ca3b4 100644 (file)
@@ -1,6 +1,6 @@
 /* Parse a printf-style format string.
 
-   Copyright (C) 1986-2017 Free Software Foundation, Inc.
+   Copyright (C) 1986-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,6 +20,8 @@
 #ifndef COMMON_FORMAT_H
 #define COMMON_FORMAT_H
 
+#include "common/gdb_string_view.h"
+
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
 # define USE_PRINTF_I64 1
 # define PRINTF_HAS_LONG_LONG
@@ -48,22 +50,47 @@ enum argclass
 
 struct format_piece
 {
-  char *string;
+  format_piece (const char *str, enum argclass argc)
+    : string (str),
+      argclass (argc)
+  {
+  }
+
+  bool operator== (const format_piece &other) const
+  {
+    return (this->argclass == other.argclass
+           && gdb::string_view (this->string) == other.string);
+  }
+
+  const char *string;
   enum argclass argclass;
 };
 
-/* Return an array of printf fragments found at the given string, and
-   rewrite ARG with a pointer to the end of the format string.  */
+class format_pieces
+{
+public:
 
-extern struct format_piece *parse_format_string (const char **arg);
+  format_pieces (const char **arg);
+  ~format_pieces () = default;
 
-/* Given a pointer to an array of format pieces, free any memory that
-   would have been allocated by parse_format_string.  */
+  DISABLE_COPY_AND_ASSIGN (format_pieces);
 
-extern void free_format_pieces (struct format_piece *frags);
+  typedef std::vector<format_piece>::iterator iterator;
 
-/* Freeing, cast as a cleanup.  */
+  iterator begin ()
+  {
+    return m_pieces.begin ();
+  }
+
+  iterator end ()
+  {
+    return m_pieces.end ();
+  }
 
-extern void free_format_pieces_cleanup (void *);
+private:
+
+  std::vector<format_piece> m_pieces;
+  gdb::unique_xmalloc_ptr<char> m_storage;
+};
 
 #endif /* COMMON_FORMAT_H */
This page took 0.025375 seconds and 4 git commands to generate.