xref: /illumos-gate/usr/src/lib/libdemangle/common/cxx.h (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2017 Jason King
14  */
15 
16 #ifndef _CPP_H
17 #define	_CPP_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <stdio.h>
24 #include "demangle-sys.h"
25 #include "str.h"
26 
27 typedef struct name_s {
28 	str_pair_t	*nm_items;
29 	sysdem_ops_t	*nm_ops;
30 	size_t		nm_len;
31 	size_t		nm_size;
32 } name_t;
33 
34 extern size_t cpp_name_max_depth;
35 
36 void name_clear(name_t *);
37 void name_init(name_t *, sysdem_ops_t *);
38 void name_fini(name_t *);
39 size_t name_len(const name_t *);
40 boolean_t name_empty(const name_t *);
41 boolean_t name_add(name_t *, const char *, size_t, const char *, size_t);
42 boolean_t name_add_str(name_t *, str_t *, str_t *);
43 boolean_t name_join(name_t *, size_t, const char *);
44 boolean_t name_fmt(name_t *, const char *, const char *);
45 str_pair_t *name_at(const name_t *, size_t);
46 str_pair_t *name_top(name_t *);
47 void name_pop(name_t *, str_pair_t *);
48 
49 typedef struct sub_s {
50 	name_t		*sub_items;
51 	sysdem_ops_t	*sub_ops;
52 	size_t		sub_len;
53 	size_t		sub_size;
54 } sub_t;
55 
56 void sub_clear(sub_t *);
57 void sub_init(sub_t *, sysdem_ops_t *);
58 void sub_fini(sub_t *);
59 void sub_pop(sub_t *);
60 boolean_t sub_save(sub_t *, const name_t *, size_t);
61 boolean_t sub_substitute(const sub_t *, size_t, name_t *);
62 boolean_t sub_empty(const sub_t *);
63 size_t sub_len(const sub_t *);
64 
65 typedef struct templ_s {
66 	sub_t		*tpl_items;
67 	sysdem_ops_t	*tpl_ops;
68 	size_t		tpl_len;
69 	size_t		tpl_size;
70 } templ_t;
71 
72 void templ_init(templ_t *, sysdem_ops_t *);
73 void templ_fini(templ_t *);
74 boolean_t templ_empty(const templ_t *);
75 size_t templ_top_len(const templ_t *);
76 boolean_t templ_sub(const templ_t *, size_t, name_t *);
77 boolean_t templ_save(const name_t *, size_t, templ_t *);
78 
79 boolean_t templ_push(templ_t *);
80 void templ_pop(templ_t *);
81 sub_t *templ_top(templ_t *);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif /* _CPP_H */
88