From: Kern Sibbald Date: Mon, 2 Jan 2012 16:57:45 +0000 (+0100) Subject: Enhance sellist to allow rescanning the list X-Git-Tag: Release-7.0.0~387 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e8bd4575d652c85b9633e7e851f3c5faf5d61de7;p=bacula%2Fbacula Enhance sellist to allow rescanning the list --- diff --git a/bacula/src/lib/sellist.h b/bacula/src/lib/sellist.h index 99365bdda8..8b98bd23f0 100644 --- a/bacula/src/lib/sellist.h +++ b/bacula/src/lib/sellist.h @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2011-2011 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -54,8 +54,12 @@ public: bool set_string(char *string, bool scan); int64_t first(); int64_t next(); - int size() const; - char *get_errmsg(); + void begin(); + /* size() valid only if scan enabled on string */ + int size() const { return num_items; }; + char *get_list() { return str; }; + /* if errmsg == NULL, no error */ + char *get_errmsg() { return errmsg; }; }; /* @@ -81,31 +85,24 @@ inline sellist::~sellist() } /* - * Return list size, but only if scan enabled on string - */ -inline int sellist::size() const -{ - return num_items; -} - -/* - * Return error message or NULL if none + * Returns first item + * error if returns -1 and errmsg set + * end of items if returns -1 and errmsg NULL */ -inline char *sellist::get_errmsg() +inline int64_t sellist::first() { - return errmsg; + begin(); + return next(); } /* - * Returns first item - * error if returns -1 and errmsg set - * end of items if returns -1 and errmsg NULL + * Reset to walk list from beginning */ -inline int64_t sellist::first() +inline void sellist::begin() { e = str; end = 0; beg = 1; errmsg = NULL; - return next(); } +