本文整理汇总了C++中DataTable类的典型用法代码示例。如果您正苦于以下问题:C++ DataTable类的具体用法?C++ DataTable怎么用?C++ DataTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadVariables
void HM_LC_SWX_FM::loadVariables()
{
try
{
HomeMaticDevice::loadVariables();
_databaseMutex.lock();
DataTable rows = GD::db.executeCommand("SELECT * FROM deviceVariables WHERE deviceID=" + std::to_string(_deviceID));
for(DataTable::iterator row = rows.begin(); row != rows.end(); ++row)
{
_variableDatabaseIDs[row->second.at(2)->intValue] = row->second.at(0)->intValue;
switch(row->second.at(2)->intValue)
{
case 1000:
_channelCount = row->second.at(3)->intValue;
break;
case 1001:
unserializeStates(row->second.at(5)->binaryValue);
break;
}
}
}
catch(const std::exception& ex)
{
Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(Exception& ex)
{
Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
Output::printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
_databaseMutex.unlock();
}
示例2: init
void IDbResult::init(DataTable &table)
{
uint32 count = columns();
table.setColumns(count);
for(uint32 i = 0; i < count; i++)
table.setColumnName(i, columnName(i));
}
示例3: migrateAccounts
void CompatibilityManager::migrateAccounts(const shared_ptr<IPortalDatabase> &database)
{
shared_ptr<IDbConnection> globalConnection = Engine::instance()->createSystemConnection();
DataTable result;
String sql = _S("select * from os_accounts");
database->execute(sql,result);
for(uint32 r=0;r<result.rows();r++)
{
String id = result.get(r,_S("id"));
shared_ptr<DataAccount> dataAccount(OS_NEW DataAccount());
dataAccount->read(result[r]);
dataAccount->description = _S("Imported from portal '") + database->getPortal()->getName();
String sql = String::format(_S("select count(*) from os_accounts where id='%S'").c_str(), id.c_str());
int nRecordExists = globalConnection->value_of(sql);
bool alreadyExists = (nRecordExists>0);
DbSqlValues values;
dataAccount->write(values);
if(alreadyExists)
globalConnection->executeStatement(globalConnection->prepare_update(DBTABLES::ACCOUNTS_TABLE, values, DBTABLES::ACCOUNTS::ID, Convert::toSQL(dataAccount->id)), values);
else
globalConnection->executeStatement(globalConnection->prepare_insert(DBTABLES::ACCOUNTS_TABLE, values), values);
}
}
示例4: atan
void Michalewicz::runProblem()
{
double pi = atan(1)*4;
std::vector<VariablePtr> vars = {
std::make_shared<Variable>(0, 0, pi),
std::make_shared<Variable>(0, 0, pi),
std::make_shared<Variable>(1)
};
// Set starting points
vars.at(0)->setValue(1.0);
vars.at(1)->setValue(1.0);
DataTable data;
double dx = 0.05;
for (double x1 = 0; x1 <= pi; x1+=dx)
{
for (double x2 = 0; x2 <= pi; x2+=dx)
{
std::vector<double> x = {x1, x2};
DenseVector xd(2); xd << x1, x2;
DenseVector yd = michalewiczFunction(xd);
data.addSample(x,yd(0));
}
}
// Test accuracy of B-spline
// DenseVector (*foo)(DenseVector);
// foo = &michalewiczFunction;
// BSpline* bs = new BSpline(*data, 3);
// bool testpassed = bs->testBspline(foo);
// if (testpassed)
// {
// cout << "B-spline is very accurate:)" << endl;
// }
// else
// {
// cout << "B-spline is NOT very accurate:(" << endl;
// }
BSpline bs(data, BSplineType::CUBIC);
auto constraint = std::make_shared<ConstraintBSpline>(vars, bs, false);
//SolverIpopt solver(constraint);
BB::BranchAndBound solver(constraint);
// Optimize
SolverResult result = solver.optimize();
cout << result << endl;
fopt_found = result.objectiveValue;
zopt_found = result.primalVariables;
cout << zopt_found << endl;
}
示例5: atan
void Michalewicz::runProblem()
{
double pi = atan(1)*4;
std::vector<VariablePtr> vars = {
std::make_shared<Variable>(0, 0, pi),
std::make_shared<Variable>(0, 0, pi),
std::make_shared<Variable>(1)
};
// Set starting points
vars.at(0)->setValue(1.0);
vars.at(1)->setValue(1.0);
DataTable data;
unsigned int nums = 10; // 60x60 yields is sufficient to model function around optimum
auto x1 = linspace(0, 4, nums);
auto x2 = linspace(0, 4, nums);
for (auto x1i : x1)
{
for (auto x2i : x2)
{
DenseVector xd(2); xd << x1i, x2i;
double yd = michalewiczFunction(xd);
data.addSample(xd, yd);
}
}
// Test accuracy of B-spline
// DenseVector (*foo)(DenseVector);
// foo = &michalewiczFunction;
// BSpline* bs = new BSpline(*data, 3);
// bool testpassed = bs->testBspline(foo);
// if (testpassed)
// {
// cout << "B-spline is very accurate:)" << endl;
// }
// else
// {
// cout << "B-spline is NOT very accurate:(" << endl;
// }
BSpline bs = BSpline::Builder(data).degree(3).build();
auto constraint = std::make_shared<ConstraintBSpline>(vars, bs, false);
//SolverIpopt solver(constraint);
BB::BranchAndBound solver(constraint);
// Optimize
SolverResult result = solver.optimize();
cout << result << endl;
fopt_found = result.objectiveValue;
zopt_found = result.primalVariables;
cout << zopt_found << endl;
}
示例6: WARNING
void SocialsManager::load (const std::string & filename)
{
Iff iff;
if (!iff.open (filename.c_str (), true))
WARNING (true, ("Data file %s not available.", filename.c_str ()));
else
{
DataTable dt;
dt.load (iff);
iff.close ();
const int numRows = dt.getNumRows ();
uint32 count = 0;
for (int i = 0; i < numRows; ++i)
{
const std::string & name = Unicode::toLower (dt.getStringValue (DC_name, i));
++count;
s_idToNameMap.insert (std::make_pair (count, name));
s_crcToNameMap.insert (std::make_pair (Crc::calculate(name.c_str()), name));
const std::pair<StringIntMap::const_iterator, bool> retval = s_nameToIdMap.insert (std::make_pair (name, count));
if (!retval.second)
WARNING_STRICT_FATAL (true, ("SocialsManager file '%s' duplicate social type '%s'", filename.c_str (), name.c_str ()));
}
}
}
示例7: FATAL
void SetupSharedUtility::installFileManifestEntries ()
{
// read in the datatable entries for sharedFile/FileManifest.cpp
std::string datatableName = FileManifest::getDatatableName();
FATAL(!TreeFile::exists(datatableName.c_str()), ("%s could not be found. Are your paths set up correctly?", datatableName.c_str()));
DataTable * manifestDatatable = DataTableManager::getTable(datatableName, true);
if (manifestDatatable)
{
int numRows = manifestDatatable->getNumRows();
for (int i = 0; i < numRows; ++i)
{
std::string fileName = manifestDatatable->getStringValue("fileName", i);
std::string sceneId = manifestDatatable->getStringValue("sceneId", i);
int fileSize = manifestDatatable->getIntValue("fileSize", i);
if (!fileName.empty())
FileManifest::addStoredManifestEntry(fileName.c_str(), sceneId.c_str(), fileSize);
else
DEBUG_WARNING(true, ("SetupSharedUtility::installFileManifestEntries(): found an entry with a null filename: (row %i)\n", i));
}
}
else
DEBUG_WARNING(true, ("SetupSharedUtility::installFileManifestEntries(): can't find %s\n", datatableName.c_str()));
DataTableManager::close(datatableName);
}
示例8: DEBUG_FATAL
// ----------------------------------------------------------------------
void Squad::install()
{
DEBUG_FATAL(s_installed, ("Already installed"));
// Create the data table
Iff iff;
if (iff.open("datatables/space_mobile/space_mobile.iff", true))
{
DataTable dataTable;
dataTable.load(iff);
int const rowCount = dataTable.getNumRows();
for (int row = 0; row < rowCount; ++row)
{
PersistentCrcString const shipName(dataTable.getStringValue("strIndex", row), false);
int const formationPriority = dataTable.getIntValue("formationPriority", row);
IGNORE_RETURN(s_formationPriorityList.insert(std::make_pair(shipName, formationPriority)));
LOGC((ConfigServerGame::isSpaceAiLoggingEnabled() && formationPriority <= 0), "space_debug_ai", ("Squad::install() ERROR: Invalid formationPriority(%d) specified for shipName(%s)", formationPriority, shipName.getString()));
}
}
else
{
DEBUG_WARNING(true, ("Unable to load space_mobile.iff to retrieve formation priorities!"));
}
ExitChain::add(&remove, "Squad::remove");
s_installed = true;
}
示例9: queryValue
DataItem IDbConnection::queryValue(const String &sql)
{
DataItem value;
DataTable result;
if(query(sql, result))
if(result.rows() > 0 && result.columns() > 0)
value = *result[0][0];
return value;
}
示例10: compareDataTables
bool compareDataTables(DataTable &a, DataTable &b)
{
if (a.getNumVariables() != b.getNumVariables())
return false;
auto ait = a.cbegin(), bit = b.cbegin();
for (; ait != a.cend() && bit != b.cend(); ait++, bit++)
{
for (unsigned int i = 0; i < a.getNumVariables(); i++)
{
// std::cout << std::setprecision(SAVE_DOUBLE_PRECISION) << ait->getX().at(i) << " == " << std::setprecision(SAVE_DOUBLE_PRECISION) << bit->getX().at(i) << " ";
if (!equalsWithinRange(ait->getX().at(i), bit->getX().at(i)))
return false;
}
// std::cout << std::setprecision(SAVE_DOUBLE_PRECISION) << ait->getY().at(j) << " == " << std::setprecision(SAVE_DOUBLE_PRECISION) << bit->getY().at(j) << " ";
if (!equalsWithinRange(ait->getY(), bit->getY()))
return false;
// std::cout << std::endl;
}
// std::cout << "Finished comparing samples..." << std::endl;
return ait == a.cend() && bit == b.cend();
}
示例11: value_of
uint32 IDbConnection::value_of(const String &sql) // TOCLEAN, rimpiazzare con la queryValue
{
DataTable result;
if(query(sql, result) == false)
return false;
uint32 value = 0;
if(result.rows() > 0 && result.columns() > 0)
value = *result[0][0];
return value;
}
示例12: getWeaponReloadTimeSeconds
float CombatTimingTable::getWeaponReloadTimeSeconds(std::string const & weaponType)
{
float result = 0;
DataTable * combatTimingTable = DataTableManager::getTable(cs_combatTimingTableName, true);
if (combatTimingTable)
{
int rowNum = combatTimingTable->searchColumnString(0, weaponType);
result = combatTimingTable->getFloatValue("WeaponReloadTimeSeconds", rowNum);
}
return result;
}
示例13: isContinuous
bool CombatTimingTable::isContinuous(std::string const & weaponType)
{
bool result = false;
DataTable * combatTimingTable = DataTableManager::getTable(cs_combatTimingTableName, true);
if (combatTimingTable)
{
int rowNum = combatTimingTable->searchColumnString(0, weaponType);
result = combatTimingTable->getIntValue("Continuous", rowNum) ? true : false;
}
return result;
}
示例14:
const char *CombatTimingTable::getWeaponReloadClientAnimation(std::string const & weaponType)
{
const char * result = 0;
DataTable * combatTimingTable = DataTableManager::getTable(cs_combatTimingTableName, true);
if (combatTimingTable)
{
int rowNum = combatTimingTable->searchColumnString(0, weaponType);
result = combatTimingTable->getStringValue("WeaponReloadClientAnimation", rowNum);
}
return result;
}
示例15: getMaximumShotsTillWeaponReload
int CombatTimingTable::getMaximumShotsTillWeaponReload(std::string const & weaponType)
{
int result = 0;
DataTable * combatTimingTable = DataTableManager::getTable(cs_combatTimingTableName, true);
if (combatTimingTable)
{
int rowNum = combatTimingTable->searchColumnString(0, weaponType);
result = combatTimingTable->getIntValue("MaximumShotsTillWeaponReload", rowNum);
}
return result;
}