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


C++ CharacterVector::push_front方法代码示例

本文整理汇总了C++中rcpp::CharacterVector::push_front方法的典型用法代码示例。如果您正苦于以下问题:C++ CharacterVector::push_front方法的具体用法?C++ CharacterVector::push_front怎么用?C++ CharacterVector::push_front使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcpp::CharacterVector的用法示例。


在下文中一共展示了CharacterVector::push_front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RXMLAExecute

RcppExport SEXP RXMLAExecute(SEXP handle, SEXP query, SEXP rPropertiesString)
{
	XmlaWebServiceSoapProxy service = XmlaWebServiceSoapProxy(SOAP_XML_DEFAULTNS, SOAP_XML_DEFAULTNS);

	Rcpp::XPtr<XMLAHandle> ptr(handle);
	const char *connectionString = ptr->connectionString;
	std::string propertiesString = CHAR(STRING_ELT(rPropertiesString,0));

	ns1__Session session;
	std::string sessionId = ptr->sessionID;
	session.SessionId = &sessionId;
	service.soap_header(NULL, NULL, &session, NULL);

	_ns1__Execute execute;
	ns1__CommandStatement command;
	ns1__Properties properties;
	ns1__PropertyList propertyList;
	_ns1__ExecuteResponse response;

	std::string statement = CHAR(STRING_ELT(query,0));
	command.Statement = &statement;
	execute.Command = &command;
	execute.Properties = &properties;
	properties.PropertyList = &propertyList;
	if (!propertiesString.empty()) {
		parseKeyValuePairs(&propertiesString, propertyList.__any);
	}
	service.userid = ptr->userName;
	service.passwd = ptr->password;

	if (service.Execute(connectionString, NULL, &execute, &response) == SOAP_OK) {
		// Parse MDDataSet
		if (response.return_->ns4__root != NULL && response.return_->ns4__root->__union_ResultXmlRoot != NULL && response.return_->ns4__root->__union_ResultXmlRoot->Axes != NULL) {
			if (response.return_->ns4__root->__union_ResultXmlRoot->Axes->Axis.size() < 3) {
				std::cerr << "Error: No data on Axis1" << std::endl;
				return Rcpp::wrap(false);
			}
			if (response.return_->ns4__root->__union_ResultXmlRoot->Axes->Axis.size() > 3) {
				std::cerr << "Error: More than 2 axes not supported" << std::endl;
				return Rcpp::wrap(false);
			}

			ns4__Axes *axes = response.return_->ns4__root->__union_ResultXmlRoot->Axes;
			std::vector<ns4__Cell *> cellDataVector = response.return_->ns4__root->__union_ResultXmlRoot->CellData->Cell;
			int numCols = response.return_->ns4__root->__union_ResultXmlRoot->Axes->Axis[0]->__union_Axis->Tuples->Tuple.size();
			int numRows = response.return_->ns4__root->__union_ResultXmlRoot->Axes->Axis[1]->__union_Axis->Tuples->Tuple.size();
			int cellDataVectorMember = 0;

			Rcpp::CharacterVector colNames;
			Rcpp::CharacterVector rowNames;
			Rcpp::NumericMatrix resultMatrix(numRows, numCols);

			for (int row = 0; row < numRows; row++)	{
				for (int col = 0; col < numCols; col++)	{
					if (cellDataVector[cellDataVectorMember]->CellOrdinal == ((row * numCols) + col)) {
						resultMatrix(row, col) = *cellDataVector[cellDataVectorMember]->Value;
						if (cellDataVectorMember < cellDataVector.size() - 1) {
							cellDataVectorMember += 1;
						}
					}
					else {
						resultMatrix(row, col) = NA_REAL;
					}
				}
				mdDataSetGetNames(rowNames, axes, row, true);
			}

			for (int col = 0; col < numCols; col++)	{
				mdDataSetGetNames(colNames, axes, col, false);
			}

			colNames.push_front("Row Names");
			Rcpp::DataFrame resultDataFrame(resultMatrix);
			resultDataFrame.push_front(rowNames);
			resultDataFrame.attr("names") = colNames;
			service.destroy();
			return resultDataFrame;
		}
		// Parse RowSet
		else if (response.return_->ns2__root != NULL 
			&& response.return_->ns2__root->xsd__schema != NULL 
			&& response.return_->ns2__root->__union_ResultXmlRoot != NULL 
			&& !response.return_->ns2__root->__union_ResultXmlRoot->row.empty()) {

				std::string rawXML = "<root xmlns=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><xsd:schema targetNamespace=\"urn:schemas-microsoft-com:xml-analysis:rowset\" xmlns:sql=\"urn:schemas-microsoft-com:xml-sql\" elementFormDefault=\"qualified\">";
				rawXML = rawXML + response.return_->ns2__root->xsd__schema + "</xsd:schema></root>";
				char *schema = strdup(rawXML.c_str());
				rapidxml::xml_document<> doc;
				doc.parse<0>(schema);

				// Find XML section containing column names
				rapidxml::xml_node<char> *rowNode = doc.first_node()->first_node()->first_node("xsd:complexType");
				while(rowNode != NULL && strcmp(rowNode->first_attribute("name")->value(), "row") != 0)	{
					rowNode = rowNode->next_sibling("xsd:complexType");
				}

				rapidxml::xml_node<char> *schemaElementNode = rowNode->first_node()->first_node();
				std::vector<char *> rows = response.return_->ns2__root->__union_ResultXmlRoot->row;
				Rcpp::DataFrame resultDataFrame;
				Rcpp::CharacterVector colNames;
//.........这里部分代码省略.........
开发者ID:norrislee,项目名称:ReX,代码行数:101,代码来源:ReX.cpp


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