-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_table.cpp
executable file
·128 lines (113 loc) · 3.68 KB
/
test_table.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Copyright (C) 2016, Íõ³¬ [wabcwang] , <[email protected]>.
* All Rights Reserved.
*/
#include <iostream>
#include "table.h"
int main ()
{
Table table;
for(int i=0;i <10;i++)
{
Row *row = new Row;
row->setValue("a",i);
row->setValue("b",i);
row->setValue("c",i);
row->setValue("d",i);
row->setValue("e",5.1);
table.addRow(row);
}
Row *row=table.getRow(0);
if(NULL != row)
{
std::cout<<"a:"<<row->getValue("a")<<" ";
std::cout<<"b:"<<row->getValue("b")<<" ";
std::cout<<"c:"<<row->getValue("c")<<" ";
std::cout<<"d:"<<row->getValue("d")<<" ";
std::cout<<"e:"<<row->getValue("e")<<" ";
std::cout<<std::endl;
}
int i =row->getInt("e");
std::cout<<"int-e:"<<i<<std::endl;
float f =row->getFloat("e");
std::cout<<"float-e:"<<f<<std::endl;
double d =row->getDouble("e");
std::cout<<"double-e:"<<d<<std::endl;
long l =row->getLong("e");
std::cout<<"long-e:"<<l<<std::endl;
table.deleteRow(2);
for(int i=0;i <table.size();i++)
{
row=table.getRow(i);
if(NULL != row)
{
std::cout<<"a:"<<row->getValue("a")<<" ";
std::cout<<"b:"<<row->getValue("b")<<" ";
std::cout<<"c:"<<row->getValue("c")<<" ";
std::cout<<"d:"<<row->getValue("d")<<" ";
std::cout<<"e:"<<row->getValue("e")<<" ";
std::cout<<std::endl;
}
}
row=table.pop_back();
std::cout<<"a:"<<row->getValue("a")<<" size:"<<table.size()<<std::endl;
delete row;
row=table.getRow(0);
std::cout<<"a:"<<row->getValue("a")<<std::endl;
table.deleteRow(4,6);
for(int i=0;i <table.size();i++)
{
row=table.getRow(i);
if(NULL != row)
{
std::cout<<"a:"<<row->getValue("a")<<" ";
std::cout<<"b:"<<row->getValue("b")<<" ";
std::cout<<"c:"<<row->getValue("c")<<" ";
std::cout<<"d:"<<row->getValue("d")<<" ";
std::cout<<"e:"<<row->getValue("e")<<" ";
std::cout<<std::endl;
}
}
char *s = (char*)"a b c d e f g\n"\
"1 ? 1 1 1 1 1\n"\
"2 2 2 2 2 2\n"\
"33 33 33 33 33 33 33 ?\n";
Table table_test(s);
for(int i=0;i <table_test.size();i++)
{
row=table_test.getRow(i);
if(NULL != row)
{
std::cout<<"a:"<<row->getValue("a")<<" ";
std::cout<<"b:"<<row->getValue("b")<<" ";
std::cout<<"c:"<<row->getValue("c")<<" ";
std::cout<<"d:"<<row->getValue("d")<<" ";
std::cout<<"e:"<<row->getValue("e")<<" ";
std::cout<<"f:"<<row->getValue("f")<<" ";
std::cout<<"g:"<<row->getValue("g")<<" ";
std::cout<<std::endl;
}
}
row = table_test.find("a", "2");
if(NULL != row)
{
std::cout<<"find: "<<row->getValue("a")<<std::endl;
}
/*Table test = table_test;
for(int i=0;i <test.size();i++)
{
row=test.getRow(i);
//if(NULL != row)
{
std::cout<<"a:"<<row->getValue("a")<<" ";
std::cout<<"b:"<<row->getValue("b")<<" ";
std::cout<<"c:"<<row->getValue("c")<<" ";
std::cout<<"d:"<<row->getValue("d")<<" ";
std::cout<<"e:"<<row->getValue("e")<<" ";
std::cout<<"f:"<<row->getValue("f")<<" ";
std::cout<<"g:"<<row->getValue("g")<<" ";
std::cout<<std::endl;
}
} */
return 0;
}