LCOV - code coverage report
Current view: top level - flamenco/rpcserver - fd_methods.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 2 0.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_tango_webserver_fd_methods_h
       2             : #define HEADER_fd_src_tango_webserver_fd_methods_h
       3             : 
       4             : #include "json_lex.h"
       5             : 
       6             : // Data structure describing a "path" to a value in json data. This is
       7             : // basically a path through the syntax tree. A path element can be one
       8             : // of the following:
       9             : //   object member:  (JSON_TOKEN_LBRACE<<16) | keyword_id
      10             : //   array member:   (JSON_TOKEN_LBRACKET<<16) | index
      11             : //   string value:   (JSON_TOKEN_STRING<<16)
      12             : //   int value:      (JSON_TOKEN_INTEGER<<16)
      13             : //   float value:    (JSON_TOKEN_FLOAT<<16)
      14             : //   boolean value:  (JSON_TOKEN_BOOL<<16)
      15             : //   null value:     (JSON_TOKEN_NULL<<16)
      16             : // keyword ids are generated by json_keyword(...) in keywords.h
      17           0 : #define JSON_MAX_PATH 8
      18             : struct json_path {
      19             :     uint len;
      20             :     uint elems[JSON_MAX_PATH];
      21             : };
      22             : 
      23             : // Represents the result of parsing a json data structure. Each leaf
      24             : // value (string, number, boolean, etc) gets an entry in the values
      25             : // list. The complete paths to those values are provided. This
      26             : // structure is optimized for quickly finding values at predetermined
      27             : // paths. It is compact and efficient.
      28           0 : #define JSON_MAX_PATHS 32
      29             : struct json_values {
      30             :     // Number of leaf values
      31             :     uint num_values;
      32             :     struct {
      33             :         // Path to data
      34             :         struct json_path path;
      35             :         // Offset and size of data value in buffer
      36             :         ulong data_offset;
      37             :         ulong data_sz;
      38             :     } values[JSON_MAX_PATHS];
      39             :     // Dynamic buffer containing all data
      40             :     char* buf;
      41             :     ulong buf_sz;
      42             :     ulong buf_alloc;
      43             :     char buf_init[2048];
      44             : };
      45             : 
      46             : // Initialize a json_values
      47             : void json_values_new(struct json_values* values);
      48             : 
      49             : // Destroy a json_values
      50             : void json_values_delete(struct json_values* values);
      51             : 
      52             : // Add a parsed value to a json_values
      53             : void json_add_value(struct json_values* values, struct json_path* path, const void* data, ulong data_sz);
      54             : 
      55             : // Retrieve a value at a given path. A NULL is returned if the path
      56             : // isn't found
      57             : const void* json_get_value(struct json_values* values, const uint* path, uint path_sz, ulong* data_sz);
      58             : 
      59             : // Version that allows iterative retrieval. *pos should be initialized to zero.
      60             : const void* json_get_value_multi(struct json_values* values, const uint* path, uint path_sz, ulong* data_sz, uint * pos);
      61             : 
      62             : // Dump the values and paths to stdout
      63             : void json_values_printout(struct json_values* values);
      64             : 
      65             : // Parse a block of json. Returns 1 on success.
      66             : int json_values_parse(json_lex_state_t* lex, struct json_values* values, struct json_path* path);
      67             : 
      68             : #endif /* HEADER_fd_src_tango_webserver_fd_methods_h */

Generated by: LCOV version 1.14