1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! ## 使用方式
//!
//! 注:
//! 1. `hicc-std`仅提供了`std::string`, `std::u16string`, `std::u32string`相关的构造函数.
//! 1. `v0.2.0`版本, 通过增加参数校验,消除了原接口中可能抛出的各种异常.
//! 部分接口的返回值类型发生了变化.
//!
//! 因为都是模板类,需要使用者显式实现实例化模版类的构建函数. 参见如下代码:
//!
//! ```text
//! use hicc::AbicClass;
//!
//! hicc::cpp! {
//! // c++侧需要引用hicc提供的头文件.
//! #include <hicc/std/map.hpp>
//! #include <hicc/std/string.hpp>
//!
//! // 按需定义容器类型. 可以包含非缺省的Allocator等模版参数类型.
//! typedef std::map<int, std::string> CppMap;
//! }
//!
//! hicc::import_lib! {
//! #![link_name = "example"]
//!
//! // 对应`c++`的`CppMap`
//! class RustMap = hicc_std::map<hicc::Pod<i32>, hicc_std::string>;
//!
//! // 创建容器接口.
//! #[cpp(func = "std::unique_ptr<CppMap> hicc::make_unique<CppMap>()")]
//! fn rustmap_new() -> RustMap;
//! }
//!
//! fn main() {
//! let mut map = rustmap_new();
//! let name = hicc_std::string::from(hicc::cstr!("hello"));
//! map.insert(&0, &name);
//! assert_eq!(map.get(&1), None);
//! assert_eq!(map.get(&0), Some(name.as_ref()));
//! }
//! ```
//!
//! **注意**:
//! > 1. 模版参数类型只能是`c++`类或者可直接在`CABI`接口上传递使用的`POD`数据类型,后者只能结合`hicc::Pod<T>`使用.
//!
//! 3. `build.rs`编译`c++`代码
//!
//! ```text
//! fn main() {
//! hicc_build::Build::new().rust_file("src/main.rs").compile("example");
//! println!("cargo::rustc-link-lib=example");
//! println!("cargo::rustc-link-lib=stdc++");
//! println!("cargo::rerun-if-changed=src/main.rs");
//! }
//! ```
//!
//! `hicc_build`仅支持生成静态库, 需要最终构建为可执行程序或者动态库时指定所依赖的`c++`标准库.
//!
//! ## 迭代器接口说明
//!
//! `c++`容器基于迭代器实现插入删除等接口违背`rust`的借用规则, `hicc-std`将迭代器做了二次封装,提供容器遍历和插入删除功能.
//!
//! ## 测试
//!
//! `doc test`需要开启`test feature`, 提供了测试用例用到的容器实例化类型的构建函数.
//!
//! ```text
//! # cargo test --features "test"
//! ```
//!
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;