libsaria: Create iterator functions for the library
I use these to fill in the UI list for the library. I think this will be easier to use (and cleaner) than passing a function pointer to a for_each loop.
This commit is contained in:
parent
0fa608c90f
commit
2fd41ff4d7
|
@ -12,6 +12,14 @@ namespace libsaria
|
|||
{
|
||||
namespace library
|
||||
{
|
||||
|
||||
namespace iter
|
||||
{
|
||||
void reset();
|
||||
libsaria::Track *next();
|
||||
bool end();
|
||||
} /* Namespace: iter */
|
||||
|
||||
struct PathInfo {
|
||||
string path;
|
||||
unsigned int size;
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/library.h>
|
||||
#include "list.h"
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
list<libsaria::Track *>::iterator it;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
namespace library
|
||||
{
|
||||
|
||||
void iter::reset()
|
||||
{
|
||||
it = track_list.begin();
|
||||
}
|
||||
|
||||
libsaria::Track *iter::next()
|
||||
{
|
||||
libsaria::Track *track = *it;
|
||||
it++;
|
||||
return track;
|
||||
}
|
||||
|
||||
bool iter::end()
|
||||
{
|
||||
return it == track_list.end();
|
||||
}
|
||||
|
||||
} /* Namespace: library */
|
||||
}; /* Namespace: libsaria */
|
|
@ -6,7 +6,7 @@
|
|||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
static list<libsaria::Track *> track_list;
|
||||
list<libsaria::Track *> track_list;
|
||||
|
||||
static bool compare_tracks(libsaria::Track *one, libsaria::Track *two)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#ifndef LIBSARIA_LIBRARY_LIST_H
|
||||
#define LIBSARIA_LIBRARY_LIST_H
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
extern list<libsaria::Track *> track_list;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
namespace library
|
||||
|
|
Loading…
Reference in New Issue