Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/networking/dataio_json.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
dataio_json.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13#ifndef FC__DATAIO_JSON_H
14#define FC__DATAIO_JSON_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20#include <jansson.h>
21
22/* utility */
23#include "bitvector.h"
24#include "support.h" /* bool type */
25
26/* common/networking */
27#include "connection.h"
28
29struct cm_parameter;
30struct unit_order;
31struct worklist;
32struct requirement;
33
34 struct json_data_out {
35 struct raw_data_out raw;
36 json_t *json;
37};
38
39/* gets */
40 bool dio_get_type_json(struct data_in *din, enum data_type type, int *dest)
41 fc__attribute((nonnull (3)));
42
43 bool dio_get_uint8_json(struct connection *pc, struct data_in *din,
44 const struct plocation *location, int *dest);
45 bool dio_get_uint16_json(struct connection *pc, struct data_in *din,
46 const struct plocation *location, int *dest);
47 bool dio_get_uint32_json(struct connection *pc, struct data_in *din,
48 const struct plocation *location, int *dest);
49
50 bool dio_get_sint8_json(struct connection *pc, struct data_in *din,
51 const struct plocation *location, int *dest);
52 bool dio_get_sint16_json(struct connection *pc, struct data_in *din,
53 const struct plocation *location, int *dest);
54 bool dio_get_sint32_json(struct connection *pc, struct data_in *din,
55 const struct plocation *location, int *dest);
56
57 bool dio_get_bool8_json(struct connection *pc, struct data_in *din,
58 const struct plocation *location, bool *dest);
59 bool dio_get_bool32_json(struct connection *pc, struct data_in *din,
60 const struct plocation *location, bool *dest);
61 bool dio_get_ufloat_json(struct connection *pc, struct data_in *din,
62 const struct plocation *location,
63 float *dest, int float_factor);
64 bool dio_get_sfloat_json(struct connection *pc, struct data_in *din,
65 const struct plocation *location,
66 float *dest, int float_factor);
67 bool dio_get_memory_json(struct connection *pc, struct data_in *din,
68 struct plocation *location,
69 void *dest, size_t dest_size);
70 bool dio_get_string_json(struct connection *pc, struct data_in *din,
71 const struct plocation *location,
72 char *dest, size_t max_dest_size);
73 bool dio_get_estring_json(struct connection *pc, struct data_in *din,
74 const struct plocation *location,
75 char *dest, size_t max_dest_size);
76 bool dio_get_cm_parameter_json(struct connection *pc, struct data_in *din,
77 struct plocation *location,
78 struct cm_parameter *param);
79 bool dio_get_worklist_json(struct connection *pc, struct data_in *din,
80 struct plocation *location,
81 struct worklist *pwl);
82 bool dio_get_unit_order_json(struct connection *pc, struct data_in *din,
83 struct plocation *location,
84 struct unit_order *order);
85 bool dio_get_requirement_json(struct connection *pc, struct data_in *din,
86 const struct plocation *location,
87 struct requirement *preq);
88 bool dio_get_action_probability_json(struct connection *pc, struct data_in *din,
89 const struct plocation *location,
90 struct act_prob *prob);
91
92 bool dio_get_uint8_vec8_json(struct connection *pc, struct data_in *din,
93 const struct plocation *location,
94 int **values, int stop_value);
95 bool dio_get_uint16_vec8_json(struct connection *pc, struct data_in *din,
96 const struct plocation *location,
97 int **values, int stop_value);
98
99/* Should be a function but we need some macro magic. */
100#define DIO_BV_GET(pdin, location, bv) \
101 dio_get_memory_json(pc, pdin, location, \
102 (bv).vec, sizeof((bv).vec))
103
104#define DIO_GET(f, d, l, ...) \
105 dio_get_##f##_json(pc, d, l, ## __VA_ARGS__)
106
107/* puts */
108 int dio_put_farray_json(struct json_data_out *dout,
109 const struct plocation *location, int size);
110
111 int dio_put_type_json(struct json_data_out *dout, enum data_type type,
112 const struct plocation *location,
113 int value);
114
115 int dio_put_uint8_json(struct json_data_out *dout,
116 const struct plocation *location, int value);
117 int dio_put_sint8_json(struct json_data_out *dout,
118 const struct plocation *location, int value);
119 int dio_put_uint16_json(struct json_data_out *dout,
120 const struct plocation *location, int value);
121 int dio_put_sint16_json(struct json_data_out *dout,
122 const struct plocation *location, int value);
123 int dio_put_uint32_json(struct json_data_out *dout,
124 const struct plocation *location, int value);
125 int dio_put_sint32_json(struct json_data_out *dout,
126 const struct plocation *location, int value);
127 int dio_put_bool8_json(struct json_data_out *dout,
128 const struct plocation *location, bool value);
129 int dio_put_bool32_json(struct json_data_out *dout,
130 const struct plocation *location, bool value);
131 int dio_put_ufloat_json(struct json_data_out *dout,
132 const struct plocation *location,
133 float value, int float_factor);
134 int dio_put_sfloat_json(struct json_data_out *dout,
135 const struct plocation *location,
136 float value, int float_factor);
137
138 int dio_put_memory_json(struct json_data_out *dout,
139 struct plocation *location,
140 const void *value, size_t size);
141 int dio_put_string_json(struct json_data_out *dout,
142 const struct plocation *location,
143 const char *value);
144 int dio_put_estring_json(struct json_data_out *dout,
145 const struct plocation *location,
146 const char *value);
147 int dio_put_cm_parameter_json(struct json_data_out *dout,
148 struct plocation *location,
149 const struct cm_parameter *order);
150 int dio_put_unit_order_json(struct json_data_out *dout,
151 struct plocation *location,
152 const struct unit_order *order);
153 int dio_put_worklist_json(struct json_data_out *dout,
154 struct plocation *location,
155 const struct worklist *pwl);
156 int dio_put_requirement_json(struct json_data_out *dout,
157 const struct plocation *location,
158 const struct requirement *preq);
159 int dio_put_action_probability_json(struct json_data_out *dout,
160 const struct plocation *location,
161 const struct act_prob *prob);
162
163 int dio_put_uint8_vec8_json(struct json_data_out *dout,
164 const struct plocation *location,
165 int *values, int stop_value);
166 int dio_put_uint16_vec8_json(struct json_data_out *dout,
167 const struct plocation *location,
168 int *values, int stop_value);
169
170/* Should be a function but we need some macro magic. */
171#define DIO_BV_PUT(pdout, location, bv) \
172 dio_put_memory_json((pdout), location, (bv).vec, sizeof((bv).vec))
173
174#define DIO_PUT(f, d, l, ...) \
175 dio_put_##f##_json(d, l, ## __VA_ARGS__)
176
177#ifdef __cplusplus
178}
179#endif /* __cplusplus */
180
181#endif /* FC__DATAIO_JSON_H */
bitvector.h
incite_cost
char * incite_cost
Definition comments.c:74
connection.h
dio_put_unit_order_json
int dio_put_unit_order_json(struct json_data_out *dout, struct plocation *location, const struct unit_order *order)
dio_get_type_json
bool dio_get_type_json(struct data_in *din, enum data_type type, int *dest) fc__attribute((nonnull(3)))
dio_put_type_json
int dio_put_type_json(struct json_data_out *dout, enum data_type type, const struct plocation *location, int value)
dio_put_uint8_vec8_json
int dio_put_uint8_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
dio_get_uint16_json
bool dio_get_uint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_get_estring_json
bool dio_get_estring_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_size)
dio_put_worklist_json
int dio_put_worklist_json(struct json_data_out *dout, struct plocation *location, const struct worklist *pwl)
dio_put_uint32_json
int dio_put_uint32_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_get_worklist_json
bool dio_get_worklist_json(struct connection *pc, struct data_in *din, struct plocation *location, struct worklist *pwl)
dio_put_uint16_vec8_json
int dio_put_uint16_vec8_json(struct json_data_out *dout, const struct plocation *location, int *values, int stop_value)
dio_get_sint16_json
bool dio_get_sint16_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_get_sint32_json
bool dio_get_sint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_get_sint8_json
bool dio_get_sint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_put_uint16_json
int dio_put_uint16_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_get_bool32_json
bool dio_get_bool32_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest)
dio_put_memory_json
int dio_put_memory_json(struct json_data_out *dout, struct plocation *location, const void *value, size_t size)
dio_get_uint32_json
bool dio_get_uint32_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_get_string_json
bool dio_get_string_json(struct connection *pc, struct data_in *din, const struct plocation *location, char *dest, size_t max_dest_size)
dio_put_uint8_json
int dio_put_uint8_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_put_farray_json
int dio_put_farray_json(struct json_data_out *dout, const struct plocation *location, int size)
dio_get_requirement_json
bool dio_get_requirement_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct requirement *preq)
dio_put_bool8_json
int dio_put_bool8_json(struct json_data_out *dout, const struct plocation *location, bool value)
dio_get_uint8_vec8_json
bool dio_get_uint8_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int **values, int stop_value)
dio_get_cm_parameter_json
bool dio_get_cm_parameter_json(struct connection *pc, struct data_in *din, struct plocation *location, struct cm_parameter *param)
dio_get_sfloat_json
bool dio_get_sfloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor)
dio_get_uint8_json
bool dio_get_uint8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int *dest)
dio_put_sint32_json
int dio_put_sint32_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_get_memory_json
bool dio_get_memory_json(struct connection *pc, struct data_in *din, struct plocation *location, void *dest, size_t dest_size)
dio_get_unit_order_json
bool dio_get_unit_order_json(struct connection *pc, struct data_in *din, struct plocation *location, struct unit_order *order)
dio_put_estring_json
int dio_put_estring_json(struct json_data_out *dout, const struct plocation *location, const char *value)
dio_put_action_probability_json
int dio_put_action_probability_json(struct json_data_out *dout, const struct plocation *location, const struct act_prob *prob)
dio_get_ufloat_json
bool dio_get_ufloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, float *dest, int float_factor)
dio_put_bool32_json
int dio_put_bool32_json(struct json_data_out *dout, const struct plocation *location, bool value)
dio_get_action_probability_json
bool dio_get_action_probability_json(struct connection *pc, struct data_in *din, const struct plocation *location, struct act_prob *prob)
dio_put_sfloat_json
int dio_put_sfloat_json(struct json_data_out *dout, const struct plocation *location, float value, int float_factor)
dio_put_requirement_json
int dio_put_requirement_json(struct json_data_out *dout, const struct plocation *location, const struct requirement *preq)
dio_put_sint8_json
int dio_put_sint8_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_put_sint16_json
int dio_put_sint16_json(struct json_data_out *dout, const struct plocation *location, int value)
dio_put_ufloat_json
int dio_put_ufloat_json(struct json_data_out *dout, const struct plocation *location, float value, int float_factor)
dio_get_bool8_json
bool dio_get_bool8_json(struct connection *pc, struct data_in *din, const struct plocation *location, bool *dest)
dio_put_string_json
int dio_put_string_json(struct json_data_out *dout, const struct plocation *location, const char *value)
dio_put_cm_parameter_json
int dio_put_cm_parameter_json(struct json_data_out *dout, struct plocation *location, const struct cm_parameter *order)
dio_get_uint16_vec8_json
bool dio_get_uint16_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, int **values, int stop_value)
data_type
data_type
Definition dataio_raw.h:43
type
GType type
Definition repodlgs.c:1313
size
size_t size
Definition specvec.h:72
act_prob
Definition fc_types.h:1241
cm_parameter
Definition cm.h:40
connection
Definition connection.h:136
data_in
Definition dataio_raw.h:30
json_data_out
Definition dataio_json.h:34
json_data_out::json
json_t * json
Definition dataio_json.h:36
json_data_out::raw
struct raw_data_out raw
Definition dataio_json.h:35
plocation
Definition dataio_raw.h:63
raw_data_out
Definition dataio_raw.h:35
raw_data_out::dest
void * dest
Definition dataio_raw.h:36
raw_data_out::dest_size
size_t dest_size
Definition dataio_raw.h:37
requirement
Definition requirements.h:81
unit_order
Definition unit.h:92
worklist
Definition worklist.h:28
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:99