]> git.sur5r.net Git - bacula/bacula/commitdiff
Enhance sellist to allow rescanning the list
authorKern Sibbald <kern@sibbald.com>
Mon, 2 Jan 2012 16:57:45 +0000 (17:57 +0100)
committerKern Sibbald <kern@sibbald.com>
Mon, 2 Jan 2012 16:57:45 +0000 (17:57 +0100)
bacula/src/lib/sellist.h

index 99365bdda8edd25842813c5b8455d1e175c856f4..8b98bd23f0062e07fb038c03ca23861dd830ad0d 100644 (file)
@@ -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();
 }
+