Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=cfpm.git;a=commitdiff;h=6c8bc64fe41e2002c2a0d00cb4a6ba72027cd17a

commit 6c8bc64fe41e2002c2a0d00cb4a6ba72027cd17a
Author: Priyank <priy...@frugalware.org>
Date:   Sat Jun 6 12:51:51 2009 +0530

new class: List

* Initial draft

diff --git a/pm.cc b/pm.cc
index eee9035..d80630f 100644
--- a/pm.cc
+++ b/pm.cc
@@ -31,6 +31,7 @@ using PM::Shared;
using PM::Database;
using PM::Package;
using PM::Group;
+using PM::List;

bool PM::initialize(const string &root)
{
@@ -311,3 +312,69 @@ string Group::getName()
return ret;
}

+List::List()
+{
+       list = NULL;
+}
+
+List::List(PM_LIST *l)
+{
+       List();
+       list = l;
+}
+
+List::~List()
+{
+       free();
+}
+
+int List::count()
+{
+       return pacman_list_count(list);
+}
+
+List* List::getFirst()
+{
+       List *ret = NULL;
+
+       if ( list )
+       {
+               PM_LIST *l = pacman_list_first(list);
+               if (l)
+               {
+                       ret = new List(l);
+               }
+       }
+       return ret;
+}
+
+List* List::getNext()
+{
+       List *ret = NULL;
+
+       if ( list )
+       {
+               PM_LIST *l = pacman_list_next(list);
+               if (l)
+               {
+                       ret = new List(l);
+               }
+       }
+       return ret;
+}
+
+void* List::getData()
+{
+       void *ret = NULL;
+
+       if ( list )
+       {
+               ret = pacman_list_getdata(list);
+       }
+       return ret;
+}
+
+void List::free()
+{
+       pacman_list_free(list);
+}
diff --git a/pm.hh b/pm.hh
index 218fc43..50b7a4e 100644
--- a/pm.hh
+++ b/pm.hh
@@ -81,5 +81,20 @@ namespace PM
void* getInfo(unsigned char param);
std::string getName();
};
+
+       class List
+       {
+               PM_LIST *list;
+
+               public:
+                       List();
+                       List(PM_LIST *list);
+                       ~List();
+                       int count();
+                       List *getFirst();
+                       List *getNext();
+                       void *getData();
+                       void free();
+       };
}
#endif
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to