Add API for getting the class of tag type directly
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 28 Jan 2009 11:17:17 +0000 (13:17 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 28 Jan 2009 11:17:17 +0000 (13:17 +0200)
- no point requiring going through rpmTagGetType() if we already have
  the type at hand, and in some nutty cases (wrt extensions) these dont
  even always  match
- rpmTagGetClass() is now just a convenience wrapper around
  rpmTagTypeGetClass()

lib/rpmtag.h
lib/tagname.c

index 335d413..dd64c2d 100644 (file)
@@ -398,6 +398,13 @@ rpmTagClass rpmTagGetClass(rpmTag tag);
 rpmTag rpmTagGetValue(const char * tagstr);
 
 /** \ingroup rpmtag
+ * Return data class of type
+ * @param tag          tag type
+ * @return             data class, RPM_NULL_CLASS on unknown.
+ */
+rpmTagClass rpmTagTypeGetClass(rpmTagType type);
+
+/** \ingroup rpmtag
  * Return known rpm tag names, sorted by name.
  * @retval tagnames    tag container of string array type
  * @param fullname     return short or full name
index a81424d..cdc5ad6 100644 (file)
@@ -294,10 +294,10 @@ rpmTagType rpmTagGetType(rpmTag tag)
     return ((*rpmTags->tagType)(tag));
 }
 
-rpmTagClass rpmTagGetClass(rpmTag tag)
+rpmTagClass rpmTagTypeGetClass(rpmTagType type)
 {
     rpmTagClass class;
-    switch (rpmTagGetType(tag) & RPM_MASK_TYPE) {
+    switch (type & RPM_MASK_TYPE) {
     case RPM_CHAR_TYPE:
     case RPM_INT8_TYPE:
     case RPM_INT16_TYPE:
@@ -321,6 +321,11 @@ rpmTagClass rpmTagGetClass(rpmTag tag)
     return class;
 }
 
+rpmTagClass rpmTagGetClass(rpmTag tag)
+{
+    return rpmTagTypeGetClass(rpmTagGetType(tag));
+}
+
 rpmTag rpmTagGetValue(const char * tagstr)
 {
     return ((*rpmTags->tagValue)(tagstr));