Skip to content

Commit 50b37ee

Browse files
author
NickYang
committed
finish AFRecord(function AddRow)
1 parent 7e50d62 commit 50b37ee

File tree

2 files changed

+88
-10
lines changed

2 files changed

+88
-10
lines changed

Frame/SDK/Core/AFRecord.cpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,71 @@ int AFRecord::GetColType(int col) const
106106

107107
bool AFRecord::AddRow(size_t row)
108108
{
109-
//TODO
109+
size_t col_num = GetColCount();
110+
RowData* row_data = new RowData[col_num];
111+
if (row >= GetRowCount())
112+
{
113+
mxRowDatas.push_back(row_data);
114+
}
115+
else
116+
{
117+
mxRowDatas.insert(row, row_data);
118+
}
119+
110120
return true;
111121
}
112122

113123
bool AFRecord::AddRow(size_t row, const AFIDataList& data)
114124
{
115-
//TODO
125+
size_t col_num = GetColCount();
126+
if (data.GetCount() != col_num)
127+
{
128+
ARK_ASSERT(0, "data size is not equal with col_num, please check your arg.", __FILE__, __FUNCTION__);
129+
return false;
130+
}
131+
132+
RowData* row_data = new RowData[col_num];
133+
for (int i = 0; i < data.GetCount(); ++i)
134+
{
135+
int type = GetColType(i);
136+
switch (type)
137+
{
138+
case DT_BOOLEAN:
139+
row_data[i].SetBool(data.Bool(i));
140+
break;
141+
case DT_INT:
142+
row_data[i].SetInt(data.Int(i));
143+
break;
144+
case DT_INT64:
145+
row_data[i].SetInt64(data.Int64(i));
146+
break;
147+
case DT_FLOAT:
148+
row_data[i].SetFloat(data.Float(i));
149+
break;
150+
case DT_DOUBLE:
151+
row_data[i].SetDouble(data.Double(i));
152+
break;
153+
case DT_STRING:
154+
row_data[i].SetString(data.String(i));
155+
break;
156+
case DT_OBJECT:
157+
row_data[i].SetObject(data.Object(i));
158+
break;
159+
default:
160+
return false;
161+
break;
162+
}
163+
}
164+
165+
if (row >= GetRowCount())
166+
{
167+
mxRowDatas.push_back(row_data);
168+
}
169+
else
170+
{
171+
mxRowDatas.insert(row, row_data);
172+
}
173+
116174
return true;
117175
}
118176

Frame/SDK/Core/AFRecord.h

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "SDK/Base/AFCoreDef.hpp"
2626
#include "SDK/Base/AFString.hpp"
2727
#include "SDK/Base/AFCData.h"
28+
#include "SDK/Base/AFBitValue.hpp"
2829

2930
using namespace ArkFrame;
3031

@@ -51,7 +52,7 @@ class AFRecord
5152

5253
void SetColCount(size_t value);
5354
int GetColCount() const;
54-
55+
5556
bool SetColType(size_t index, int type);
5657
int GetColType(int col) const;
5758

@@ -61,7 +62,27 @@ class AFRecord
6162
bool DeleteRow(size_t row);
6263

6364
void Clear();
64-
65+
66+
bool IsPublic() const
67+
{
68+
return BitValue<int8_t>::HaveBitValue(feature, RF_PUBLIC);
69+
}
70+
71+
bool IsPrivate() const
72+
{
73+
return BitValue<int8_t>::HaveBitValue(feature, RF_PRIVATE);
74+
}
75+
76+
bool IsRealTime() const
77+
{
78+
return BitValue<int8_t>::HaveBitValue(feature, RF_REAL_TIME);
79+
}
80+
81+
bool IsSave() const
82+
{
83+
return BitValue<int8_t>::HaveBitValue(feature, RF_SAVE);
84+
}
85+
6586
bool SetValue(size_t row, size_t col, const AFIData& value);
6687
bool SetBool(size_t row, size_t col, const bool value);
6788
bool SetInt(size_t row, size_t col, const int value);
@@ -99,12 +120,11 @@ class AFRecord
99120

100121
protected:
101122

102-
RecordName mstrName; //record name
103-
int8_t feature; //record feature
104-
ArraryPod<int, 1, CoreAlloc> mxColTypes; //record type array
105-
ArraryPod<RowData*, 1, CoreAlloc> mxRowDatas; //record data array
123+
RecordName mstrName; //Record name
124+
int8_t feature; //Record feature
125+
ArraryPod<int, 1, CoreAlloc> mxColTypes; //Record column type array
126+
ArraryPod<RowData*, 1, CoreAlloc> mxRowDatas; //Record data array
106127

107-
//will be added
108-
//record cb
128+
//Record callbacks will be added
109129
};
110130

0 commit comments

Comments
 (0)