LCOV - code coverage report
Current view: top level - shumate/vector - shumate-vector-value-private.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 3 3 100.0 %
Date: 2024-05-11 21:41:31 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 12 16.7 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2021 James Westman <james@jwestman.net>
       3                 :            :  *
       4                 :            :  * This library is free software; you can redistribute it and/or
       5                 :            :  * modify it under the terms of the GNU Lesser General Public
       6                 :            :  * License as published by the Free Software Foundation; either
       7                 :            :  * version 2.1 of the License, or (at your option) any later version.
       8                 :            :  *
       9                 :            :  * This library is distributed in the hope that it will be useful,
      10                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12                 :            :  * Lesser General Public License for more details.
      13                 :            :  *
      14                 :            :  * You should have received a copy of the GNU Lesser General Public
      15                 :            :  * License along with this library; if not, see <https://www.gnu.org/licenses/>.
      16                 :            :  */
      17                 :            : 
      18                 :            : #pragma once
      19                 :            : 
      20                 :            : #include <json-glib/json-glib.h>
      21                 :            : #include <gtk/gtk.h>
      22                 :            : #include "../shumate-vector-sprite.h"
      23                 :            : #include "vector_tile.pb-c.h"
      24                 :            : 
      25                 :            : #define SHUMATE_VECTOR_COLOR_BLACK ((GdkRGBA) {.red=0, .green=0, .blue=0, .alpha=1})
      26                 :            : 
      27                 :            : typedef enum {
      28                 :            :   SHUMATE_VECTOR_VALUE_TYPE_NULL,
      29                 :            :   SHUMATE_VECTOR_VALUE_TYPE_NUMBER,
      30                 :            :   SHUMATE_VECTOR_VALUE_TYPE_BOOLEAN,
      31                 :            :   SHUMATE_VECTOR_VALUE_TYPE_STRING,
      32                 :            :   SHUMATE_VECTOR_VALUE_TYPE_COLOR,
      33                 :            :   SHUMATE_VECTOR_VALUE_TYPE_ARRAY,
      34                 :            :   SHUMATE_VECTOR_VALUE_TYPE_RESOLVED_IMAGE,
      35                 :            :   SHUMATE_VECTOR_VALUE_TYPE_FORMATTED_STRING,
      36                 :            :   SHUMATE_VECTOR_VALUE_TYPE_COLLATOR,
      37                 :            : } ShumateVectorValueType;
      38                 :            : 
      39                 :            : typedef struct {
      40                 :            :   GdkRGBA text_color;
      41                 :            :   char *string;
      42                 :            :   ShumateVectorSprite *sprite;
      43                 :            :   double font_scale;
      44                 :            :   gboolean has_text_color : 1;
      45                 :            :   gboolean has_font_scale : 1;
      46                 :            : } ShumateVectorFormatPart;
      47                 :            : 
      48                 :            : typedef struct {
      49                 :            :   guint8 case_sensitive : 1;
      50                 :            : } ShumateVectorCollator;
      51                 :            : 
      52                 :            : typedef struct {
      53                 :            :   ShumateVectorValueType type;
      54                 :            : 
      55                 :            :   union {
      56                 :            :     double number;
      57                 :            :     gboolean boolean;
      58                 :            :     struct {
      59                 :            :       char *string;
      60                 :            :       GdkRGBA color;
      61                 :            :       int color_state;
      62                 :            :     };
      63                 :            :     GPtrArray *array;
      64                 :            :     struct {
      65                 :            :       ShumateVectorSprite *image;
      66                 :            :       char *image_name;
      67                 :            :     };
      68                 :            :     GPtrArray *formatted_string;
      69                 :            :     ShumateVectorCollator collator;
      70                 :            :   };
      71                 :            : } ShumateVectorValue;
      72                 :            : 
      73                 :            : #define SHUMATE_VECTOR_VALUE_INIT ((ShumateVectorValue) {.type = 0})
      74                 :            : 
      75                 :            : gboolean shumate_vector_value_set_from_json_literal (ShumateVectorValue *self, JsonNode *node, GError **error);
      76                 :            : gboolean shumate_vector_value_set_from_g_value (ShumateVectorValue *self, const GValue *value);
      77                 :            : void shumate_vector_value_set_from_feature_value (ShumateVectorValue *self, VectorTile__Tile__Value *value);
      78                 :            : 
      79                 :            : void shumate_vector_value_free (ShumateVectorValue *self);
      80                 :            : void shumate_vector_value_unset (ShumateVectorValue *self);
      81                 :            : gboolean shumate_vector_value_is_null (ShumateVectorValue *self);
      82                 :            : void shumate_vector_value_copy (ShumateVectorValue *self, ShumateVectorValue *out);
      83                 :            : void shumate_vector_value_steal (ShumateVectorValue *self, ShumateVectorValue *out);
      84                 :            : 
      85   [ -  -  -  -  :        360 : G_DEFINE_AUTOPTR_CLEANUP_FUNC (ShumateVectorValue, shumate_vector_value_free)
                   -  - ]
      86                 :       5832 : G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (ShumateVectorValue, shumate_vector_value_unset)
      87                 :            : 
      88                 :            : void shumate_vector_value_set_number (ShumateVectorValue *self, double number);
      89                 :            : gboolean shumate_vector_value_get_number (ShumateVectorValue *self, double *number);
      90                 :            : 
      91                 :            : void shumate_vector_value_set_string (ShumateVectorValue *self, const char *string);
      92                 :            : gboolean shumate_vector_value_get_string (ShumateVectorValue *self, const char **string);
      93                 :            : 
      94                 :            : void shumate_vector_value_set_boolean (ShumateVectorValue *self, gboolean boolean);
      95                 :            : gboolean shumate_vector_value_get_boolean (ShumateVectorValue *self, gboolean *boolean);
      96                 :            : 
      97                 :            : void shumate_vector_value_set_color (ShumateVectorValue *self, GdkRGBA *color);
      98                 :            : gboolean shumate_vector_value_get_color (ShumateVectorValue *self, GdkRGBA *color);
      99                 :            : 
     100                 :            : void shumate_vector_value_start_array (ShumateVectorValue *self);
     101                 :            : void shumate_vector_value_array_append (ShumateVectorValue *self, ShumateVectorValue *element);
     102                 :            : GPtrArray *shumate_vector_value_get_array (ShumateVectorValue *self);
     103                 :            : 
     104                 :            : void shumate_vector_value_set_image (ShumateVectorValue *self, ShumateVectorSprite *image, const char *image_name);
     105                 :            : gboolean shumate_vector_value_get_image (ShumateVectorValue *self, ShumateVectorSprite **image);
     106                 :            : 
     107                 :            : void shumate_vector_value_set_formatted (ShumateVectorValue *self, GPtrArray *format_parts);
     108                 :            : gboolean shumate_vector_value_get_formatted (ShumateVectorValue *self, GPtrArray **format_parts);
     109                 :            : void shumate_vector_format_part_free (ShumateVectorFormatPart *self);
     110   [ -  -  +  -  :         18 : G_DEFINE_AUTOPTR_CLEANUP_FUNC (ShumateVectorFormatPart, shumate_vector_format_part_free)
                   +  - ]
     111                 :            : 
     112                 :            : void shumate_vector_value_set_collator (ShumateVectorValue *self, ShumateVectorCollator *collator);
     113                 :            : gboolean shumate_vector_value_get_collator (ShumateVectorValue *self, ShumateVectorCollator *collator);
     114                 :            : 
     115                 :            : gboolean shumate_vector_value_equal (ShumateVectorValue *a, ShumateVectorValue *b);
     116                 :            : gint shumate_vector_value_hash (ShumateVectorValue *self);
     117                 :            : 
     118                 :            : char *shumate_vector_value_as_string (ShumateVectorValue *self);

Generated by: LCOV version 1.14