Reorganise and start working on the json parser

This commit is contained in:
2023-06-11 02:14:41 +01:00
parent 5ff93f61d7
commit c75e51aa3e
15 changed files with 69 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
#ifndef ALIASES_H
#define ALIASES_H
#include <stdint.h>
#define u8 uint8_t
#define u16 uint16_t
#define u32 uint32_t
#define u64 uint64_t
#define i8 int8_t
#define i16 int16_t
#define i32 int32_t
#define i64 int64_t
#define f32 float
#define f64 double
#define INTERNAL static
#define PERSISTENT static
#ifdef __cplusplus
#define CLASS_MEMBER static
#endif // __cplusplus
#endif // !ALIASES_H

View File

@@ -0,0 +1,15 @@
#ifndef ARGPARSER_H
#define ARGPARSER_H
#include "aliases.h"
#include <argp.h>
struct GeneratorArgs {
u32 seed;
bool clustered;
u64 count;
};
GeneratorArgs parse_args(i32 argc, char *argv[]);
#endif // !ARGPARSER_H

View File

@@ -0,0 +1,8 @@
#ifndef GENERATOR_H
#define GENERATOR_H
#include "point_types.h"
void fill_pairs_array(PairArray *pairs, bool clustered);
#endif // !GENERATOR_H

View File

@@ -0,0 +1,9 @@
#ifndef HAVERSINE_H
#define HAVERSINE_H
#include "aliases.h"
#include "point_types.h"
f64 haversine_of_degrees(const PointPair &pair, f64 radius);
#endif // !HAVERSINE_H

View File

@@ -0,0 +1,27 @@
#ifndef POINT_H
#define POINT_H
#include "aliases.h"
#include <stdio.h>
struct Point {
f64 x;
f64 y;
};
struct PointPair {
Point p1;
Point p2;
};
struct PairArray {
u64 count;
PointPair *pairs;
};
void write_pairs_to_binary(const PairArray &arr, const char *filename);
void read_pairs_from_binary(PairArray &arr, const char *filename);
void write_pairs_to_json(const PairArray &arr, const char *filename);
bool compare_pair_array(const PairArray &arr1, const PairArray &arr2);
#endif // !POINT_H