本文整理汇总了C++中IObject::GetHeaders方法的典型用法代码示例。如果您正苦于以下问题:C++ IObject::GetHeaders方法的具体用法?C++ IObject::GetHeaders怎么用?C++ IObject::GetHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject::GetHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateTableData
std::string CCMSDIntegrator::GenerateTableData(std::string schema)
{
std::stringstream buffer;
std::string table;
std::string properties;
buffer << "USE "<< schema << ";" << std::endl ;
schema="`"+schema+"`";
std::vector<std::vector<IObjectPtr> *> & allobjects = IObject::GetAllObjects();
for(int j=0; j<allobjects.size(); j++)
{
std::vector<IObjectPtr> * objects = allobjects[j];
for(int k=0; k< objects->size(); k++)
{
IObject * apart = objects->at(k).get();
table=apart->GetClassname(); // "`Part`";
buffer << "INSERT INTO " << schema << "." << table << " VALUES (" ;
// '7060',-6,0,0,0,0
std::vector<std::string> fields = apart->GetHeaders();
for(int jj=0; jj< fields.size(); jj++)
{
std::string value = GetDDLValue(apart, jj, properties) ; //apart->GetValue(jj);
buffer << value;
if((jj+1)!=fields.size()) buffer << "," ;
}
buffer << ");" << std::endl;
}
}
buffer << std::endl << std::endl << properties;
return buffer.str();
}
示例2: GenerateSchema
std::string CCMSDIntegrator::GenerateSchema(std::string schema)
{
std::stringstream buffer;
std::string table;
buffer << "CREATE SCHEMA IF NOT EXISTS `" << schema << "` DEFAULT CHARACTER SET latin1;" << std::endl;
buffer << "USE "<< schema << ";" << std::endl ;
schema="`"+schema+"`";
buffer << std::endl << std::endl ;
buffer << "DROP TABLE IF EXISTS " << schema << "." << "Properties" << ";" << std::endl;
buffer << "CREATE TABLE IF NOT EXISTS " << schema << "." << "Properties" << "(" << std::endl;
buffer << "identifier CHAR(255) NOT NULL,";
buffer << "name CHAR(255) NOT NULL DEFAULT '',";
buffer << "value NOT NULL DEFAULT '', ";
buffer << "units CHAR(255) NULL DEFAULT '',";
buffer << "description NULL DEFAULT '',";
buffer << std::endl << "PRIMARY KEY (`identifier`)" << std::endl;
buffer << ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" << std::endl;
std::vector<IObject::CreatorFcn> & creators = IObject::GetAllCreators();
for(int j=0; j< creators.size(); j++)
{
IObject::CreatorFcn fcn = creators[j];
//Part * apart = (Part*) new Part();
IObject * apart = fcn();
table=apart->GetClassname(); // "`Part`";
buffer << std::endl << std::endl;
buffer << "-- -----------------------------------------------------" << std::endl;
buffer << "-- Table " << schema << "." << table << std::endl;
buffer << "-- -----------------------------------------------------" << std::endl;
buffer << "DROP TABLE IF EXISTS "<< schema << "." << table << ";" << std::endl;
buffer << "CREATE TABLE IF NOT EXISTS "<< schema << "." << table << "(" << std::endl;
std::vector<std::string> fields = apart->GetHeaders();
for(int i=0; i< fields.size(); i++)
{
MetaType type = apart->GetType(i);
std::string field = fields[i];
ReplaceAll(field,".", "_");
buffer << "`" << field << "` " << GetDDLType(type ) << " " ;
buffer << (( fields[i]=="identifier")? "NOT NULL " : "NULL ");
buffer << GetDDLDefault(type );
if((i+1)!=fields.size()) buffer << ", " << std::endl;
}
if(std::find(fields.begin(), fields.end(), "identifier")!=fields.end())
buffer << ", " << std::endl << "PRIMARY KEY (`identifier`)" << std::endl;
buffer << ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" << std::endl;
}
return buffer.str();
}