summaryrefslogtreecommitdiffstats
path: root/cssprops.h
diff options
context:
space:
mode:
Diffstat (limited to 'cssprops.h')
-rw-r--r--cssprops.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/cssprops.h b/cssprops.h
new file mode 100644
index 0000000..266d990
--- /dev/null
+++ b/cssprops.h
@@ -0,0 +1,81 @@
+/* Generated file, do not edit */
+
+#ifndef CSSPROPS_H
+#define CSSPROPS_H
+
+#include <string.h>
+
+typedef enum {
+ CSS_PROP_UNKNOWN,
+ CSS_PROP_COLOR,
+ CSS_PROP_DISPLAY,
+ CSS_PROP_FONT_FAMILY,
+ CSS_PROP_FONT_SIZE,
+ CSS_PROP_FONT_WEIGHT,
+ CSS_PROP_LINE_HEIGHT,
+ CSS_PROP_LIST_STYLE_TYPE,
+ CSS_PROP_MARGIN,
+ CSS_PROP_PADDING_LEFT,
+ CSS_PROP_TEXT_DECORATION,
+} css_prop;
+
+static const struct {
+ const char *name;
+ css_prop prop;
+} css_prop_map[] = {
+ { "color", CSS_PROP_COLOR },
+ { "display", CSS_PROP_DISPLAY },
+ { "font-family", CSS_PROP_FONT_FAMILY },
+ { "font-size", CSS_PROP_FONT_SIZE },
+ { "font-weight", CSS_PROP_FONT_WEIGHT },
+ { "line-height", CSS_PROP_LINE_HEIGHT },
+ { "list-style-type", CSS_PROP_LIST_STYLE_TYPE },
+ { "margin", CSS_PROP_MARGIN },
+ { "padding-left", CSS_PROP_PADDING_LEFT },
+ { "text-decoration", CSS_PROP_TEXT_DECORATION },
+};
+
+static inline css_prop
+str_to_css_prop(const char *name, size_t len)
+{
+ int lo, hi, mid, cmp;
+
+ lo = 0;
+ hi = 10 - 1;
+
+ while (lo <= hi) {
+ mid = (lo + hi) / 2;
+ cmp = strncmp(name, css_prop_map[mid].name, len);
+ if (cmp == 0) {
+ if (css_prop_map[mid].name[len] == '\0')
+ return css_prop_map[mid].prop;
+ hi = mid - 1;
+ } else if (cmp < 0)
+ hi = mid - 1;
+ else
+ lo = mid + 1;
+ }
+
+ return CSS_PROP_UNKNOWN;
+}
+
+static inline const char *
+css_prop_to_str(css_prop prop)
+{
+ switch (prop) {
+ case CSS_PROP_UNKNOWN: return "unknown";
+ case CSS_PROP_COLOR: return "color";
+ case CSS_PROP_DISPLAY: return "display";
+ case CSS_PROP_FONT_FAMILY: return "font-family";
+ case CSS_PROP_FONT_SIZE: return "font-size";
+ case CSS_PROP_FONT_WEIGHT: return "font-weight";
+ case CSS_PROP_LINE_HEIGHT: return "line-height";
+ case CSS_PROP_LIST_STYLE_TYPE: return "list-style-type";
+ case CSS_PROP_MARGIN: return "margin";
+ case CSS_PROP_PADDING_LEFT: return "padding-left";
+ case CSS_PROP_TEXT_DECORATION: return "text-decoration";
+ default: return "unknown";
+ }
+}
+
+#endif /* CSSPROPS_H */