*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
*/
#include <libtu/minmax.h>
}
-struct szplcy_spec {
- const char *spec;
- int szplcy;
-};
-
-
/* translation table for sizepolicy specifications */
-static struct szplcy_spec szplcy_specs[] = {
+static StringIntMap szplcy_specs[] = {
{"default", SIZEPOLICY_DEFAULT},
{"full", SIZEPOLICY_FULL_EXACT},
{"full_bounds", SIZEPOLICY_FULL_BOUNDS},
bool string2sizepolicy(const char *szplcy, WSizePolicy *value)
{
- const struct szplcy_spec *sp;
+ int tmp;
- *value=SIZEPOLICY_DEFAULT;
-
- for(sp=szplcy_specs; sp->spec; ++sp){
- if(strcasecmp(szplcy,sp->spec)==0){
- *value=sp->szplcy;
- return TRUE;
- }
- }
+ tmp=stringintmap_value(szplcy_specs, szplcy, -1);
- return FALSE;
+ if(tmp==-1){
+ *value=SIZEPOLICY_DEFAULT;
+ return FALSE;
+ }else{
+ *value=tmp;
+ return TRUE;
+ }
}
+
+const char *sizepolicy2string(WSizePolicy szplcy)
+{
+ return stringintmap_key(szplcy_specs, szplcy, NULL);
+}