libhpdftbl 1.5.0
Table construction library for Haru PDF library
|
Functions for load (internalizing) serialized data structure. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <hpdf.h>
#include "hpdftbl.h"
#include <jansson.h>
Macros | |
#define | GETJSON_STRING(table, k, var) |
#define | GETJSON_UINT(table, k, var) |
#define | GETJSON_REAL(table, k, var) |
#define | GETJSON_BOOLEAN(table, k, var) |
#define | GETJSON_RGB(table, k, var) |
#define | GETJSON_GRIDSTYLE(table, k, var) |
#define | GETJSON_TXTSTYLE(table, k, var) |
#define | GETJSON_REALARRAY(table, k, var) |
#define | GETJSON_DYNCB(table, key) |
#define | GETJSON_CELLDYNCB(table, key, r, c) |
#define | GETJSON_CELLTXTSTYLE(table, key, r, c) |
Functions | |
int | hpdftbl_theme_loads (hpdftbl_theme_t *theme, char *buff) |
Load theme from a serialized string. This is the invert function of hpdftbl_theme_dumps(). More... | |
int | hpdftbl_theme_load (hpdftbl_theme_t *theme, char *filename) |
Read a theme from a previous serialized theme from a named file. More... | |
int | hpdftbl_load (hpdftbl_t tbl, char *filename) |
Import a table structure from a serialized table on file. More... | |
int | hpdftbl_loads (hpdftbl_t tbl, char *buff) |
Import a table structure from a serialized json buffert. More... | |
Functions for load (internalizing) serialized data structure.
Copyright (C) 2022 Johan Persson
Released under the MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GETJSON_BOOLEAN | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_CELLDYNCB | ( | table, | |
key, | |||
r, | |||
c | |||
) |
#define GETJSON_CELLTXTSTYLE | ( | table, | |
key, | |||
r, | |||
c | |||
) |
#define GETJSON_DYNCB | ( | table, | |
key | |||
) |
#define GETJSON_GRIDSTYLE | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_REAL | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_REALARRAY | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_RGB | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_STRING | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_TXTSTYLE | ( | table, | |
k, | |||
var | |||
) |
#define GETJSON_UINT | ( | table, | |
k, | |||
var | |||
) |
int hpdftbl_load | ( | hpdftbl_t | tbl, |
char * | filename | ||
) |
Import a table structure from a serialized table on file.
The json file make it possible to adjust the table directly. However it is easy to get it wrong. Some things to keep in mind while doing manual changes.
After reading a serialized table it can asily be be stroked with only two lines of code as the following code-snippet shows
hpdftbl_t
is a pointer type to struct hpdftbl
and hence must must be either dynamically allocated as the example here shows or an instance of the struct must be created whose address is given to this functions.tbl | Table to read into |
filename | File to read from |
int hpdftbl_loads | ( | hpdftbl_t | tbl, |
char * | buff | ||
) |
Import a table structure from a serialized json buffert.
This is the preferred way on how to store a table structure in for example a database.
Example:
tbl | Reference to table handle to be populated |
buff | Buffer with serialized data to read back |
Referenced by hpdftbl_load().
int hpdftbl_theme_load | ( | hpdftbl_theme_t * | theme, |
char * | filename | ||
) |
Read a theme from a previous serialized theme from a named file.
Example:
theme | Theme to read into |
filename | File to read from |
int hpdftbl_theme_loads | ( | hpdftbl_theme_t * | theme, |
char * | buff | ||
) |
Load theme from a serialized string. This is the invert function of hpdftbl_theme_dumps().
theme | Theme to load to. |
buff | Buffer which holds the previous serialized theme |
Referenced by hpdftbl_theme_load().