0
我正在開發Raskberry Pi 3的嵌入式應用程序,它將數據存儲在Metakit 2.4.9.7數據庫中。其中一個表由兩列組成(數據類型:double + string)。 double值存儲沒有任何問題,但是一旦我調用數據庫的Commit()方法,字符串值顯然會被丟棄。看到這個代碼:爲什麼Metakit在提交後不存儲字符串值?
#include <iostream>
#include <map>
#include <mk4.h>
#include "database.h"
using namespace std;
database::database (string file_name)
: connection_handler (file_name.c_str(), 1),
table_tracks (connection_handler.GetAs ("tracks [degrees:D, compass:S]"))
{
cout << "Opening database " << file_name << "." << endl;
if (table_tracks.GetSize() == 0) {
c4_DoubleProp degrees ("degrees");
c4_StringProp compass ("compass");
c4_Row track;
int i;
string compass_points [17] = {"N", "NNE", "NE", "ENE",
"E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW",
"W", "WNW", "NW", "NNW",
"N"};
cout << "Database is vanilla. Setting it up now." << endl;
for (i = 0; i <= 16; i++) {
degrees (track) = 22.5 * (double) i;
compass (track) = (compass_points [i]).c_str();
table_tracks.Add (track);
}
for (i = 0; i < table_tracks.GetSize(); i++) {
cout << (double) degrees (table_tracks [i]) << " " << (string) compass (table_tracks [i]) << endl;
}
connection_handler.Commit();
for (i = 0; i < table_tracks.GetSize(); i++) {
cout << (double) degrees (table_tracks [i]) << " " << (string) compass (table_tracks [i]) << endl;
}
}
}
第一個循環給了我先前充滿了數據的表的全部內容:#1列(雙)和#2(串),而第二循環運行後剛剛提交( )調用只會給出#1的內容,就像#2從未被填充一樣。
這裏有什麼問題?任何有用的提示非常感謝。