aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/format.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common/format.h')
-rw-r--r--gdb/common/format.h42
1 files changed, 33 insertions, 9 deletions
diff --git a/gdb/common/format.h b/gdb/common/format.h
index f3a94b8..dd083f9 100644
--- a/gdb/common/format.h
+++ b/gdb/common/format.h
@@ -48,22 +48,46 @@ enum argclass
struct format_piece
{
- char *string;
+ format_piece (const char *str, enum argclass argc)
+ : string (str),
+ argclass (argc)
+ {
+ }
+
+ 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:
+
+ format_pieces (const char **arg);
+ ~format_pieces () = default;
+
+ DISABLE_COPY_AND_ASSIGN (format_pieces);
-extern struct format_piece *parse_format_string (const char **arg);
+ format_piece &operator[] (size_t index)
+ {
+ return m_pieces[index];
+ }
-/* Given a pointer to an array of format pieces, free any memory that
- would have been allocated by parse_format_string. */
+ typedef std::vector<format_piece>::iterator iterator;
-extern void free_format_pieces (struct format_piece *frags);
+ iterator begin ()
+ {
+ return m_pieces.begin ();
+ }
-/* Freeing, cast as a cleanup. */
+ 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 */