cxx_qt_gen/generator/cpp/
fragment.rs

1// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
2// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com>
3//
4// SPDX-License-Identifier: MIT OR Apache-2.0
5
6#[derive(PartialEq, Eq, Debug)]
7/// A fragment of C++ code
8pub enum CppFragment {
9    /// A fragment which only both a header and a source
10    Pair {
11        /// The header of the fragment
12        header: String,
13        /// The source of the fragment
14        source: String,
15    },
16    /// A fragment which only has a header
17    Header(String),
18    /// A fragment which only has a source
19    Source(String),
20}
21
22impl Default for CppFragment {
23    fn default() -> Self {
24        CppFragment::Pair {
25            header: String::new(),
26            source: String::new(),
27        }
28    }
29}
30
31pub struct CppNamedType {
32    pub ident: String,
33    pub ty: String,
34}
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    #[test]
41    fn test_default_creation() {
42        assert_eq!(
43            CppFragment::default(),
44            CppFragment::Pair {
45                header: String::new(),
46                source: String::new()
47            }
48        )
49    }
50}