1use griff::ChunkStream;
2use crate::clangd::ClangdUtility;
3
4#[derive(Debug, Clone, Default)]
5pub struct Cmdl {
6 pub directory: String,
7 pub cmdl: Vec<String>,
8}
9impl ClangdUtility for Cmdl{}
10
11impl Cmdl {
12 #[allow(dead_code)]
13 pub fn parse(stream: &ChunkStream, string_tables: &Vec<String>) -> Vec<Self> {
14 let mut cmdlines: Vec<Cmdl> = vec![];
15 let data: &[u8] = stream.data.as_slice();
16 if data.len() == 0 {
17 return cmdlines;
18 }
19 let mut cursor: usize = 0;
20 let mut idx: u32;
21 while cursor < data.len() {
22 let mut c: Cmdl = Default::default();
23 let (sz, content) = Self::get_string(data.get(cursor..).unwrap(), string_tables);
24 c.directory = content;
25 cursor += sz;
26 let (sz, len) = Self::get_varint(data.get(cursor..).unwrap());
27 cursor += sz;
28 idx = 0;
29 while idx < len {
30 let (sz, content) = Self::get_string(data.get(cursor..).unwrap(), string_tables);
31 c.cmdl.push(content);
32 cursor += sz;
33 idx += 1;
34 }
35 cmdlines.push(c);
36 }
37
38 cmdlines
39 }
40}