当前位置: 首页>>代码示例>>C++>>正文


C++ IObject::GetHeaders方法代码示例

本文整理汇总了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();
}
开发者ID:amanrenishaw,项目名称:MTConnectGadgets,代码行数:33,代码来源:ResourceIntegrator.cpp

示例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();
}
开发者ID:amanrenishaw,项目名称:MTConnectGadgets,代码行数:55,代码来源:ResourceIntegrator.cpp


注:本文中的IObject::GetHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。