-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomm.cpp
More file actions
74 lines (68 loc) · 1.95 KB
/
comm.cpp
File metadata and controls
74 lines (68 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "comm.h"
#include <QDateTime>
#include <QRegExpValidator>
#include <QValidator>
#include <stdio.h>
void __print(char *info)
{
QString temp = QString(QLatin1String(info));
__print(temp);
}
void __print(QString info)
{
QString temp ="[";
QDateTime local(QDateTime::currentDateTime());
QString localTime = local.toString("yyyy-MM-dd:hh:mm:ss");
temp.append(localTime);
temp.append("] ");
temp.append(info);
qDebug()<<qPrintable(temp);
}
int separate_chess_type_name(char *type_name, Vector_Plural_node *node){
int res = 1;
QString str = QString(QLatin1String(type_name));
__print("检查的 type_name " + str);
QRegExp vectorRX("^(v(\\d+))?(c?)(u?)(int(\\d+))_t$");
int pos = str.indexOf(vectorRX);
// __print(QString::number(pos));
if (pos >= 0){
#ifdef DEBUG_PRINT
__print(vectorRX.cap(0));
__print(vectorRX.cap(1));
__print(vectorRX.cap(2));
__print(vectorRX.cap(3));
__print(vectorRX.cap(4));
__print(vectorRX.cap(5));
#endif
node->array_num = vectorRX.cap(1).isEmpty()? 1: vectorRX.cap(2).toInt();
node->is_plural = vectorRX.cap(3).isEmpty()? false: true;
if (vectorRX.cap(4).isEmpty()) sprintf(node->base_type_name, "%s", vectorRX.cap(5).toLatin1().data());
else sprintf(node->base_type_name, "unsigned %s", vectorRX.cap(5).toLatin1().data());
node->base_size = vectorRX.cap(6).toInt()/8;
res = 0;
}
return res;
}
//int which_type_size(int byte_size, char *type_name)
//{
// int res = 0;
// switch (byte_size) {
// case 1:
// strcpy(type_name, "int8");
// break;
// case 2:
// strcpy(type_name, "int16");
// break;
// case 4:
// strcpy(type_name, "int32");
// break;
// case 8:
// strcpy(type_name, "int64");
// break;
// default:
// strcpy(type_name, "unkown");
// res = -1;
// break;
// }
// return res;
//}