void ftof_volumes_xml(xml_document& doc, const ForwardTOF& ftof)
{
    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }
    xml_node dc_node = geom_node.child("forward_tof");
    if (!dc_node)
    {
        dc_node = geom_node.append_child("forward_tof");
    }
    xml_node vol_node = dc_node.child("volumes");
    if (!vol_node)
    {
        vol_node = dc_node.append_child("volumes");
    }

    for (auto k1 : ftof_volumes_map(ftof))
    {
        xml_node n1 = vol_node.append_child(k1.first.c_str());

        for (auto k2 : k1.second)
        {
            xml_node n2 = n1.append_child(k2.first.c_str());
            n2.append_child(node_pcdata).set_value(k2.second.c_str());
        }
    }
}
void dc_core_params_xml(xml_document& doc, const DriftChamber& dc, const string& units="cm")
{
    double lconv = length_conversion(units);

    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }

    xml_node dc_node = geom_node.child("drift_chamber");
    if (!dc_node)
    {
        dc_node = geom_node.append_child("drift_chamber");
    }

    xml_node params_node = dc_node.append_child("core_params");

    for (int nreg : vector<int>{0, 1, 2})
    {
        xml_node reg_node = params_node.append_child("region");
        reg_node.append_attribute("index") = nreg;

        for (int nslyr : vector<int>{0, 1})
        {
            xml_node slyr_node = reg_node.append_child("superlayer");
            slyr_node.append_attribute("index") = nslyr;

            slyr_node.append_attribute("wpdist") = dc.sector(0).region(nreg).superlayer(nslyr).wpdist() * lconv;
        }
    }
}
示例#3
0
文件: XmlParse.cpp 项目: ponlee/test
void XmlParse::AppendAttribute(const std::string &NewAttributeName, const std::string &NewAttributeValue,
                               xml_document<> &doc, xml_node<> *ParentNode)
{
    xml_attribute<> *attr = doc.allocate_attribute(doc.allocate_string(NewAttributeName.c_str()),
                            doc.allocate_string(NewAttributeValue.c_str()));
    if (ParentNode)
    {
        ParentNode->append_attribute(attr);
    }
}
示例#4
0
void workbook_serializer::read_properties_core(const xml_document &xml)
{
    auto &props = workbook_.get_properties();
    auto root_node = xml.get_child("cp:coreProperties");

    props.excel_base_date = calendar::windows_1900;

    if (root_node.has_child("dc:creator"))
    {
        props.creator = root_node.get_child("dc:creator").get_text();
    }
    if (root_node.has_child("cp:lastModifiedBy"))
    {
        props.last_modified_by = root_node.get_child("cp:lastModifiedBy").get_text();
    }
    if (root_node.has_child("dcterms:created"))
    {
        std::string created_string = root_node.get_child("dcterms:created").get_text();
        props.created = w3cdtf_to_datetime(created_string);
    }
    if (root_node.has_child("dcterms:modified"))
    {
        std::string modified_string = root_node.get_child("dcterms:modified").get_text();
        props.modified = w3cdtf_to_datetime(modified_string);
    }
}
示例#5
0
static void load_document_copy(xml_document& doc, const char_t* text)
{
	xml_document source;
	CHECK(source.load(text));

	doc.append_copy(source.first_child());
}
示例#6
0
void loadSRSML()
{

	cout << "parsing srsml..." << endl;


	// Read the xml file into a vector
	ifstream theFile ("gastrectomy.xml");
	vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
	buffer.push_back('\0');
	// Parse the buffer using the xml file parsing library into doc
	doc.parse<0>(&buffer[0]);
	// Find our root node
	cout << "parsing a root element" << endl;
	root_node = doc.first_node("srsml");

	int size = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
	int size2 = strlen((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());

	// variables for malloc
	elements=(char*) malloc(size+1);
	elements2=(char*) malloc(size2+1);

	strcpy ((char*)elements,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value()));
	strcpy ((char*)elements2,(char*)((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value()));

	// variables for string
	str_elements.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("name"))->value());
	str_elements2.assign((((root_node->first_node("models"))->first_node("vessels"))->first_attribute("type"))->value());

	// Iterate over the vessels
	if (root_node){
		cout << "if there is a root element" << endl;
		for (xml_node<> * models_node = root_node->first_node("models"); models_node!=NULL; models_node = models_node->next_sibling())
		{
			cout << "here is in the model for loop" << endl;
			for (xml_node<> * vessels_node = models_node->first_node("vessels"); vessels_node!=NULL; vessels_node = vessels_node->next_sibling())
			{
				cout << "here is in the vessels for loop" << endl;
				printf("I have visited in. ");//,
					// Interate over the beers
				cout << "here is before the inner for loop" << endl;
				for(xml_node<> * vessel_node = vessels_node->first_node("vessel"); vessel_node; vessel_node = vessel_node->next_sibling())
				{
					printf("On, I tried their %s which is a %s. ",
							vessel_node->first_attribute("name")->value(),
							vessel_node->first_attribute("type")->value());
				}
				cout << endl;
			}
		}
	}
}
void add_to_toc(int level, xml_node<char> *title, xml_attribute<char> *id, bool not_numbered)
{
    char *style_class;
    char *fulltitle = doc.allocate_string(0, title->value_size() + 100);
    if (level == 0)
    {
        style_class = "toc1";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i. %s", ++numbering[0], title->value());
            numbering[1] = 0;
            numbering[2] = 0;
        }
    }
    else if (level == 1)
    {
        style_class = "toc2";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i %s", numbering[0], ++numbering[1], title->value());
            numbering[2] = 0;
        }
    }
    else if (level == 2)
    {
        style_class = "toc3";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i.%i %s", numbering[0], numbering[1], ++numbering[2], title->value());
        }
    }
    else
        throw std::exception("Invalid TOC level");
    xml_node<char> *tocentry = doc.allocate_node(node_element, "a", fulltitle);
    char *link = doc.allocate_string(0, id->value_size() + 1);
    memcpy(link + 1, id->value(), id->value_size());
    link[0] = '#';
    tocentry->append_attribute(doc.allocate_attribute("href", link, 0, id->value_size() + 1));
    tocentry->append_attribute(doc.allocate_attribute("class", style_class));
    toc.append_node(tocentry);
    toc.append_node(doc.allocate_node(node_element, "br"));
    xml_node<char> *title_data = title->first_node();
    if (title_data)
        title->remove_node(title_data);
    title->value(fulltitle);
}
示例#8
0
XmlNodeRef XmlParserImp::parse(char* buffer, int bufLen, const char* rootNodeName, behaviac::string& errorString, bool isFinal)
{
    BEHAVIAC_UNUSED_VAR(bufLen);
    BEHAVIAC_UNUSED_VAR(errorString);
    BEHAVIAC_UNUSED_VAR(isFinal);

    m_parser.parse<0>(buffer);

    xml_node<>* xmlnode = m_parser.first_node(rootNodeName);

    XmlNodeRef node = cloneXmlNodeFrom(xmlnode);

    return node;
}
void osm_loader::load_bounds() 
{
    xml_node *root = doc_.first_node("osm");
    if (root == NULL)
        return;

    string str = root->first_node("bound")->first_attribute("box")->value();
    vector<string> strs;
    boost::split(strs, str, boost::is_any_of(","));

    mins.x = atof(strs[0].c_str());
    mins.y = atof(strs[1].c_str());
    maxs.x = atof(strs[2].c_str());
    maxs.y = atof(strs[3].c_str());
}
示例#10
0
void loadXML()
{

	cout << "Parsing my beer journal..." << endl;


	// Read the xml file into a vector
	cout << "before loading a xml file" << endl;
	ifstream theFile ("beerJournal.xml");
	cout << "after loading a xml file" << endl;
	vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
	buffer.push_back('\0');
	// Parse the buffer using the xml file parsing library into doc
	doc.parse<0>(&buffer[0]);
	// Find our root node
	cout << "before parsing a root element" << endl;
	root_node = doc.first_node("MyBeerJournal");
	// Iterate over the brewerys
//	elements = "sldfjlsdjfldsjfldsjflsdjflds";
	elements=(char*) malloc(strlen(((((root_node)->first_node("Brewery"))->first_attribute("name"))->value()))+1);

	strcpy ((char*)elements,(char*)(((root_node)->first_node("Brewery"))->first_attribute("name"))->value());
	elements[strlen(((((root_node)->first_node("Brewery"))->first_attribute("name"))->value()))]='\0';
//	elements = "char";
	printf("here is element:%s\n",elements);
	cout << "after parsing a root element" << endl;
	if (root_node){
		cout << "if there is a root element" << endl;
		for (xml_node<> * brewery_node = root_node->first_node("Brewery"); brewery_node!=NULL; brewery_node = brewery_node->next_sibling())
		{
			cout << "here is in the for loop" << endl;
			printf("I have visited %s in %s. ",
				brewery_node->first_attribute("name")->value(),
				brewery_node->first_attribute("location")->value());
				// Interate over the beers
			cout << "here is before the inner for loop" << endl;
			for(xml_node<> * beer_node = brewery_node->first_node("Beer"); beer_node; beer_node = beer_node->next_sibling())
			{
				printf("On %s, I tried their %s which is a %s. ",
					beer_node->first_attribute("dateSampled")->value(),
					beer_node->first_attribute("name")->value(),
					beer_node->first_attribute("description")->value());
				printf("I gave it the following review: %s", beer_node->value());
			}
			cout << endl;
		}
	}
}
示例#11
0
static xml_parse_result load_concat(xml_document& doc, const char_t* a, const char_t* b = STR(""), const char_t* c = STR(""))
{
	char_t buffer[768];

#ifdef PUGIXML_WCHAR_MODE
	wcscpy(buffer, a);
	wcscat(buffer, b);
	wcscat(buffer, c);
#else
	strcpy(buffer, a);
	strcat(buffer, b);
	strcat(buffer, c);
#endif

	return doc.load(buffer, parse_fragment);
}
void osm_loader::prepare_verts(unordered_set<xml_id> &verts_pending) 
{
    cout << "Preparing verts" << endl;
    
    xml_node *root = doc_.first_node("osm");
    if (root == NULL)
        return;

    size_t counter = 0;
    xml_node *node = root->first_node("node");
    while (node != NULL)
    {
        xml_id id = atol(node->first_attribute("id")->value());
        verts_pending.insert(id);
        node = node->next_sibling("node");
    }
}
void osm_loader::load_verts() 
{
    xml_node *root = doc_.first_node("osm");
    if (root == NULL)
        return;
    
    size_t counter = 0;
    xml_node *node = root->first_node("node");
    while (node != NULL)
    {
        if (counter >= MAX_VERTS)
            break;
        xml_id id = atol(node->first_attribute("id")->value());

        if (pgraph_->vertex_exists(id))
        {
            vis_coord coord (atof(node->first_attribute("lat")->value()),
                             atof(node->first_attribute("lon")->value()));

            
            vis_vertex &v = pgraph_->get_vertex(id);
            vis_vertex_data &ref_data = v.get_data();

            ref_data.c = coord;
            
            int degree = v.get_out_degree();
            if (degree >= degrees_stats_.size())
                degrees_stats_.resize(degree + 1, 0);
            ++degrees_stats_[degree];
            

            if (counter % 100000 == 0)
                cout << counter << " verts loaded" << endl;
            ++counter;
        }
        node = node->next_sibling("node");
    }

    update_edge_weights();

}
示例#14
0
bool RawInputParser::LoadXMLFile(xml_document& doc,const string& filePath) const
{
	xml_parse_result result = doc.load_file(filePath.c_str());

	bool returnResult = false;

	if (result)
	{
		LOG("XML [" << filePath << "] parsed without errors\n");
		returnResult = true;
	}
	else
	{
		LOG("XML [" << filePath << "] parsed with errors\n");
		LOG("Error description: " << result.description() << "\n");
		LOG("Error offset: " << result.offset << "\n");
		returnResult = false;
	}

	return returnResult;
}
void osm_loader::load_edges()
{
    unordered_set<xml_id> verts_pending;
    prepare_verts(verts_pending);

    cout << "Loading edges" << endl;

    xml_node *root = doc_.first_node("osm");
    if (root == NULL)
        return;

    xml_node *node = root->first_node("way");
    while (node != NULL)
    {
        if (pgraph_->v_count() >= MAX_VERTS)
            break;

        load_way (node, verts_pending);
        node = node->next_sibling("way");
    }

}
/// Initialize the XML DOM structure (leaving .desc unchanged) from the data.
void stream_info_impl::write_xml(xml_document &doc) {
	const char *channel_format_strings[] = {"undefined","float32","double64","string","int32","int16","int8","int64"};
	xml_node info = doc.append_child("info");
	info.append_child("name").append_child(node_pcdata).set_value(name_.c_str());
	info.append_child("type").append_child(node_pcdata).set_value(type_.c_str());
	info.append_child("channel_count").append_child(node_pcdata).set_value(lexical_cast<string>(channel_count_).c_str());
	info.append_child("nominal_srate").append_child(node_pcdata).set_value(lexical_cast<string>(nominal_srate_).c_str());
	info.append_child("channel_format").append_child(node_pcdata).set_value(channel_format_strings[channel_format_]);
	info.append_child("source_id").append_child(node_pcdata).set_value(source_id_.c_str());
	info.append_child("version").append_child(node_pcdata).set_value(lexical_cast<string>(version_/100.0).c_str());
	info.append_child("created_at").append_child(node_pcdata).set_value(lexical_cast<string>(created_at_).c_str());
	info.append_child("uid").append_child(node_pcdata).set_value(uid_.c_str());
	info.append_child("session_id").append_child(node_pcdata).set_value(session_id_.c_str());
	info.append_child("hostname").append_child(node_pcdata).set_value(hostname_.c_str());
	info.append_child("v4address").append_child(node_pcdata).set_value(v4address_.c_str());
	info.append_child("v4data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4data_port_).c_str());
	info.append_child("v4service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v4service_port_).c_str());
	info.append_child("v6address").append_child(node_pcdata).set_value(v6address_.c_str());
	info.append_child("v6data_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6data_port_).c_str());
	info.append_child("v6service_port").append_child(node_pcdata).set_value(lexical_cast<string>(v6service_port_).c_str());
	info.append_child("desc");
}
示例#17
0
   std::string path::toElementText( xml_document const& _doc )const {

      path key_no_attr = *this;

      if( key_no_attr.points_to_attr() ) {
         path_element& pel = key_no_attr.last();
         pel.attr( path_attr() );
      }// debug

      string pathadd = key_no_attr;

      if( pathadd == "domain.features.apic" ) {
         pathadd = key_no_attr;
      }

      element_locator locator( key_no_attr );

      _doc.accept( &locator );

      xml_element* elem = locator.elementfound();

      if( elem != nullptr ) {
         xml_node const* ch = elem->first_child();

         if( ch == nullptr ) {
            return "nullptr";
         }

         xml_text const* p1 = dynamic_cast<xml_text const*>( ch );
         string txt = p1->value();
         return txt;

      }


      return "";

   }
示例#18
0
bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std::vector<std::string> &strings)
{
    strings.clear();

    auto root_node = xml.get_child("sst");
    auto unique_count = 0;

    if (root_node.has_attribute("uniqueCount"))
    {
        unique_count = std::stoull(root_node.get_attribute("uniqueCount"));
    }

    for (const auto &si_node : root_node.get_children())
    {
        if (si_node.get_name() != "si")
        {
            continue;
        }

        if (si_node.has_child("t"))
        {
            strings.push_back(si_node.get_child("t").get_text());
        }
        else if (si_node.has_child("r"))
        {
            strings.push_back(si_node.get_child("r").get_child("t").get_text());
        }
    }

    if (unique_count != strings.size())
    {
        throw std::runtime_error("counts don't match");
    }

    return true;
}
示例#19
0
/**
 * @brief WrapperXml::writeXml, metodo para escribir un xml
 * @param pRuta, directorio en el que se guardara el documento
 * @param pRoot, raiz del documento
 * @param pSon, hijo del documento
 */
void WrapperXml::writeCreateSchemeXml(std::string pMsg, xml_document<> &pDocument){
    xml_node<>* decl = pDocument.allocate_node(node_declaration);
    decl->append_attribute(pDocument.allocate_attribute(VERSION, NUMVERSION));
    decl->append_attribute(pDocument.allocate_attribute(ENCODE, TYPEENCODE));
    pDocument.append_node(decl);

    xml_node<>* root = pDocument.allocate_node(node_element, SCHEME);
    pDocument.append_node(root);

    std::istringstream pBuffer(pMsg);
    std::string subString;
    pBuffer >> subString;
    xml_node<>* childSN = pDocument.allocate_node(node_element, SCHEMENAME);
    childSN->value(strdup(subString.c_str()));
    root->append_node(childSN);
    pBuffer >> subString;
    xml_node<>* childR = pDocument.allocate_node(node_element, RAID);
    childR->value(strdup(subString.c_str()));
    root->append_node(childR);

    while(pBuffer){
        pBuffer >> subString;
        if(subString==HASH)
            break;
        else{
            xml_node<>* childD = pDocument.allocate_node(node_element, DATA);
            xml_node<>* childDT = pDocument.allocate_node(node_element, DATATYPE);
            childDT->value(strdup(subString.c_str()));
            childD->append_node(childDT);
            pBuffer >> subString;
            xml_node<>* childDL = pDocument.allocate_node(node_element, DATANAME );
            childDL->value(strdup(subString.c_str()));
            childD->append_node(childDL);
            pBuffer >> subString;
            xml_node<>* childDN= pDocument.allocate_node(node_element, DATANAME);
            childDN->value(strdup(subString.c_str()));
            childD->append_node(childDN);
            root->append_node(childD);
        }
    }

}
void ftof_panels_parms_xml(xml_document& doc, const ForwardTOF& ftof, const string& coordsys="clas", const string& units="cm")
{
    double lconv = length_conversion(units);

    if (coordsys != "sector" && coordsys != "clas")
    {
        throw runtime_error(string("can not generate data in ") + coordsys + " coordinates");
    }
    coordsys_t coord = str2coord(coordsys);

    // start building up the XML document
    xml_node geom_node = doc.child("geometry");
    if (!geom_node)
    {
        geom_node = doc.append_child("geometry");
    }

    xml_node ftof_node = geom_node.child("forward_tof");
    if (!ftof_node)
    {
        ftof_node = geom_node.append_child("forward_tof");
    }

    xml_node panels_node = ftof_node.child("panels_parms");
    if (!panels_node)
    {
        panels_node = ftof_node.append_child("panels_parms");
        panels_node.append_attribute("length_units");
        panels_node.append_attribute("coordinate_system");
    }

    panels_node.attribute("length_units") = units.c_str();
    panels_node.attribute("coordinate_system") = coordsys.c_str();

    for (int sec=0; sec<ftof.sectors().size(); sec++)
    {
        const forward_tof::Sector& ftof_sector = ftof.sector(sec);

        for (int pan=0; pan<ftof_sector.panels().size(); pan++)
        {
            const forward_tof::Panel& panel = ftof_sector.panel(pan);

            xml_node panel_node = panels_node.append_child("panel");
            panel_node.append_attribute("sector") = sec;
            panel_node.append_attribute("panel") = ftof_sector.panel_name(pan).c_str();
            panel_node.append_attribute("npaddles") = int(panel.npaddles());
            panel_node.append_attribute("dist2tgt") = panel.dist2tgt() * lconv;

            direction_vector<double,3> panel_norm = panel.panel_normal(coord);
            panel_node.append_attribute("norm_phi") = panel_norm.phi();
            panel_node.append_attribute("norm_theta") = panel_norm.theta();

            direction_vector<double,3> paddle_dir = panel.paddle_direction(coord);
            panel_node.append_attribute("paddle_phi") = paddle_dir.phi();
            panel_node.append_attribute("paddle_theta") = paddle_dir.theta();

            panel_node.append_attribute("paddle_width") = panel.paddle_width() * lconv;
            panel_node.append_attribute("paddle_thickness") = panel.paddle_thickness() * lconv;

            euclid_vector<double,3> paddle_extent = panel.paddle_extent(COORDSYS::SECTOR);
            panel_node.append_attribute("paddle_extent_x") = paddle_extent.x() * lconv;
            panel_node.append_attribute("paddle_extent_z") = paddle_extent.z() * lconv;

            xml_node center_node = panel_node.append_child("paddle_centers");
            vector<xml_node> paddle_centers_node;
            paddle_centers_node.push_back(center_node.append_child("x"));
            paddle_centers_node.push_back(center_node.append_child("y"));
            paddle_centers_node.push_back(center_node.append_child("z"));

            vector<stringstream> centers(3);
            for (auto cntr : panel.paddle_centers(coord))
            {
                centers[0] << " " << cntr.x() * lconv;
                centers[1] << " " << cntr.y() * lconv;
                centers[2] << " " << cntr.z() * lconv;
            }
            for (int i=0; i<paddle_centers_node.size(); i++)
            {
                paddle_centers_node[i].append_child(pugi::node_pcdata).set_value(
                    centers[i].str().erase(0,1).c_str());
            }

            xml_node length_node = panel_node.append_child("paddle_lengths");
            stringstream lengths;
            for (auto lngth : panel.paddle_lengths())
            {
                lengths << " " << lngth;
            }
            length_node.append_child(pugi::node_pcdata).set_value(
                lengths.str().erase(0,1).c_str());
        }
    }
}
示例#21
0
void ProjectManager::loadEnvironment(xml_document<> &doc)
{
	objects.clear();

	cout << "loading environment..." << "\n" << flush;
	xml_node<> *profile = doc.first_node()->first_node("profile");
	xml_node<> *user = profile->first_node("user");
	xml_node<> *objecties = profile->first_node("object");
	//read x y z h p r from user block and place object there
	
	cout << "obtained variables..." << "\n" << flush;
	//look at obj nodes, then check the doc for the location, then import and position at the correct location
	
	string path = projectDir + "\\data\\obj";
	//string filename = objecties->first_node("resourceName")->value();
	cout << "projdir: " << projectDir << "\n" << flush;
	vector<string> pathv;
	vector<string> filenamev;
	vector<float> objx;
	vector<float> objy;
	vector<float> objz;
	vector<float> objh;
	vector<float> objp;
	vector<float> objr;
	vector<float> objscale;
	vector<char *> objname;
	//filenamev.push_back(filename);
	
	xml_node<> *userlocation = user->first_node("startingLocation");
	if (userlocation != 0)
	{
		float x = atof(userlocation->first_node("x")->value());
		float y = atof(userlocation->first_node("y")->value());
		float z = atof(userlocation->first_node("z")->value());
		float h = atof(userlocation->first_node("heading")->value());
		float p = atof(userlocation->first_node("pitch")->value());
		float r = atof(userlocation->first_node("roll")->value());
		char *name = user->first_node("name")->value();
		
		objx.push_back(x);
		objy.push_back(y+3.3); //for mrbody this should be y+3
		objz.push_back(z);
		objh.push_back(h);
		objp.push_back(p+180); //for mrbody this should be p-12
		objr.push_back(r);
		objscale.push_back(4); //for mrbody this should be 4
		objname.push_back(name);
		
		//string filename = "MrBodyWithHands.obj";
		string filename = "batman.obj";
		filenamev.push_back(filename);
		string pathy = PATH+"Kosmos\\data\\obj";
		pathv.push_back(pathy);
		//Import::import("cello.obj", x, y, z, h, p, r, "C:\\aszgard5\\szg\\projects\\Kosmos\\data\\obj");
	}
	
	
	
	
	while(objecties != 0)
	{
		cout << "loading object..." << "\n" << flush;
		//filename = "";
		// get xyzhpr and import object
		
		string filename = objecties->first_node("resourceName")->value();
		filenamev.push_back(filename);
		pathv.push_back(path);
		/*int length = filename.length();
		if (filename[length-1] == 'j' && filename[length-2] == 'b' && filename[length-3] == 'o')
		{
			cout << "wth file is obj " << "\n" << flush;
		}*/
		float x = atof(objecties->first_node("x")->value());
		float y = atof(objecties->first_node("y")->value());
		float z = atof(objecties->first_node("z")->value());
		float h = atof(objecties->first_node("heading")->value());
		float p = atof(objecties->first_node("pitch")->value());
		float r = atof(objecties->first_node("roll")->value());
		float s = atof(objecties->first_node("scale")->value());
		char *name = objecties->first_node("name")->value();
		
		objx.push_back(x);
		objy.push_back(y);
		objz.push_back(z);
		objh.push_back(h);
		objp.push_back(p);
		objr.push_back(r);
		objscale.push_back(s);
		objname.push_back(name);
		/*
			<resourceName>cello.obj</resourceName>
			<x>0</x>
			<y>4</y>
			<z>-4</z>
			<heading>0</heading>
			<pitch>0</pitch>
			<roll>0</roll>
		*/
		objecties = objecties->next_sibling();
		if (objecties == 0)
		{
			break;
		}
	}
	
	for( unsigned int i=0; i<filenamev.size(); ++i)
	{
		if (i==0)
		{
			userObject = Import::import(filenamev[i], objx[i], objy[i], objz[i], objh[i], objp[i], objr[i], objscale[i], pathv[i],5,objname[i]);
		}
		else
		{
			Import::import(filenamev[i], objx[i], objy[i], objz[i], objh[i], objp[i], objr[i], objscale[i], pathv[i],2,objname[i]);
		}
	}
	
	filenamev.clear();
	objx.clear();
	objy.clear();
	objz.clear();
	objh.clear();
	objp.clear();
	objr.clear();
	objscale.clear();
	objname.clear();
	pathv.clear();
	
	float wiimoteX = 1.9; //2 for mrbody
	float wiimoteY = 3.5; //4 for mrbody
	float wiimoteZ = -0.6; //-0.7 for mrbody, negative moves closer
	rightWiimote = new Object(4, 0.5, 0.5, 0.5, "MrWiimote.obj");
	rightWiimote->normalize();
	rightWiimote->setMatrix(ar_translationMatrix(wiimoteX, wiimoteY, wiimoteZ)); // initial position
	rightWiimote->setHPR(135,0,0);
	//rightWiimote->disable();
	//rightWiimote->_selected = true;
	//rightWiimote->setHighlight(true);
	objects.push_back(rightWiimote);
	
	leftWiimote = new Object(4, 0.5, 0.5, 0.5, "MrWiimote.obj");
	leftWiimote->normalize();
	leftWiimote->setMatrix(ar_translationMatrix(-wiimoteX, wiimoteY, wiimoteZ)); // initial position
	leftWiimote->setHPR(135,0,0);
	objects.push_back(leftWiimote);
	
	headMountedDisplay = new Object(6, 0.4, 0.4, 0.35, "MrVisor.obj");
	headMountedDisplay->normalize();
	headMountedDisplay->setMatrix(ar_translationMatrix(0, 5.85, -0.09)); // initial position
	headMountedDisplay->setHPR(0,-90,0);
	objects.push_back(headMountedDisplay);
}
示例#22
0
 inline void allocate_append_attribute(xml_node<>* node, const char* attr_name, const char* attr_val)
 {
     xml_attribute<>* attr = xml_doc.allocate_attribute(attr_name, attr_val);
     node->append_attribute(attr);
 }
/// Read & assign the object's fields from an XML DOM structure.
void stream_info_impl::read_xml(xml_document &doc) {
	try {
		xml_node info = doc.child("info");
		// name
		name_ = info.child_value("name");
		if (name_.empty())
			throw std::runtime_error("Received a stream info with empty <name> field.");
		// type
		type_ = info.child_value("type");
		// channel_count
		channel_count_ = lexical_cast<int>(info.child_value("channel_count"));
		if (channel_count_ < 0)
			throw std::runtime_error("The channel count of the given stream info is smaller than 0.");
		// nominal_srate
		nominal_srate_ = lexical_cast<double>(info.child_value("nominal_srate"));
		if (nominal_srate_ < 0.0)
			throw std::runtime_error("The sampling rate of the given stream info is negative.");
		// channel_format
		channel_format_ = cf_undefined;
		string fmt(info.child_value("channel_format"));
		if (fmt == "float32")
			channel_format_ = cf_float32;
		if (fmt == "double64")
			channel_format_ = cf_double64;
		if (fmt == "string")
			channel_format_ = cf_string;
		if (fmt == "int32")
			channel_format_ = cf_int32;
		if (fmt == "int16")
			channel_format_ = cf_int16;
		if (fmt == "int8")
			channel_format_ = cf_int8;
		if (fmt == "int64")
			channel_format_ = cf_int64;
		// source_id
		source_id_ = info.child_value("source_id");
		// version
		version_ = (int)(lexical_cast<double>(info.child_value("version"))*100.0);
		if (version_ <= 0)
			throw std::runtime_error("The version of the given stream info is invalid.");
		// created_at
		created_at_ = lexical_cast<double>(info.child_value("created_at"));
		// uid
		uid_ = info.child_value("uid");
		if (uid_.empty())
			throw std::runtime_error("The UID of the given stream info is empty.");
		// session_id
		session_id_ = info.child_value("session_id");
		// hostname
		hostname_ = info.child_value("hostname");
		// address
		v4address_ = info.child_value("v4address");
		// data_port
		v4data_port_ = lexical_cast<int>(info.child_value("v4data_port"));
		// service_port
		v4service_port_ = lexical_cast<int>(info.child_value("v4service_port"));
		// address
		v6address_ = info.child_value("v6address");
		// data_port
		v6data_port_ = lexical_cast<int>(info.child_value("v6data_port"));
		// service_port
		v6service_port_ = lexical_cast<int>(info.child_value("v6service_port"));
	} catch(std::exception &e) {
		// reset the stream info to blank state
		*this = stream_info_impl();
		name_ = (string("(invalid: ") += e.what()) += ")";
	}
}
示例#24
0
void process_contextless(xml_node<char> *node)
{
    // Translate contextless doxygen tags
    if (string(node->name()) == "ulink")
    {
        node->name("a");
        xml_attribute<char> *attr = node->first_attribute("url");
        if (attr)
            attr->name("href");
    }
    else if (string(node->name()) == "ref")
    {
        node->name("a");
        xml_attribute<char> *attr = node->first_attribute("refid");
        if (attr)
        {
            attr->name("href");
            char *value = doc.allocate_string(0, attr->value_size() + 1);
            std::memcpy(value + 1, attr->value(), attr->value_size());
            value[0] = '#';
            attr->value(value, attr->value_size() + 1);
        }
    }
    else if (string(node->name()) == "computeroutput")
    {
        node->name("code");
    }
    else if (string(node->name()) == "verbatim")
    {
        node->name("pre");
    }
    else if (string(node->name()) == "linebreak")
    {
        node->name("br");
    }
    else if (string(node->name()) == "hruler")
    {
        node->name("hr");
    }
    else if (string(node->name()) == "heading")
    {
        xml_attribute<char> *attr = node->first_attribute("level");
        if (attr)
        {
            int level = atoi(attr->value());
            if (level == 0) node->name("h0");
            else if (level == 1) node->name("h1");
            else if (level == 2) node->name("h2");
            else if (level == 3) node->name("h3");
            else if (level == 4) node->name("h4");
            else if (level == 5) node->name("h5");
            else if (level == 6) node->name("h6");
            else if (level == 7) node->name("h7");
            else if (level == 8) node->name("h8");
            else node->name("h9");
        }
    }
    else if (string(node->name()) == "toc")
    {
        if (toc.parent() != 0)
            throw std::exception("More than one <toc> tag found.");
        toc.name("toc-contents");
        node->append_node(&toc);
    }
    else if (string(node->name()) == "sect1")
    {
        xml_node<char> *title = node->first_node("title");
        if (title)
        {
            title->name("h2");
            xml_attribute<char> *id = node->first_attribute("id");
            if (id)
            {
                xml_attribute<char> *not_numbered = node->first_attribute("not-numbered");
                add_to_toc(0, title, id, not_numbered != 0);
                id->parent()->remove_attribute(id);
                title->append_attribute(id);
            }
        }
    }
    else if (string(node->name()) == "sect2")
    {
        xml_node<char> *title = node->first_node("title");
        if (title)
        {
            title->name("h3");
            xml_attribute<char> *id = node->first_attribute("id");
            if (id)
            {
                xml_attribute<char> *not_numbered = node->first_attribute("not-numbered");
                add_to_toc(1, title, id, not_numbered != 0);
                id->parent()->remove_attribute(id);
                title->append_attribute(id);
            }
        }
    }
    else if (string(node->name()) == "sect3")
    {
        xml_node<char> *title = node->first_node("title");
        if (title)
        {
            title->name("h4");
            xml_attribute<char> *id = node->first_attribute("id");
            if (id)
            {
                xml_attribute<char> *not_numbered = node->first_attribute("not-numbered");
                add_to_toc(2, title, id, not_numbered != 0);
                id->parent()->remove_attribute(id);
                title->append_attribute(id);
            }
        }
    }
    else if (string(node->name()) == "itemizedlist")
    {
        node->name("ul");
    }
    else if (string(node->name()) == "listitem")
    {
        node->name("li");
    }
    else if (string(node->name()) == "table")
    {
        node->append_attribute(doc.allocate_attribute("border", "1"));
        node->append_attribute(doc.allocate_attribute("cellpadding", "3pt"));
    }
    else if (string(node->name()) == "row")
    {
        node->name("tr");
    }
    else if (string(node->name()) == "entry")
    {
        if (node->first_attribute("thead") && string(node->first_attribute("thead")->value()) == "yes")
            node->name("th");
        else
            node->name("td");
        xml_node<char> *rowspan = node->first_node("rowspan");
        if (rowspan)
        {
            xml_attribute<char> *attr = rowspan->first_attribute("count");
            if (attr)
            {
                xml_attribute<char> *a = doc.allocate_attribute();
                a->name("rowspan");
                a->value(attr->value());
                node->append_attribute(a);
            }
        }
    }
    else if (string(node->name()) == "emphasis")
    {
        node->name("i");
    }
    else if (string(node->name()) == "bold")
    {
        node->name("b");
    }
    else if (string(node->name()) == "space")
    {
        node->type(node_data);
        int n = 1;
        if (node->first_attribute("count"))
            n = atoi(node->first_attribute("count")->value());
        char *data = doc.allocate_string(0, n);
        memset(data, ' ', n);
        node->value(data, n);
    }

    // Process recursively
    xml_node<char> *child = node->first_node();
    while (child)
    {
        xml_node<char> *next = child->next_sibling();
        process_contextless(child);
        child = next;
    }
}
示例#25
0
//!
//! I would like to thank Arseny Kapoulkine for his work on <a href="http://code.google.com/p/pugixml">pugixml</a>, 
//! which was an inspiration for this project.
//! Additional thanks go to Kristen Wegner for creating <a href="http://www.codeproject.com/soap/pugxml.asp">pugxml</a>,
//! from which pugixml was derived.
//! Janusz Wohlfeil kindly ran RapidXml speed tests on hardware that I did not have access to, 
//! allowing me to expand performance comparison table.
//!
//! \section two_minute_tutorial Two Minute Tutorial
//!
//! \subsection parsing Parsing
//!
//! The following code causes RapidXml to parse a zero-terminated string named <c>text</c>:
//! \verbatim
using namespace rapidxml;
xml_document<> doc;    // character type defaults to char
doc.parse<0>(text);    // 0 means default parse flags
\endverbatim
//! <c>doc</c> object is now a root of DOM tree containing representation of the parsed XML.
//! Because all RapidXml interface is contained inside namespace <c>rapidxml</c>, 
//! users must either bring contents of this namespace into scope, or fully qualify all the names.
//! Class xml_document represents a root of the DOM hierarchy. 
//! By means of public inheritance, it is also an xml_node and a memory_pool.
//! Template parameter of xml_document::parse() function is used to specify parsing flags, 
//! with which you can fine-tune behaviour of the parser.
//! Note that flags must be a compile-time constant.
//!
//! \subsection accessing_dom_tree Accessing The DOM Tree
//!
//! To access the DOM tree, use methods of xml_node and xml_attribute classes:
//! \verbatim
示例#26
0
 inline xml_node<>* allocate_append_node(xml_node<>* top, const char* name)
 {
     xml_node<>* node = xml_doc.allocate_node(node_element, name);
     top->append_node(node);
     return node;
 }