1use serde::Serialize;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
4#[serde(rename_all = "snake_case")]
5#[non_exhaustive]
7pub enum CppConfidence {
8 Exact,
10 High,
12 Medium,
14 Low,
16 Hook,
18}
19
20impl CppConfidence {
21 pub fn max(self, other: Self) -> Self {
23 self.max_by(other, |left, right| left.cmp(right))
24 }
25
26 fn max_by<F>(self, other: Self, cmp: F) -> Self
27 where
28 F: Fn(&Self, &Self) -> std::cmp::Ordering,
29 {
30 if cmp(&self, &other).is_ge() {
31 self
32 } else {
33 other
34 }
35 }
36}
37
38#[derive(Debug, Clone, Serialize)]
39#[serde(rename_all = "snake_case")]
40#[non_exhaustive]
42pub enum CppEvidenceKind {
43 MangledSymbol,
45 DemangledSymbol,
47 Vtable,
49 TypeInfo,
51 BodyAnalysis,
53 CrossBinary,
55 ExternalHeader,
57}
58
59#[derive(Debug, Clone, Serialize)]
60pub struct CppEvidence {
62 pub kind: CppEvidenceKind,
64 pub confidence: CppConfidence,
66 pub detail: String,
68}
69
70#[derive(Debug, Clone, Serialize)]
71#[serde(rename_all = "snake_case")]
72#[non_exhaustive]
74pub enum CppTypeInfoKind {
75 Class,
77 SingleInheritance,
79 VirtualMultipleInheritance,
81 Unknown,
83}
84
85#[derive(Debug, Clone, Serialize)]
86pub struct CppBaseClass {
88 pub name: String,
90 pub offset: Option<i64>,
92 pub flags: u64,
94 pub is_virtual: bool,
96 pub is_public: bool,
98 pub evidence: Vec<CppEvidence>,
100}
101
102#[derive(Debug, Clone, Serialize)]
103pub struct CppTypeInfoNode {
105 pub name: String,
107 pub mangled_name: String,
109 pub address: u64,
111 pub kind: CppTypeInfoKind,
113 pub bases: Vec<CppBaseClass>,
115 pub evidence: Vec<CppEvidence>,
117}