1 Star 0 Fork 1

reference/PracticeCode

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
param.cpp 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
亦狂亦侠_亦温文 提交于 2016-07-13 18:24 +08:00 . update
#include "param.h"
#include "enum.h"
std::string Any::ToString(){
if (GetType() == qualified_typeof(const char*)) return static_cast<_Holder<const char*>*>(value)->data;
auto t = GetType().RemoveCV();
#define TOSTR(T) if(t == qualified_typeof(T)) return std::to_string(static_cast<_Holder<T>*>(value)->data); \
if(t == qualified_typeof(T&)) return std::to_string(static_cast<_Holder<T&>*>(value)->data);
TOSTR(int8_t);
TOSTR(int16_t);
TOSTR(int32_t);
TOSTR(int64_t);
TOSTR(uint8_t);
TOSTR(uint16_t);
TOSTR(uint32_t);
TOSTR(uint64_t);
TOSTR(bool);
TOSTR(float);
TOSTR(double);
#undef TOSTR
if (t == qualified_typeof(char*)) return static_cast<_Holder<const char*>*>(value)->data;
if (t == qualified_typeof(std::string)) return static_cast<_Holder<std::string>*>(value)->data;
if (t == qualified_typeof(std::string&)) return static_cast<_Holder<std::string&>*>(value)->data;
if (t.GetType()->IsEnum()) return Enum::GetName(t.GetType(), static_cast<_Holder<int64_t>*>(value)->data);
return "(unknown)";
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/reference/PracticeCode.git
git@gitee.com:reference/PracticeCode.git
reference
PracticeCode
PracticeCode
master

搜索帮助