自定义生成IFC globalID的函数
自定义生成IFC globalID的函数
.h文件
#include <QChar> #include <cstdlib> #include <ctime> QString createGlobalID();
.cpp文件
QString createGlobalID() { QChar chars[36] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k','l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w','x', 'y', 'z','0','1','2','3','4','5','6','7','8','9' }; QString newGlobalID = ""; //srand((int)time(0)); srand((unsigned)time(NULL)); for (int k=0;k<11;++k) { int index_num = rand()% 36; newGlobalID.append(chars[index_num]); } return newGlobalID; }
测试
QString globalIDStr1 = createGlobalID(); QString globalIDStr2 = createGlobalID(); QString globalIDStr3 = createGlobalID();
输出结果
"d7wvembqeir" "j44h7s83hxj" "tldbj0dd8l7"
QQ 3087438119