mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-04 01:15:41 +02:00
Change the JSON writing functions to object methods
This commit is contained in:
+24
-18
@@ -14,12 +14,13 @@ enum json_write_tok {
|
||||
JSON_WRITE_TOP,
|
||||
};
|
||||
|
||||
struct json_write_state {
|
||||
struct json_writer {
|
||||
std::vector<json_write_tok> state;
|
||||
bool nospace = false;
|
||||
bool wantnl = false;
|
||||
FILE *f;
|
||||
|
||||
~json_write_state() {
|
||||
~json_writer() {
|
||||
if (state.size() > 0) {
|
||||
if (state.size() != 1 || state[0] != JSON_WRITE_TOP) {
|
||||
fprintf(stderr, "JSON not closed at end\n");
|
||||
@@ -27,24 +28,29 @@ struct json_write_state {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json_writer(FILE *fp) {
|
||||
f = fp;
|
||||
}
|
||||
|
||||
void json_write_array();
|
||||
void json_end_array();
|
||||
void json_write_hash();
|
||||
void json_end_hash();
|
||||
void json_write_string(std::string const &s);
|
||||
void json_write_number(double d);
|
||||
void json_write_float(double d);
|
||||
void json_write_unsigned(unsigned long long v);
|
||||
void json_write_signed(long long v);
|
||||
void json_write_stringified(std::string const &s);
|
||||
void json_write_bool(bool b);
|
||||
void json_write_null();
|
||||
void json_write_newline();
|
||||
void json_comma_newline();
|
||||
void json_adjust();
|
||||
};
|
||||
|
||||
void layer_to_geojson(FILE *fp, mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_write_state &state);
|
||||
void layer_to_geojson(mvt_layer const &layer, unsigned z, unsigned x, unsigned y, bool comma, bool name, bool zoom, bool dropped, unsigned long long index, long long sequence, long long extent, bool complain, json_writer &state);
|
||||
void fprintq(FILE *f, const char *s);
|
||||
|
||||
void json_write_array(FILE *f, json_write_state &state);
|
||||
void json_end_array(FILE *f, json_write_state &state);
|
||||
void json_write_hash(FILE *f, json_write_state &state);
|
||||
void json_end_hash(FILE *f, json_write_state &state);
|
||||
void json_write_string(FILE *f, std::string const &s, json_write_state &state);
|
||||
void json_write_number(FILE *f, double d, json_write_state &state);
|
||||
void json_write_float(FILE *f, double d, json_write_state &state);
|
||||
void json_write_unsigned(FILE *f, unsigned long long v, json_write_state &state);
|
||||
void json_write_signed(FILE *f, long long v, json_write_state &state);
|
||||
void json_write_stringified(FILE *f, std::string const &s, json_write_state &state);
|
||||
void json_write_bool(FILE *f, bool b, json_write_state &state);
|
||||
void json_write_null(FILE *f, json_write_state &state);
|
||||
void json_write_newline(FILE *f, json_write_state &state);
|
||||
void json_comma_newline(FILE *f, json_write_state &state);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user