Enlightenment CVS committal

Author  : xcomputerman
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_config


Modified Files:
        Ecore_Config.h convenience.c ecore_config.c 


Log Message:
Add boolean type. It's essentially the same as an INT, but at least we have a boolean 
property API, and the ability to store bools if the backend supports it (which edb 
doesn't).

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/Ecore_Config.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -3 -r1.36 -r1.37
--- Ecore_Config.h      15 Sep 2004 05:44:24 -0000      1.36
+++ Ecore_Config.h      23 Sep 2004 01:56:09 -0000      1.37
@@ -119,6 +119,7 @@
 
    Ecore_Config_Prop  *ecore_config_get(const char *key);
    const char         *ecore_config_type_get(const Ecore_Config_Prop * e);
+   int                ecore_config_boolean_get(const char *key);
    void               *ecore_config_data_get(const char *key);
    char               *ecore_config_string_get(const char *key);
    long                ecore_config_int_get(const char *key);
@@ -139,6 +140,7 @@
    int                 ecore_config_set(const char *key, char *val);
    int                 ecore_config_typed_set(const char *key, void *val,
                                              int type);
+   int                 ecore_config_boolean_set(const char *key, int val);
    int                 ecore_config_string_set(const char *key, char *val);
    int                 ecore_config_int_set(const char *key, int val);
    int                 ecore_config_rgb_set(const char *key, char *val);
@@ -153,6 +155,7 @@
                                            float lo, float hi, float step);
    int                 ecore_config_typed_default(const char *key, void *val,
                                                  int type);
+   int                 ecore_config_boolean_default(const char *key, int val);
    int                 ecore_config_int_default(const char *key, int val);
    int                 ecore_config_int_default_bound(const char *key, int val,
                                                      int lo, int hi, int step);
@@ -236,6 +239,9 @@
    int                 ecore_config_typed_create(const char *key, void *val,
                                                 int type, char short_opt,
                                                 char *long_opt, char *desc);
+   int                 ecore_config_boolean_create(const char *key, int val,
+                      char short_opt, char *long_opt,
+                      char *desc);
    int                 ecore_config_int_create(const char *key, int val,
                                               char short_opt, char *long_opt,
                                               char *desc);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/convenience.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- convenience.c       30 Jul 2004 12:28:29 -0000      1.21
+++ convenience.c       23 Sep 2004 01:56:09 -0000      1.22
@@ -75,6 +75,27 @@
 }
 
 /**
+ * Creates a new boolean property, if it does not already exist, and sets its
+ * attributes to those given.
+ * @param   key       The property key.
+ * @param   val       Default boolean value of key.
+ * @param   short_opt Short option used to set the property from command
+ *                    line.
+ * @param   long_opt  Long option used to set the property from command line.
+ * @param   desc      String description of property.
+ * @return  @c ECORE_CONFIG_ERR_SUCC on success.
+ * @ingroup Ecore_Config_Create_Group
+ */
+int
+ecore_config_boolean_create(const char *key, int val, char short_opt,
+                       char *long_opt, char *desc)
+{
+   return
+      ecore_config_typed_create(key, (void *)&val, PT_BLN, short_opt, long_opt,
+                               desc);
+}
+
+/**
  * Creates a new integer property, if it does not already exist, and sets its
  * attributes to those given.
  * @param   key       The property key.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -3 -r1.46 -r1.47
--- ecore_config.c      1 Sep 2004 20:55:23 -0000       1.46
+++ ecore_config.c      23 Sep 2004 01:56:09 -0000      1.47
@@ -28,7 +28,7 @@
 static int           _ecore_config_system_load(void);
 
 static char        *_ecore_config_type[] =
-   { "undefined", "integer", "float", "string", "colour", "theme" };
+   { "undefined", "integer", "float", "string", "colour", "theme", "boolean" };
 
 /**
  * @defgroup Ecore_Config_Property_Group Ecore Config Property Functions
@@ -172,6 +172,22 @@
 }
 
 /**
+ * Returns the specified property as an integer.
+ * @param   key The property key.
+ * @return  The value of the property.  The function returns -1 if the
+ *          property is not an integer or is not set.
+ * @ingroup Ecore_Config_Get_Group
+ */
+int
+ecore_config_boolean_get(const char *key)
+{
+   Ecore_Config_Prop  *e;
+
+   e = ecore_config_get(key);
+   return (e && ((e->type == PT_INT) || (e->type == PT_BLN))) ? (e->val != 0) : -1;
+}
+
+/**
  * Returns the specified property as a long integer.
  * @param   key The property key.
  * @return  The integer value of the property.  The function returns 0 if the
@@ -330,6 +346,9 @@
          case PT_INT:
             esprintf(&r, "%s:%s=%ld", key, type, ecore_config_int_get(key));
             break;
+     case PT_BLN:
+        esprintf(&r, "%s:%s=%ld", key, type, ecore_config_boolean_get(key));
+        break;
          case PT_FLT:
             esprintf(&r, "%s:%s=%lf", key, type, ecore_config_float_get(key));
             break;
@@ -468,6 +487,12 @@
             e->val = (long)*i;
             e->type = PT_INT;
          }
+   else if (type == PT_BLN )
+     {
+        i = (int *)val;
+        e->val = (long)*i;
+        e->type = PT_BLN;
+     }
        else if (type == PT_STR || type == PT_THM)
          {
             if (!(e->ptr = strdup(val)))
@@ -719,6 +744,20 @@
 }
 
 /**
+ * Sets the indicated property to the given boolean.
+ * @param   key The property key.
+ * @param   val Boolean integer to set the property to.
+ * @return  @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
+ * @ingroup Ecore_Config_Set_Group
+ */
+int
+ecore_config_boolean_set(const char *key, int val)
+{
+   val = val ? 1 : 0;
+   return ecore_config_typed_set(key, (void *)&val, PT_BLN);
+}
+
+/**
  * Sets the indicated property to the given integer.
  * @param   key The property key.
  * @param   val Integer to set the property to.
@@ -919,6 +958,21 @@
 }
 
 /**
+ * Sets the indicated property to the given boolean if the property has not yet
+ * been set.
+ * @param   key The property key.
+ * @param   val Boolean Integer to set the value to.
+ * @return  @c ECORE_CONFIG_ERR_SUCC if there are no problems.
+ * @ingroup Ecore_Config_Default_Group
+ */
+int
+ecore_config_boolean_default(const char *key, int val)
+{
+   val = val ? 1 : 0;
+   return ecore_config_typed_default(key, (void *)&val, PT_BLN);
+}
+
+/**
  * Sets the indicated property to the given integer if the property has not yet
  * been set.
  * @param   key The property key.




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to