]> mj.ucw.cz Git - libucw.git/commitdiff
Extended types: Moved unit tables to a more logical place in the header
authorMartin Mares <mj@ucw.cz>
Fri, 25 Jul 2014 11:11:16 +0000 (13:11 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 25 Jul 2014 11:11:16 +0000 (13:11 +0200)
ucw/xtypes.h

index 3bf9656831f8c4a939c77716bfe0db2fec5ad0b3..f0e892771a44e0df012798ceea46315a15236798 100644 (file)
@@ -74,23 +74,6 @@ typedef const char * (*xtype_fmt_parser)(const char *str, u32 *dest, struct memp
  **/
 typedef const char * (*xtype_fmt_formatter)(u32 fmt, struct mempool *pool);
 
-/**
- * Definition of the units that are appended to an xtype value. The value with units is represented
- * by the following string: "<value><units>". The final value of the of the string is computed using
- * the following formula: <value> * <num>/<denom>.
- **/
-struct unit_definition {
-  const char *unit; // string representation of unit
-  u64 num;
-  u64 denom;
-};
-
-/**
- * Parse a name of a unit and return its index in the @units array or -1
- * if is not present there.
- **/
-int xtype_unit_parser(const char *str, struct unit_definition *units);
-
 /**
  * This structure describes an xtype. Among other things, it points to callback
  * functions handling this xtype.
@@ -134,4 +117,23 @@ extern const struct xtype xt_double;
 #define XTYPE_FMT_DBL_FIXED_PREC(_prec) (_prec | XTYPE_FMT_DBL_PREC)
 #define XTYPE_FMT_DBL_PREC XTYPE_FMT_CUSTOM
 
+/* Tables of units, provided as convenience for the implementations of xtypes */
+
+/**
+ * Definition of the units that are appended to an xtype value. The value with units is represented
+ * by the following string: "<value><units>". The final value of the of the string is computed using
+ * the following formula: <value> * <num>/<denom>.
+ **/
+struct unit_definition {
+  const char *unit; // string representation of unit
+  u64 num;
+  u64 denom;
+};
+
+/**
+ * Parse a name of a unit and return its index in the @units array or -1
+ * if is not present there.
+ **/
+int xtype_unit_parser(const char *str, struct unit_definition *units);
+
 #endif