Skip to content

Commit

Permalink
Adding Collapse functionality in CLI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhassina committed Dec 23, 2024
1 parent eb894ed commit 04b90c0
Show file tree
Hide file tree
Showing 5 changed files with 669 additions and 349 deletions.
9 changes: 9 additions & 0 deletions inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern "C"

#define EM_TEST_IO_PERM 0666
#define EM_IO_BUFF_SZ 4096
#define EM_LONG_IO_BUFF_SZ 4096*4

#define EM_MAX_OP_CLASS 48
#define EM_MAX_POLICIES 16
Expand Down Expand Up @@ -2826,8 +2827,16 @@ typedef enum {
em_network_node_data_type_raw,
} em_network_node_data_type_t;

typedef struct {
bool collapsed;
unsigned int orig_node_ctr;
unsigned int node_ctr;
unsigned int node_pos;
} em_node_display_info_t;

typedef struct em_network_node {
em_long_string_t key;
em_node_display_info_t display_info;
em_network_node_data_type_t type;
em_long_string_t value_str;
unsigned int value_int;
Expand Down
26 changes: 17 additions & 9 deletions inc/em_cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

class em_cli_t {
em_cmd_t& get_command(char *in, size_t in_len);
em_long_string_t m_lib_dbg_file_name;

public:
em_editor_callback_t m_editor_cb;
Expand All @@ -33,20 +34,26 @@ class em_cli_t {
const char *get_first_cmd_str();
const char *get_next_cmd_str(const char *cmd);

em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
em_network_node_t *clone_network_tree(em_network_node_t *orig_node, em_network_node_t *dis_node,
unsigned int index, bool collapse, unsigned int *node_ctr = NULL);
em_network_node_t *get_node_from_node_ctr(em_network_node_t *tree, unsigned int node_display_ctr);
int get_network_tree_node(cJSON *obj, em_network_node_t *root, unsigned int *node_ctr);
em_network_node_t *get_child_node_at_index(em_network_node_t *node, unsigned int idx);
unsigned int get_node_display_position(em_network_node_t *node);
char *get_formatted_node_scalar_value(em_network_node_t *node);
char *get_formatted_node_array_value(em_network_node_t *node);
em_network_node_data_type_t get_node_type(em_network_node_t *node);
void free_formatted_node_value(char *str);
int get_network_tree_node(cJSON *obj, em_network_node_t *root);
void free_network_tree(em_network_node_t *tree);
void free_network_tree_node(em_network_node_t *node);
void *network_tree_to_json(em_network_node_t *root);
cJSON *network_tree_node_to_json(em_network_node_t *node, cJSON *parent);
void print_network_tree(em_network_node_t *tree);
void print_network_tree_node(em_network_node_t *node, unsigned int *pident);
void free_network_tree(em_network_node_t *tree);
void free_network_tree_node(em_network_node_t *node);
void *network_tree_to_json(em_network_node_t *root);
cJSON *network_tree_node_to_json(em_network_node_t *node, cJSON *parent);
char *get_network_tree_string(em_network_node_t *tree);
void get_network_tree_node_string(char *str, em_network_node_t *node, unsigned int *pident);
void init_lib_dbg(char *file_name);
void dump_lib_dbg(char *str);

em_cli_t();
~em_cli_t();
Expand All @@ -55,3 +62,4 @@ class em_cli_t {
em_cli_t *get_cli();

#endif

10 changes: 9 additions & 1 deletion inc/em_cli_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ const char *get_next_cmd_str(const char *cmd);
em_network_node_t *get_network_tree_by_file(const char *file_name);
em_network_node_t *get_network_tree(char *buff);
em_network_node_t *get_child_node_at_index(em_network_node_t *node, unsigned int idx);
unsigned int get_node_display_position(em_network_node_t *node);
char *get_formatted_node_scalar_value(em_network_node_t *node);
char *get_formatted_node_array_value(em_network_node_t *node);
void free_formatted_node_value(char *str);
em_network_node_data_type_t get_node_type(em_network_node_t *node);
void free_network_tree(em_network_node_t *node);
void *network_tree_to_json(em_network_node_t *node);
void print_network_tree(em_network_node_t *node);
em_network_node_t *clone_network_tree(em_network_node_t *orig_node, em_network_node_t *dis_node, unsigned int index, bool collapse);
char *get_network_tree_string(em_network_node_t *node);
em_network_node_t *get_node_from_node_ctr(em_network_node_t *tree, unsigned int node_display_ctr);
unsigned int can_collapse_node(em_network_node_t *node);
unsigned int can_expand_node(em_network_node_t *node);
void free_network_tree_string(char *str);
void init_lib_dbg(char *file_name);
void dump_lib_dbg(char *fmt);

#ifdef __cplusplus
} // extern "C"
Expand Down
Loading

0 comments on commit 04b90c0

Please sign in to comment.