当前位置: 首页 > news >正文

wordpress网站下方广东省自然资源厅8号文

wordpress网站下方,广东省自然资源厅8号文,wordpress新版编辑器使用教程,wordpress ctfC/C 中#define 的妙用#xff0c;让代码更美一些 flyfish 1 数值类型输出易读的字符串形式 例如使用enum定义一些错误值#xff0c;想要将数值类型的错误#xff0c;输出易读的字符串形式 重要的一句代码 #define MAKE_PAIR(val) std::make_pair(val, #val)可以看到 #va…C/C 中#define 的妙用让代码更美一些 flyfish 1 数值类型输出易读的字符串形式 例如使用enum定义一些错误值想要将数值类型的错误输出易读的字符串形式 重要的一句代码 #define MAKE_PAIR(val) std::make_pair(val, #val)可以看到 #val宏定义中的传入参数名val 转换成字符串就像用一对双引号包含起来的val 完整实现代码如下 #include iostream #include cinttypes #include string #include typeinfo #include utility #include vector using namespace std;typedef enum {ACAMERA_OK 0,ACAMERA_ERROR_BASE -10000,ACAMERA_ERROR_UNKNOWN ACAMERA_ERROR_BASE,ACAMERA_ERROR_INVALID_PARAMETER ACAMERA_ERROR_BASE - 1,ACAMERA_ERROR_CAMERA_DISCONNECTED ACAMERA_ERROR_BASE - 2,} camera_status_t;#define UKNOWN_TAG UNKNOW_TAG #define MAKE_PAIR(val) std::make_pair(val, #val) template typename T const char* GetPairStr(T key, std::vectorstd::pairT, const char* store) {typedef typename std::vectorstd::pairT, const char*::iterator iterator;for (iterator it store.begin(); it ! store.end(); it) {if (it-first key) {return it-second;}}//LOGW((%#08x) : UNKNOWN_TAG for %s, key, typeid(store[0].first).name());return UKNOWN_TAG; } using ERROR_PAIR std::paircamera_status_t, const char*; static std::vectorERROR_PAIR errorInfo{MAKE_PAIR(ACAMERA_OK),MAKE_PAIR(ACAMERA_ERROR_UNKNOWN),MAKE_PAIR(ACAMERA_ERROR_INVALID_PARAMETER),MAKE_PAIR(ACAMERA_ERROR_CAMERA_DISCONNECTED), }; const char* GetErrorStr(camera_status_t err) {return GetPairStrcamera_status_t(err, errorInfo); }int main() {std::coutGetErrorStr(ACAMERA_ERROR_INVALID_PARAMETER)std::endl;return 0; }输出 ACAMERA_ERROR_INVALID_PARAMETER2 易记的简化调用 例如有两个函数 camera_status_t ACameraManager_A() {std::coutAstd::endl;return ACAMERA_OK; }camera_status_t ACameraManager_B() {std::coutBstd::endl;return ACAMERA_OK; }这两个函数很长函数名前缀相同 想要易记的简化调用 例如 CALL_MGR(A()); //实际调用ACameraManager_A() CALL_MGR(B()); //实际调用ACameraManager_B()#define CALL_CAMERA(func) \{ \camera_status_t status func; \std::coutGetErrorStr(status)std::endl; \} #define CALL_MGR(func) CALL_CAMERA(ACameraManager_##func)#define 后面的 \ 表示下一行继续写宏定义。 两个#号 ## 表示连接操作符。 CALL_MGR(A());通过 ACameraManager_##func 变成了ACameraManager_A 实现完整代码如下 #include iostream #include cinttypes #include string #include typeinfo #include utility #include vector #include assert.h using namespace std;typedef enum {ACAMERA_OK 0,ACAMERA_ERROR_BASE -10000,ACAMERA_ERROR_UNKNOWN ACAMERA_ERROR_BASE,ACAMERA_ERROR_INVALID_PARAMETER ACAMERA_ERROR_BASE - 1,ACAMERA_ERROR_CAMERA_DISCONNECTED ACAMERA_ERROR_BASE - 2,} camera_status_t;#define UKNOWN_TAG UNKNOW_TAG #define MAKE_PAIR(val) std::make_pair(val, #val) template typename T const char* GetPairStr(T key, std::vectorstd::pairT, const char* store) {typedef typename std::vectorstd::pairT, const char*::iterator iterator;for (iterator it store.begin(); it ! store.end(); it) {if (it-first key) {return it-second;}}//LOGW((%#08x) : UNKNOWN_TAG for %s, key, typeid(store[0].first).name());return UKNOWN_TAG; } using ERROR_PAIR std::paircamera_status_t, const char*; static std::vectorERROR_PAIR errorInfo{MAKE_PAIR(ACAMERA_OK),MAKE_PAIR(ACAMERA_ERROR_UNKNOWN),MAKE_PAIR(ACAMERA_ERROR_INVALID_PARAMETER),MAKE_PAIR(ACAMERA_ERROR_CAMERA_DISCONNECTED), }; const char* GetErrorStr(camera_status_t err) {return GetPairStrcamera_status_t(err, errorInfo); }camera_status_t ACameraManager_A() {std::coutAstd::endl;return ACAMERA_OK; } camera_status_t ACameraManager_B() {std::coutBstd::endl;return ACAMERA_OK; } #define CALL_CAMERA(func) \{ \camera_status_t status func; \std::coutGetErrorStr(status)std::endl; \} #define CALL_MGR(func) CALL_CAMERA(ACameraManager_##func) int main() {CALL_MGR(A());CALL_MGR(B());return 0; }输出 A ACAMERA_OK B ACAMERA_OK以上代码应用在google的ndk camera代码中
http://www.w-s-a.com/news/236614/

相关文章:

  • 2018新网站做外链app制作的网站
  • 外贸网站建设怎么建设pc网站做移动端适配
  • 做经销找厂家好的网站个人备案网站可以做电影站吗
  • 网站搭建怎么做网站建设培训哪家好
  • 学做美食的视频网站企业网站备案密码怎么找回
  • 销售产品做单页还是网站seo有哪些作用
  • 网站视觉规范南宁网站优化推广
  • 公司起名打分最准的免费网站学设计的学校
  • 用cn作网站行么WordPress网站打不开nginx
  • 顺德龙江网站建设百货商城自助下单网站
  • 门户网站采用较多的模式是wordpress自动搜索缩略图
  • 深圳设计功能网站做网站推广怎么做
  • 海口专业网站建设地址wordpress站点标题是什么
  • 青岛做网站那家好网页素材网
  • 宁夏银川做网站的公司网络营销有哪些推广方法
  • 免费域名网站哪个最好东莞企业网站排名
  • dz做网站网址模版
  • 做外贸网站平台中华室内设计师网
  • 三大网络架构seo是啥职业
  • 一个域名可以做中英文两个网站吗搜索引擎营销的6种方式
  • 可以做ppt的网站天津网站建设怎么样
  • 网站怎么做的qq邮件订阅浙江省住房和城乡建设厅网站查询
  • 主机屋网站在线做图片
  • 河南省城乡住房建设厅网站wordpress登陆密码
  • 漳州做网站的公司搭建网站多少时间
  • 网站开发实习计划模板微营销手机
  • 网站设计与制作是做什么工作免费封面设计在线制作生成
  • 网站开发的教学课程网站广告调词软件
  • 进下加强新闻宣传网站建设入门 做网站 书籍
  • 电商网站主题photolux wordpress