mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
update docs
This commit is contained in:
parent
945df56a7e
commit
62024334ab
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
2023/09/27
|
||||
* 更新文档。
|
||||
|
||||
2023/09/26
|
||||
* 修复对旧linux-fb的debug模式为true的问题(感谢智明提供补丁)
|
||||
* 修复环形进度条value为0时候画成百分百以及修改nanovg的浮点比较问题(感谢智明提供补丁)
|
||||
|
@ -3,6 +3,49 @@
|
||||
![image](images/conf_ini_t_0.png)
|
||||
|
||||
conf ini对象。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
char filename[MAX_PATH + 1] = {0};
|
||||
path_prepend_temp_path(filename, "test.ini");
|
||||
|
||||
const char *ini_data1 = "[root]\n"
|
||||
"name=awplc\n"
|
||||
"age=18\n"
|
||||
"weight=60.5\n";
|
||||
ENSURE(file_write(filename, ini_data1, strlen(ini_data1)) == RET_OK);
|
||||
|
||||
// 从文件加载
|
||||
tk_object_t *ini = conf_ini_load(filename, FALSE);
|
||||
|
||||
// 获取数据。
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(ini, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(ini, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(ini, "root.weight", 0) == 60.5);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(ini);
|
||||
|
||||
// 从内存加载
|
||||
ini = conf_ini_load_from_buff(ini_data1, strlen(ini_data1), FALSE);
|
||||
|
||||
// 获取数据
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(ini, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(ini, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(ini, "root.weight", 0) == 60.5);
|
||||
|
||||
// 设置数据
|
||||
ENSURE(tk_object_set_prop_int(ini, "root.age", 20) == RET_OK);
|
||||
ENSURE(tk_object_get_prop_int(ini, "root.age", 0) == 20);
|
||||
|
||||
// 保存到文件
|
||||
ENSURE(conf_ini_save_as(ini, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(ini);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="conf_ini_t_methods">
|
||||
|
@ -3,6 +3,52 @@
|
||||
![image](images/conf_json_t_0.png)
|
||||
|
||||
conf json对象。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
char filename[MAX_PATH + 1] = {0};
|
||||
path_prepend_temp_path(filename, "test.json");
|
||||
|
||||
const char *json_data1 = "{"
|
||||
"{\"root\":{"
|
||||
"\"name\":\"awplc\","
|
||||
"\"age\":18,"
|
||||
"\"weight\":60.5"
|
||||
"}"
|
||||
"}";
|
||||
ENSURE(file_write(filename, json_data1, strlen(json_data1)) == RET_OK);
|
||||
|
||||
// 从文件加载
|
||||
tk_object_t *json = conf_json_load(filename, FALSE);
|
||||
|
||||
// 获取数据。
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(json, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(json, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(json, "root.weight", 0) == 60.5);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(json);
|
||||
|
||||
// 从内存加载
|
||||
json = conf_json_load_from_buff(json_data1, strlen(json_data1), FALSE);
|
||||
|
||||
// 获取数据
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(json, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(json, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(json, "root.weight", 0) == 60.5);
|
||||
|
||||
// 设置数据
|
||||
ENSURE(tk_object_set_prop_int(json, "root.age", 20) == RET_OK);
|
||||
ENSURE(tk_object_get_prop_int(json, "root.age", 0) == 20);
|
||||
|
||||
// 保存到文件
|
||||
ENSURE(conf_json_save_as(json, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(json);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="conf_json_t_methods">
|
||||
|
@ -3,6 +3,45 @@
|
||||
![image](images/conf_ubjson_t_0.png)
|
||||
|
||||
conf json对象。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
char filename[MAX_PATH + 1] = {0};
|
||||
path_prepend_temp_path(filename, "test.ubjson");
|
||||
|
||||
const char *ubjson_data1 = "{"
|
||||
"\"root\":{"
|
||||
"\"name\":\"awplc\","
|
||||
"\"age\":18,"
|
||||
"\"weight\":60.5"
|
||||
"}"
|
||||
"}";
|
||||
|
||||
// 将JSON保存为UBJSON
|
||||
tk_object_t *json = conf_json_load_from_buff(ubjson_data1, strlen(ubjson_data1), FALSE);
|
||||
ENSURE(conf_ubjson_save_as(json, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 从文件加载
|
||||
tk_object_t *ubjson = conf_ubjson_load(filename, FALSE);
|
||||
|
||||
// 获取数据。
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(ubjson, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(ubjson, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(ubjson, "root.weight", 0) == 60.5);
|
||||
|
||||
// 设置数据
|
||||
ENSURE(tk_object_set_prop_int(ubjson, "root.age", 20) == RET_OK);
|
||||
ENSURE(tk_object_get_prop_int(ubjson, "root.age", 0) == 20);
|
||||
|
||||
// 保存到文件
|
||||
ENSURE(conf_ubjson_save_as(ubjson, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(ubjson);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="conf_ubjson_t_methods">
|
||||
|
@ -3,6 +3,47 @@
|
||||
![image](images/conf_xml_t_0.png)
|
||||
|
||||
conf xml对象。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
char filename[MAX_PATH + 1] = {0};
|
||||
path_prepend_temp_path(filename, "test.xml");
|
||||
|
||||
const char *xml_data1 = "<root><name>awplc</name><age>18</age><weight>60.5</weight></root>";
|
||||
ENSURE(file_write(filename, xml_data1, strlen(xml_data1)) == RET_OK);
|
||||
|
||||
// 从文件加载
|
||||
tk_object_t *xml = conf_xml_load(filename, FALSE);
|
||||
|
||||
// 获取数据。注意:从文本节点获取数据,需要加上@text
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(xml, "root.name.@text"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(xml, "root.age.@text", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(xml, "root.weight.@text", 0) == 60.5);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(xml);
|
||||
|
||||
// 从内存加载
|
||||
const char *xml_data2 = "<root name=\"awplc\" age=\"18\" weight=\"60.5\"></root>";
|
||||
xml = conf_xml_load_from_buff(xml_data2, strlen(xml_data2), FALSE);
|
||||
|
||||
// 获取数据
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(xml, "root.name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(xml, "root.age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(xml, "root.weight", 0) == 60.5);
|
||||
|
||||
// 设置数据
|
||||
ENSURE(tk_object_set_prop_int(xml, "root.age", 20) == RET_OK);
|
||||
ENSURE(tk_object_get_prop_int(xml, "root.age", 0) == 20);
|
||||
|
||||
// 保存到文件
|
||||
ENSURE(conf_xml_save_as(xml, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(xml);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="conf_xml_t_methods">
|
||||
|
@ -3,6 +3,57 @@
|
||||
![image](images/csv_file_object_t_0.png)
|
||||
|
||||
将cvs file包装成object对象。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
char filename[MAX_PATH + 1] = {0};
|
||||
path_prepend_temp_path(filename, "test.csv");
|
||||
|
||||
const char *csv_data1 = "name,age,weight\n"
|
||||
"awplc,18,60.5\n";
|
||||
ENSURE(file_write(filename, csv_data1, strlen(csv_data1)) == RET_OK);
|
||||
|
||||
// 从文件加载
|
||||
tk_object_t *csv = csv_file_object_load(filename, ',');
|
||||
|
||||
// 获取数据: 通过属性名
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(csv, "[1].weight", 0) == 60.5);
|
||||
|
||||
// 获取数据: 通过属性索引
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].0"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(csv, "[1].1", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(csv, "[1].2", 0) == 60.5);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(csv);
|
||||
|
||||
// 从内存加载
|
||||
csv = csv_file_object_load_from_buff(csv_data1, strlen(csv_data1), ',');
|
||||
|
||||
// 获取数据: 通过属性名
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(csv, "[1].weight", 0) == 60.5);
|
||||
|
||||
// 获取数据: 通过属性索引
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].0"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(csv, "[1].1", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(csv, "[1].2", 0) == 60.5);
|
||||
|
||||
// 设置数据
|
||||
ENSURE(tk_object_set_prop_int(csv, "[1].age", 20) == RET_OK);
|
||||
ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 20);
|
||||
|
||||
// 保存到文件
|
||||
ENSURE(csv_file_object_save_as(csv, filename) == RET_OK);
|
||||
ENSURE(file_exist(filename) == TRUE);
|
||||
|
||||
// 销毁对象
|
||||
TK_OBJECT_UNREF(csv);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="csv_file_object_t_methods">
|
||||
@ -11,6 +62,10 @@
|
||||
| -------- | ------------ |
|
||||
| <a href="#csv_file_object_t_csv_file_object_create">csv\_file\_object\_create</a> | 将csv_file对象包装成object。 |
|
||||
| <a href="#csv_file_object_t_csv_file_object_get_csv">csv\_file\_object\_get\_csv</a> | 获取csv对象。 |
|
||||
| <a href="#csv_file_object_t_csv_file_object_load">csv\_file\_object\_load</a> | 从指定文件加载CSV对象。 |
|
||||
| <a href="#csv_file_object_t_csv_file_object_load_from_buff">csv\_file\_object\_load\_from\_buff</a> | 从内存加载CSV对象。 |
|
||||
| <a href="#csv_file_object_t_csv_file_object_save_as">csv\_file\_object\_save\_as</a> | 将doc对象保存到指定文件。 |
|
||||
| <a href="#csv_file_object_t_csv_file_object_save_to_buff">csv\_file\_object\_save\_to\_buff</a> | 将obj保存为CSV格式到内存。 |
|
||||
#### csv\_file\_object\_create 函数
|
||||
-----------------------
|
||||
|
||||
@ -49,3 +104,84 @@ csv_file_t* csv_file_object_get_csv (tk_object_t* obj);
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | csv\_file\_t* | 返回csv对象。 |
|
||||
| obj | tk\_object\_t* | obj对象。 |
|
||||
#### csv\_file\_object\_load 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="csv_file_object_t_csv_file_object_load">从指定文件加载CSV对象。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
tk_object_t* csv_file_object_load (const char* filename, char sep);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | tk\_object\_t* | 返回配置对象。 |
|
||||
| filename | const char* | 文件名。 |
|
||||
| sep | char | 分隔符。 |
|
||||
#### csv\_file\_object\_load\_from\_buff 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="csv_file_object_t_csv_file_object_load_from_buff">从内存加载CSV对象。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
tk_object_t* csv_file_object_load_from_buff (const void* buff, uint32_t size, char sep);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | tk\_object\_t* | 返回配置对象。 |
|
||||
| buff | const void* | 数据。 |
|
||||
| size | uint32\_t | 数据长度。 |
|
||||
| sep | char | 分隔符。 |
|
||||
#### csv\_file\_object\_save\_as 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="csv_file_object_t_csv_file_object_save_as">将doc对象保存到指定文件。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t csv_file_object_save_as (tk_object_t* obj, const char* filename);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败 |
|
||||
| obj | tk\_object\_t* | doc对象。 |
|
||||
| filename | const char* | 文件名。 |
|
||||
#### csv\_file\_object\_save\_to\_buff 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="csv_file_object_t_csv_file_object_save_to_buff">将obj保存为CSV格式到内存。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t csv_file_object_save_to_buff (tk_object_t* obj, wbuffer_t* wb);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败 |
|
||||
| obj | tk\_object\_t* | doc对象。 |
|
||||
| wb | wbuffer\_t* | 返回结果(不要初始化,使用完成后要调用wbuffer\_deinit)。 |
|
||||
|
@ -27,6 +27,7 @@
|
||||
| <a href="#csv_file_t_csv_file_remove_checked_rows">csv\_file\_remove\_checked\_rows</a> | 删除全部勾选的行。 |
|
||||
| <a href="#csv_file_t_csv_file_remove_row">csv\_file\_remove\_row</a> | 删除指定行。 |
|
||||
| <a href="#csv_file_t_csv_file_save">csv\_file\_save</a> | 保存。 |
|
||||
| <a href="#csv_file_t_csv_file_save_to_buff">csv\_file\_save\_to\_buff</a> | 保存。 |
|
||||
| <a href="#csv_file_t_csv_file_set">csv\_file\_set</a> | 修改指定行列的数据。 |
|
||||
| <a href="#csv_file_t_csv_file_set_filter">csv\_file\_set\_filter</a> | 设置过滤函数。 |
|
||||
| <a href="#csv_file_t_csv_file_set_row_checked">csv\_file\_set\_row\_checked</a> | 勾选指定行。 |
|
||||
@ -433,6 +434,26 @@ ret_t csv_file_save (csv_file_t* csv, const char* filename);
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| csv | csv\_file\_t* | csv对象。 |
|
||||
| filename | const char* | 文件名。 |
|
||||
#### csv\_file\_save\_to\_buff 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="csv_file_t_csv_file_save_to_buff">保存。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t csv_file_save_to_buff (csv_file_t* csv, wbuffer_t* buff);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| csv | csv\_file\_t* | csv对象。 |
|
||||
| buff | wbuffer\_t* | 保存结果数据。 |
|
||||
#### csv\_file\_set 函数
|
||||
-----------------------
|
||||
|
||||
|
@ -18,6 +18,81 @@ hash_table_t* hash_table = hash_table_create(10, destroy, compare, hash);
|
||||
...
|
||||
hash_table_destroy(hash_table);
|
||||
```
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
typedef struct _motor_t
|
||||
{
|
||||
int id;
|
||||
int position;
|
||||
int velocity;
|
||||
int acceleration;
|
||||
} motor_t;
|
||||
|
||||
motor_t *motor_create(int id)
|
||||
{
|
||||
motor_t *motor = new motor_t;
|
||||
motor->id = id;
|
||||
motor->position = 0;
|
||||
motor->velocity = 0;
|
||||
motor->acceleration = 0;
|
||||
return motor;
|
||||
}
|
||||
|
||||
ret_t motor_destroy(motor_t *motor)
|
||||
{
|
||||
delete motor;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int motor_compare(const void *a, const void *b)
|
||||
{
|
||||
motor_t *motor_a = (motor_t *)a;
|
||||
motor_t *motor_b = (motor_t *)b;
|
||||
|
||||
return motor_a->id - motor_b->id;
|
||||
}
|
||||
|
||||
ret_t visist_motor(void *ctx, const void *data)
|
||||
{
|
||||
motor_t *motor = (motor_t *)data;
|
||||
log_debug("motor id: %d\n", motor->id);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
uint32_t motor_hash(const void *data)
|
||||
{
|
||||
motor_t *motor = (motor_t *)data;
|
||||
return motor->id;
|
||||
}
|
||||
|
||||
void demo(void)
|
||||
{
|
||||
hash_table_t motors;
|
||||
motor_t *motor = NULL;
|
||||
|
||||
// 初始化哈希表
|
||||
hash_table_init(&motors, 10, (tk_destroy_t)motor_destroy, (tk_compare_t)motor_compare, motor_hash);
|
||||
|
||||
motor = motor_create(1);
|
||||
// 将motor添加到哈希表
|
||||
hash_table_add(&motors, motor, TRUE);
|
||||
ENSURE(hash_table_find(&motors, NULL, motor) == motor);
|
||||
|
||||
motor = motor_create(2);
|
||||
// 将motor添加到哈希表
|
||||
hash_table_add(&motors, motor, TRUE);
|
||||
ENSURE(hash_table_find(&motors, NULL, motor) == motor);
|
||||
|
||||
// 遍历哈希表
|
||||
log_debug("motors size: %d\n", hash_table_size(&motors));
|
||||
hash_table_foreach(&motors, visist_motor, NULL);
|
||||
|
||||
// 释放哈希表
|
||||
hash_table_deinit(&motors);
|
||||
}
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="hash_table_t_methods">
|
||||
|
@ -4,7 +4,30 @@
|
||||
|
||||
对象接口的缺省实现。
|
||||
|
||||
内部使用有序数组保存所有属性,可以快速查找指定名称的属性。
|
||||
通用当作 map 数据结构使用,内部用有序数组保存所有属性,因此可以快速查找指定名称的属性。
|
||||
|
||||
示例
|
||||
|
||||
```c
|
||||
// 创建默认对象
|
||||
tk_object_t *obj = object_default_create();
|
||||
|
||||
// 设置属性
|
||||
tk_object_set_prop_str(obj, "name", "awplc");
|
||||
tk_object_set_prop_int(obj, "age", 18);
|
||||
tk_object_set_prop_double(obj, "weight", 60.5);
|
||||
|
||||
// 获取属性
|
||||
ENSURE(tk_str_eq(tk_object_get_prop_str(obj, "name"), "awplc"));
|
||||
ENSURE(tk_object_get_prop_int(obj, "age", 0) == 18);
|
||||
ENSURE(tk_object_get_prop_double(obj, "weight", 0) == 60.5);
|
||||
|
||||
// 遍历属性
|
||||
tk_object_foreach_prop(obj, visit_obj, NULL);
|
||||
|
||||
// 释放对象
|
||||
TK_OBJECT_UNREF(obj);
|
||||
```
|
||||
----------------------------------
|
||||
### 函数
|
||||
<p id="object_default_t_methods">
|
||||
|
@ -24,6 +24,8 @@
|
||||
| <a href="#path_t_path_is_abs">path\_is\_abs</a> | 判断路径是否为绝对路径。 |
|
||||
| <a href="#path_t_path_normalize">path\_normalize</a> | 规范路径字符形式。 |
|
||||
| <a href="#path_t_path_prepend_app_root">path\_prepend\_app\_root</a> | 将前面路径加上app root。 |
|
||||
| <a href="#path_t_path_prepend_temp_path">path\_prepend\_temp\_path</a> | 将前面路径加上临时文件目录。 |
|
||||
| <a href="#path_t_path_prepend_user_storage_path">path\_prepend\_user\_storage\_path</a> | 将前面路径加上用户目录。 |
|
||||
| <a href="#path_t_path_remove_last_slash">path\_remove\_last\_slash</a> | 去掉后面的/和\\字符。 |
|
||||
| <a href="#path_t_path_replace_basename">path\_replace\_basename</a> | 替换文件名。 |
|
||||
| <a href="#path_t_path_replace_extname">path\_replace\_extname</a> | 替换文件扩展名。 |
|
||||
@ -372,6 +374,46 @@ const char* path_prepend_app_root (char* full_path, const char* path);
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | const char* | 返回完整路径。 |
|
||||
| full\_path | char* | 用于返回完整路径。 |
|
||||
| path | const char* | 路径。 |
|
||||
#### path\_prepend\_temp\_path 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="path_t_path_prepend_temp_path">将前面路径加上临时文件目录。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
const char* path_prepend_temp_path (char* full_path, const char* path);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | const char* | 返回完整路径。 |
|
||||
| full\_path | char* | 用于返回完整路径。 |
|
||||
| path | const char* | 路径。 |
|
||||
#### path\_prepend\_user\_storage\_path 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="path_t_path_prepend_user_storage_path">将前面路径加上用户目录。
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
const char* path_prepend_user_storage_path (char* full_path, const char* path);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | const char* | 返回完整路径。 |
|
||||
|
@ -32,6 +32,57 @@ BEGIN_C_DECLS
|
||||
* @parent tk_object_t
|
||||
* @annotation["fake"]
|
||||
* 将cvs file包装成object对象。
|
||||
*
|
||||
* 示例
|
||||
*
|
||||
* ```c
|
||||
* char filename[MAX_PATH + 1] = {0};
|
||||
* path_prepend_temp_path(filename, "test.csv");
|
||||
*
|
||||
* const char *csv_data1 = "name,age,weight\n"
|
||||
* "awplc,18,60.5\n";
|
||||
* ENSURE(file_write(filename, csv_data1, strlen(csv_data1)) == RET_OK);
|
||||
*
|
||||
* // 从文件加载
|
||||
* tk_object_t *csv = csv_file_object_load(filename, ',');
|
||||
*
|
||||
* // 获取数据: 通过属性名
|
||||
* ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].name"), "awplc"));
|
||||
* ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 18);
|
||||
* ENSURE(tk_object_get_prop_double(csv, "[1].weight", 0) == 60.5);
|
||||
*
|
||||
* // 获取数据: 通过属性索引
|
||||
* ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].0"), "awplc"));
|
||||
* ENSURE(tk_object_get_prop_int(csv, "[1].1", 0) == 18);
|
||||
* ENSURE(tk_object_get_prop_double(csv, "[1].2", 0) == 60.5);
|
||||
*
|
||||
* // 销毁对象
|
||||
* TK_OBJECT_UNREF(csv);
|
||||
*
|
||||
* // 从内存加载
|
||||
* csv = csv_file_object_load_from_buff(csv_data1, strlen(csv_data1), ',');
|
||||
*
|
||||
* // 获取数据: 通过属性名
|
||||
* ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].name"), "awplc"));
|
||||
* ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 18);
|
||||
* ENSURE(tk_object_get_prop_double(csv, "[1].weight", 0) == 60.5);
|
||||
*
|
||||
* // 获取数据: 通过属性索引
|
||||
* ENSURE(tk_str_eq(tk_object_get_prop_str(csv, "[1].0"), "awplc"));
|
||||
* ENSURE(tk_object_get_prop_int(csv, "[1].1", 0) == 18);
|
||||
* ENSURE(tk_object_get_prop_double(csv, "[1].2", 0) == 60.5);
|
||||
*
|
||||
* // 设置数据
|
||||
* ENSURE(tk_object_set_prop_int(csv, "[1].age", 20) == RET_OK);
|
||||
* ENSURE(tk_object_get_prop_int(csv, "[1].age", 0) == 20);
|
||||
*
|
||||
* // 保存到文件
|
||||
* ENSURE(csv_file_object_save_as(csv, filename) == RET_OK);
|
||||
* ENSURE(file_exist(filename) == TRUE);
|
||||
*
|
||||
* // 销毁对象
|
||||
* TK_OBJECT_UNREF(csv);
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user