]> O.S.I.I.S - jp/vkvg.git/commitdiff
Add vkvg_status_to_string (#99)
authorMarco Rubin <20150305+Rubo3@users.noreply.github.com>
Fri, 4 Mar 2022 08:44:51 +0000 (09:44 +0100)
committerGitHub <noreply@github.com>
Fri, 4 Mar 2022 08:44:51 +0000 (09:44 +0100)
* Add vkvg_status_to_string definition
* Remove unused status

include/vkvg.h
src/vkvg_context.c

index c38b59f98450ea5f72e82eebac3597ddede20fe3..a629ffffbadf44553c8b6629153158df75e882e5 100644 (file)
@@ -125,17 +125,10 @@ typedef enum {
        VKVG_STATUS_INVALID_STATUS,                     /*!< */
        VKVG_STATUS_INVALID_INDEX,                      /*!< */
        VKVG_STATUS_NULL_POINTER,                       /*!< NULL pointer*/
-       VKVG_STATUS_INVALID_STRING,                     /*!< */
-       VKVG_STATUS_INVALID_PATH_DATA,          /*!< */
-       VKVG_STATUS_READ_ERROR,                         /*!< */
        VKVG_STATUS_WRITE_ERROR,                        /*!< */
-       VKVG_STATUS_SURFACE_FINISHED,           /*!< */
-       VKVG_STATUS_SURFACE_TYPE_MISMATCH,      /*!< */
        VKVG_STATUS_PATTERN_TYPE_MISMATCH,      /*!< */
        VKVG_STATUS_PATTERN_INVALID_GRADIENT,/*!< occurs when stops count is zero */
-       VKVG_STATUS_INVALID_CONTENT,            /*!< */
        VKVG_STATUS_INVALID_FORMAT,                     /*!< */
-       VKVG_STATUS_INVALID_VISUAL,                     /*!< */
        VKVG_STATUS_FILE_NOT_FOUND,                     /*!< */
        VKVG_STATUS_INVALID_DASH,                       /*!< invalid value for a dash setting */
        VKVG_STATUS_INVALID_RECT,                       /*!< rectangle with height or width equal to 0. */
@@ -893,6 +886,16 @@ void vkvg_destroy (VkvgContext ctx);
  */
 vkvg_public
 vkvg_status_t vkvg_status (VkvgContext ctx);
+/**
+ * vkvg_status_to_string:
+ * @status: a vkvg status
+ *
+ * Provides a human-readable description of a #vkvg_status_t.
+ *
+ * Returns: a string representation of the status
+ **/
+vkvg_public
+const char *vkvg_status_to_string (vkvg_status_t status);
 /**
  * @brief Increment by one the reference count on this context.
  * @param ctx The context to increment the reference count for.
index 6e5d125fe440baa6ac58cc3bb6bf37b90870eca2..d9bce6a35b59382d2a99551025bca419d5514955 100644 (file)
@@ -1610,3 +1610,59 @@ VkvgSurface vkvg_get_target (VkvgContext ctx) {
                return NULL;
        return ctx->pSurf;
 }
+
+/**
+ * vkvg_status_to_string:
+ * @status: a vkvg status
+ *
+ * Provides a human-readable description of a #vkvg_status_t.
+ *
+ * Returns: a string representation of the status
+ **/
+const char *
+vkvg_status_to_string (vkvg_status_t status) {
+       switch (status) {
+       case VKVG_STATUS_SUCCESS:
+               return "no error has occurred";
+       case VKVG_STATUS_NO_MEMORY:
+               return "out of memory";
+       case VKVG_STATUS_INVALID_RESTORE:
+               return "vkvg_restore() without matching vkvg_save()";
+       case VKVG_STATUS_NO_CURRENT_POINT:
+               return "no current point defined";
+       case VKVG_STATUS_INVALID_MATRIX:
+               return "invalid matrix (not invertible)";
+       case VKVG_STATUS_INVALID_STATUS:
+               return "invalid value for an input vkvg_status_t";
+       case VKVG_STATUS_INVALID_INDEX:
+               return "invalid index passed to getter";
+       case VKVG_STATUS_NULL_POINTER:
+               return "NULL pointer";
+       case VKVG_STATUS_WRITE_ERROR:
+               return "error while writing to output stream";
+       case VKVG_STATUS_PATTERN_TYPE_MISMATCH:
+               return "the pattern type is not appropriate for the operation";
+       case VKVG_STATUS_PATTERN_INVALID_GRADIENT:
+               return "the stops count is zero";
+       case VKVG_STATUS_INVALID_FORMAT:
+               return "invalid value for an input vkvg_format_t";
+       case VKVG_STATUS_FILE_NOT_FOUND:
+               return "file not found";
+       case VKVG_STATUS_INVALID_DASH:
+               return "invalid value for a dash setting";
+       case VKVG_STATUS_INVALID_RECT:
+               return "a rectangle has the height or width equal to 0";
+       case VKVG_STATUS_TIMEOUT:
+               return "waiting for a Vulkan operation to finish resulted in a fence timeout (5 seconds)";
+       case VKVG_STATUS_DEVICE_ERROR:
+               return "the initialization of the device resulted in an error";
+       case VKVG_STATUS_INVALID_IMAGE:
+               return "invalid image";
+       case VKVG_STATUS_INVALID_SURFACE:
+               return "invalid surface";
+       case VKVG_STATUS_INVALID_FONT:
+               return "unresolved font name";
+       default:
+               return "<unknown error status>";
+       }
+}