Skip to content

Commit

Permalink
Adding missing header file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Jan 24, 2025
1 parent c577133 commit 80acb07
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/github-script@v6
with:
Expand Down
98 changes: 98 additions & 0 deletions include/uda/serialisation/capnp_serialisation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#pragma once

#ifndef UDA_CLIENTSERVER_CAPNP_SERIALISATION_H
# define UDA_CLIENTSERVER_CAPNP_SERIALISATION_H

# include <cstdint>
# include <cstdlib>

# ifdef __cplusplus
extern "C" {
# endif

typedef struct Buffer {
char* data;
size_t size;
} BUFFER;

typedef struct Optional_Size_t {
bool has_value;
size_t value;
} OPTIONAL_SIZE_T;

struct TreeBuilder;
struct NodeBuilder;

struct TreeReader;
struct NodeReader;

BUFFER uda_capnp_serialise(TreeBuilder* tree);
TreeReader* uda_capnp_deserialise(const char* bytes, size_t size);

NodeReader* uda_capnp_read_root(TreeReader* tree);
size_t uda_capnp_num_children(NodeReader* node);
NodeReader* uda_capnp_read_child(TreeReader* tree, NodeReader* node, const char* name);
NodeReader* uda_capnp_read_child_n(TreeReader* tree, NodeReader* node, size_t index);
const char* uda_capnp_read_name(NodeReader* node);
int uda_capnp_read_type(NodeReader* node);
OPTIONAL_SIZE_T uda_capnp_read_rank(NodeReader* node);
bool uda_capnp_read_shape(NodeReader* node, size_t* shape);
size_t uda_capnp_read_num_slices(NodeReader* node);
bool uda_capnp_read_is_eos(NodeReader* node);
size_t uda_capnp_read_slice_size(NodeReader* node, size_t slice_num);
bool uda_capnp_read_data(NodeReader* node, size_t slice_num, char* data);

TreeBuilder* uda_capnp_new_tree();
void uda_capnp_free_tree_builder(TreeBuilder* tree);
void uda_capnp_free_tree_reader(TreeReader* tree);

NodeBuilder* uda_capnp_get_root(TreeBuilder* tree);
void uda_capnp_set_node_name(NodeBuilder* node, const char* name);

void uda_capnp_add_children(NodeBuilder* node, size_t num_children);
NodeBuilder* uda_capnp_get_child(TreeBuilder* tree, NodeBuilder* node, size_t index);

void uda_capnp_add_array_f32(NodeBuilder* node, const float* data, size_t size);
void uda_capnp_add_array_f64(NodeBuilder* node, const double* data, size_t size);
void uda_capnp_add_array_i8(NodeBuilder* node, const int8_t* data, size_t size);
void uda_capnp_add_array_i16(NodeBuilder* node, const int16_t* data, size_t size);
void uda_capnp_add_array_i32(NodeBuilder* node, const int32_t* data, size_t size);
void uda_capnp_add_array_i64(NodeBuilder* node, const int64_t* data, size_t size);
void uda_capnp_add_array_u8(NodeBuilder* node, const uint8_t* data, size_t size);
void uda_capnp_add_array_u16(NodeBuilder* node, const uint16_t* data, size_t size);
void uda_capnp_add_array_u32(NodeBuilder* node, const uint32_t* data, size_t size);
void uda_capnp_add_array_u64(NodeBuilder* node, const uint64_t* data, size_t size);
void uda_capnp_add_array_char(NodeBuilder* node, const char* data, size_t size);

void uda_capnp_add_md_array_f32(NodeBuilder* node, const float* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_f64(NodeBuilder* node, const double* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_i8(NodeBuilder* node, const int8_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_i16(NodeBuilder* node, const int16_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_i32(NodeBuilder* node, const int32_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_i64(NodeBuilder* node, const int64_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_u8(NodeBuilder* node, const uint8_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_u16(NodeBuilder* node, const uint16_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_u32(NodeBuilder* node, const uint32_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_u64(NodeBuilder* node, const uint64_t* data, size_t* shape_array, size_t rank);
void uda_capnp_add_md_array_char(NodeBuilder* node, const char* data, size_t* shape_array, size_t rank);

void uda_capnp_add_f32(NodeBuilder* node, float data);
void uda_capnp_add_f64(NodeBuilder* node, double data);
void uda_capnp_add_i8(NodeBuilder* node, int8_t data);
void uda_capnp_add_i16(NodeBuilder* node, int16_t data);
void uda_capnp_add_i32(NodeBuilder* node, int32_t data);
void uda_capnp_add_i64(NodeBuilder* node, int64_t data);
void uda_capnp_add_u8(NodeBuilder* node, uint8_t data);
void uda_capnp_add_u16(NodeBuilder* node, uint16_t data);
void uda_capnp_add_u32(NodeBuilder* node, uint32_t data);
void uda_capnp_add_u64(NodeBuilder* node, uint64_t data);
void uda_capnp_add_char(NodeBuilder* node, char data);

void uda_capnp_print_tree_builder(TreeBuilder* tree);
void uda_capnp_print_tree_reader(TreeReader* tree);

# ifdef __cplusplus
}
# endif

#endif // UDA_CLIENTSERVER_CAPNP_SERIALISATION_H

0 comments on commit 80acb07

Please sign in to comment.