1 Star 0 Fork 344

seasky100 / awtk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
int_str_t.md 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
xianjimli 提交于 2019-12-14 13:25 . update docs

int_str_t

概述

数字-字符串类型。

负责把一个数字映射成一个字符串。

示例:

static const int_str_t color_values[] = {{1, "red"}, {2, "black"}, {3, "blue"}, {4, "white"}};
const char* value = int_str_value(color_values, 3);
int32_t name = int_str_name(color_values, "blue", 0);
printf("value = %s \n", value);
printf("name = %d \n", name);

函数

函数名称 说明
int_str_name 根据value获取对应的name。
int_str_value 根据name获取对应的value。

int_str_name 函数


  • 函数功能:

根据value获取对应的name。

  • 函数原型:
int32_t int_str_name (const int_str_t* items, const char* value, int32_t defval);
  • 参数说明:
参数 类型 说明
返回值 int32_t 返回name。
items const int_str_t* int_str_t数组。
value const char* value。
defval int32_t 如果没有找到对应的name,则返回的defval默认值。

int_str_value 函数


  • 函数功能:

根据name获取对应的value。

  • 函数原型:
const char* int_str_value (const int_str_t* items, int32_t name);
  • 参数说明:
参数 类型 说明
返回值 const char* 返回value。
items const int_str_t* int_str_t数组。
name int32_t name。
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/seasky100/awtk.git
git@gitee.com:seasky100/awtk.git
seasky100
awtk
awtk
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891