Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=cc1a6b245cb9c77a35f084a7624b7d6712c2a3ff

commit cc1a6b245cb9c77a35f084a7624b7d6712c2a3ff
Author: Michel Hermier <[email protected]>
Date:   Thu May 1 14:40:17 2014 +0200

libpacman: Add package_properties.h to automate generations of package 
properties.

diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp
index 48d927a..c291334 100644
--- a/lib/libpacman/package.cpp
+++ b/lib/libpacman/package.cpp
@@ -517,30 +517,15 @@ char *Package::fileneedbackup(const char *file) const
return(NULL);
}

-const char *Package::name()
-{
-       return getinfo(PM_PKG_NAME);
-}
-
-const char *Package::version()
-{
-       return getinfo(PM_PKG_VERSION);
+#define LIBPACMAN_PACKAGE_PROPERTY(type, name, flag)                           
\
+type Package::name()                                                           
\
+{                                                                              
\
+       return getinfo(PM_PKG_##flag);                                          
     \
}

-FStringList *Package::conflicts()
-{
-       return getinfo(PM_PKG_CONFLICTS);
-}
+#include "package_properties.h"

-FStringList *Package::requiredby()
-{
-       return getinfo(PM_PKG_REQUIREDBY);
-}
-
-FStringList *Package::provides()
-{
-       return getinfo(PM_PKG_PROVIDES);
-}
+#undef LIBPACMAN_PACKAGE_PROPERTY

FStringList *Package::provides() const
{
diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h
index 7518f0b..c6d6415 100644
--- a/lib/libpacman/package.h
+++ b/lib/libpacman/package.h
@@ -90,6 +90,14 @@ namespace libpacman {
class Package
: public libpacman::Object
{
+#define LIBPACMAN_PACKAGE_PROPERTY(type, name, flag)                           
\
+public:                                                                        
\
+       type name();
+
+#include "package_properties.h"
+
+#undef LIBPACMAN_PACKAGE_PROPERTY
+
public:
Package(libpacman::Database *database = 0);
Package(const char *name, const char *version);
@@ -110,17 +118,9 @@ public:
bool set_filename(const char *filename, int witharch);
static bool splitname(const char *target, char *name, char *version, int 
witharch);

-       const char *name();
-       const char *version();
-
-       FStringList *conflicts();
-
-       FStringList *provides();
FStringList *provides() const;
bool provides(const char *pkgname);

-       FStringList *requiredby();
-
libpacman::Database *database;

unsigned int flags;
diff --git a/lib/libpacman/package_properties.h 
b/lib/libpacman/package_properties.h
new file mode 100644
index 0000000..b910c06
--- /dev/null
+++ b/lib/libpacman/package_properties.h
@@ -0,0 +1,27 @@
+/*
+ *  package_properties.h
+ *
+ *  Copyright (c) 2014 by Michel Hermier <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ */
+
+LIBPACMAN_PACKAGE_PROPERTY(FStringList *, conflicts,  CONFLICTS )
+LIBPACMAN_PACKAGE_PROPERTY(const char *,  name,       NAME      )
+LIBPACMAN_PACKAGE_PROPERTY(FStringList *, provides,   PROVIDES  )
+LIBPACMAN_PACKAGE_PROPERTY(FStringList *, requiredby, REQUIREDBY)
+LIBPACMAN_PACKAGE_PROPERTY(const char *,  version,    VERSION   )
+
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to