本文整理汇总了C++中DataTable::getColumnName方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTable::getColumnName方法的具体用法?C++ DataTable::getColumnName怎么用?C++ DataTable::getColumnName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTable
的用法示例。
在下文中一共展示了DataTable::getColumnName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFromStream
void RewardMappingTools::readFromStream(istream& in, ProbabilisticRewardMapping& rewards)
throw (IOException)
{
try
{
DataTable* data = DataTable::read(in, "\t", true, -1);
vector<string> ids = data->getColumn(0);
data->deleteColumn(0); // Remove ids
data->deleteColumn(0); // Remove means
// Now parse the table:
size_t nbSites = data->getNumberOfColumns();
rewards.setNumberOfSites(nbSites);
size_t nbBranches = data->getNumberOfRows();
for (size_t i = 0; i < nbBranches; i++)
{
int id = TextTools::toInt(ids[i]);
size_t br = rewards.getNodeIndex(id);
for (size_t j = 0; j < nbSites; j++)
{
rewards(br, j) = TextTools::toDouble((*data)(i, j));
}
}
// Parse the header:
for (size_t i = 0; i < nbSites; i++)
{
string siteTxt = data->getColumnName(i);
int site = 0;
if (siteTxt.substr(0, 4) == "Site")
site = TextTools::to<int>(siteTxt.substr(4));
else
site = TextTools::to<int>(siteTxt);
rewards.setSitePosition(i, site);
}
delete data;
}
catch (Exception& e)
{
throw IOException(string("Bad input file. ") + e.what());
}
}
示例2: onPreRender
void IdeTableQuery::onPreRender()
{
ControlBase::onPreRender();
shared_ptr<XMLDocument> document = getDocument();
shared_ptr<XMLNode> node_root = document->create(_S("table_query"));
DataTable result;
if(getPage()->getDatabase()->execute(m_sql,result))
{
shared_ptr<XMLNode> node_header = node_root->addChild(_S("header"));
for(uint32 c = 0; c < result.columns(); c++)
{
String columnTitle = getColumnTitle(c);
if(columnTitle.empty())
columnTitle = result.getColumnName(c);
shared_ptr<XMLNode> node_column = node_header->addChild(_S("column"));
node_column->setAttributeString(_S("name"), columnTitle);
switch(getColumnType(c))
{
case IdeTableQuery::ctString:
{
node_column->setAttributeString(_S("type"), _S("string"));
} break;
case IdeTableQuery::ctScore:
{
node_column->setAttributeString(_S("type"), _S("score"));
} break;
case IdeTableQuery::ctEntityID:
{
node_column->setAttributeString(_S("type"), _S("entity-id"));
} break;
case IdeTableQuery::ctObjectID:
{
node_column->setAttributeString(_S("type"), _S("object-id"));
} break;
case IdeTableQuery::ctUserID:
{
node_column->setAttributeString(_S("type"), _S("user-id"));
} break;
case IdeTableQuery::ctShortDateTime:
{
node_column->setAttributeString(_S("type"), _S("short-datetime"));
} break;
case IdeTableQuery::ctLongDateTime:
{
node_column->setAttributeString(_S("type"), _S("long-datetime"));
} break;
}
}
shared_ptr<XMLNode> node_data = node_root->addChild(_S("data"));
for(uint32 r=0;r<result.rows();r++)
{
shared_ptr<XMLNode> node_data_row = node_data->addChild(_S("row"));
for(uint32 c=0;c<result.columns();c++)
{
shared_ptr<XMLNode> node_data_row_item = node_data_row->addChild(_S("item"));
String value = result.get(r,c);
switch(getColumnType(c))
{
case IdeTableQuery::ctScore:
{
node_data_row_item->setAttributeString(_S("value"), String::format(_S("%1.1f").c_str(), double(result.get(r,c))));
} break;
case IdeTableQuery::ctEntityID:
{
// Sbagliata
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
} break;
case IdeTableQuery::ctObjectID:
{
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
} break;
case IdeTableQuery::ctUserID:
{
shared_ptr<XMLPortalExporter> exporter(OS_NEW XMLPortalExporter(node_data_row_item, getPage(), XMLPortalExporter::emLite));
shared_ptr<ObjectsIObject> object = getPage()->getObject(value.to_ascii());
if(object != nullptr)
{
object->exportXML(exporter);
}
//.........这里部分代码省略.........