コード例 #1
0
bool SensorFile::init( const string &fileName )
{
	if( mInited )
		return false;

	fs::path fullPath( getAssetPath( string( "capture/" ) + fileName ));
	if( ! fs::exists( fullPath ))
	{
		console() << "Unable to load captured file: " << fileName << endl;
		return false;
	}

	mDoc = XmlTree( loadFile( fullPath ));

	if( mDoc.hasChild( "PulseSensor" ))
	{
		XmlTree &xmlPulseSensor = mDoc.getChild( "PulseSensor" );
		mName = xmlPulseSensor.getAttributeValue<string>( "Name"    , "" );

		if( xmlPulseSensor.hasChild( "Data" ))
		{
			mListXmlData   = &xmlPulseSensor.getChildren();
			mXmlDataActIt  =  mListXmlData->end();
			mInited        =  true;
			mTime          =  getElapsedSeconds();
			return true;
		}
	}

	console() << "Invalid captured file: " << fileName << endl;
	return false;
}
コード例 #2
0
ファイル: Aspring.cpp プロジェクト: afrancois/Afw
XmlTree Aspring::toXml()
{ 
	XmlTree p( "Aspring", "" );
	p.push_back( getCoreXml() );
	//attributes
	p.push_back( XmlTree( "k", toString(k) ) );
	p.push_back( XmlTree( "d", toString(d) ) );
	//references
	if(P1 != NULL && P2 != NULL){ 
		p.push_back( XmlTree( "P1", P1->Ref ) );
		p.push_back( XmlTree( "P2", P2->Ref ) );
	}
	if(COLLIDER != NULL){ 
		p.push_back( XmlTree( "COLLIDER", COLLIDER->Ref ) );
	}
	//return result
	return p;
}
コード例 #3
0
void DataManager::generateXmlFile(){
    XmlTree dataTree;
    dataTree.setTag("QLT_Genome_Data");

    dataTree.push_back(XmlTree("datapath","./data/exons/"));
    
    XmlTree datas("datasets","");
    for(int i=0;i<23;i++){
        XmlTree dataset("dataset","");
        dataset.setAttribute("id", i);
        dataset.push_back( XmlTree("title","Chromosome "+toString(i+1)) );
        dataset.push_back( XmlTree("map","exons."+toString(i+1)+".locations") );
        dataset.push_back( XmlTree("bases","exons."+toString(i+1)+".bases") );
        datas.push_back( dataset );
    }
    dataTree.push_back( datas );

    DataTargetPathRef f = writeFile( getAssetPath( "QLT_Genome_Data.xml" ), true );
    dataTree.write( f );
    
}
コード例 #4
0
ファイル: PlistReader.cpp プロジェクト: camb416/PLister
PlistReader::PlistReader()
{
    XmlTree plist =  XmlTree(loadResource( "RECIPES.plist" ) );
    console() << "this is the tag name... " << plist.getTag() << "IS THIS A DOC ELEMENT OR WAHAT???? " << plist.isDocument() << endl;
    try {
        root = plist.getChild("plist");
    } catch(XmlTree::Exception e){
        console() << "darn" << endl;
    }
    //trace(root);
    parseRecipes();
}
コード例 #5
0
ファイル: Warp.cpp プロジェクト: UIKit0/Cinder-Warping
WarpList Warp::readSettings( const DataSourceRef &source )
{
	XmlTree  doc;
	WarpList warps;

	// try to load the specified xml file
	try {
		doc = XmlTree( source );
	}
	catch( ... ) {
		return warps;
	}

	// check if this is a valid file
	bool isWarp = doc.hasChild( "warpconfig" );
	if( !isWarp ) return warps;

	//
	if( isWarp ) {
		// get first profile
		XmlTree profileXml = doc.getChild( "warpconfig/profile" );

		// iterate maps
		for( XmlTree::ConstIter child = profileXml.begin( "map" ); child != profileXml.end(); ++child ) {
			XmlTree warpXml = child->getChild( "warp" );

			// create warp of the correct type
			std::string method = warpXml.getAttributeValue<std::string>( "method", "unknown" );
			if( method == "bilinear" ) {
				WarpBilinearRef warp( new WarpBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspective" ) {
				WarpPerspectiveRef warp( new WarpPerspective() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspectivebilinear" ) {
				WarpPerspectiveBilinearRef warp( new WarpPerspectiveBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
		}
	}

	return warps;
}
コード例 #6
0
ファイル: Xml.cpp プロジェクト: Ahbee/Cinder
void parseItem( const rapidxml::xml_node<> &node, XmlTree *parent, XmlTree *result, const XmlTree::ParseOptions &options )
{
	*result = XmlTree( node.name(), node.value(), parent );
	for( const rapidxml::xml_node<> *item = node.first_node(); item; item = item->next_sibling() ) {
		XmlTree::NodeType type;
		switch( item->type() ) {
			case rapidxml::node_element:
				type = XmlTree::NODE_ELEMENT;
			break;
			case rapidxml::node_cdata: {
				if( options.getCollapseCData() ) {
					result->setValue( result->getValue() + item->value() );
					continue;
				}
				else {
					type = XmlTree::NODE_CDATA;
				}
			}
			break;						
			case rapidxml::node_comment:
				type = XmlTree::NODE_COMMENT;
			break;
			case rapidxml::node_doctype: {
				result->setDocType( item->value() );
				continue;
			}
			case rapidxml::node_data: {
				if( ! options.getIgnoreDataChildren() )
					type = XmlTree::NODE_DATA;
				else
					continue;
			}
			break;
			default:
				continue;
		}
		
		result->getChildren().push_back( unique_ptr<XmlTree>( new XmlTree ) );
		parseItem( *item, result, result->getChildren().back().get(), options );
		result->getChildren().back()->setNodeType( type );
	}

	for( rapidxml::xml_attribute<> *attr = node.first_attribute(); attr; attr = attr->next_attribute() )
		result->getAttributes().push_back( XmlTree::Attr( result, attr->name(), attr->value() ) );
}
コード例 #7
0
ファイル: CinderConfig.cpp プロジェクト: araid/Cinder-Config
void Config::save(fs::path filePath)
{
    std::string myXmlStr( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" );
	XmlTree doc(myXmlStr);
    XmlTree node;
	node.setTag("general");

	for(std::vector<ConfigParam>::iterator it = mConfigParameters.begin(); it!=mConfigParameters.end(); ++it)
	{
		XmlTree pn;
		pn.setTag(it->name);

		switch(it->type)
		{
		case _NODE:
			doc.push_back( node );
			node = XmlTree();
			node.setTag(it->name);
			break;
		case _BOOL:
            if( *((bool*)it->param) ) {
                pn.setValue<int>( 1 );
            } else {
                pn.setValue<int>( 0 );
            }
			node.push_back( pn );
			break;
		case _FLOAT:
			pn.setValue<float>( *((float*)it->param) );
			node.push_back( pn );
			break;
		case _DOUBLE:
			pn.setValue<double>( *((double*)it->param) );
			node.push_back( pn );
			break;
		case _INT:
			pn.setValue<int>( *((int*)it->param) );
			node.push_back( pn );
			break;
		case _VEC3F:
			pn.setAttribute<float>("x", (*((Vec3f*)it->param)).x);
			pn.setAttribute<float>("y", (*((Vec3f*)it->param)).y);
			pn.setAttribute<float>("z", (*((Vec3f*)it->param)).z);
			node.push_back( pn );
			break;
		case _QUATF:
			pn.setAttribute<float>("w", (*((Quatf*)it->param)).w);
			pn.setAttribute<float>("x", (*((Quatf*)it->param)).v.x);
			pn.setAttribute<float>("y", (*((Quatf*)it->param)).v.y);
			pn.setAttribute<float>("z", (*((Quatf*)it->param)).v.z);
			node.push_back( pn );
			break;
		case _COLOR:
			pn.setAttribute<float>("r", (*((Color*)it->param)).r);
			pn.setAttribute<float>("g", (*((Color*)it->param)).g);
			pn.setAttribute<float>("b", (*((Color*)it->param)).b);
			node.push_back( pn );
			break;
		case _COLORA:
			pn.setAttribute<float>("r", (*((ColorA*)it->param)).r);
			pn.setAttribute<float>("g", (*((ColorA*)it->param)).g);
			pn.setAttribute<float>("b", (*((ColorA*)it->param)).b);
			pn.setAttribute<float>("a", (*((ColorA*)it->param)).a);
			node.push_back( pn );
			break;
		case _STRING:
			pn.setValue<std::string>( *((std::string*)it->param) );
			node.push_back( pn );
			break;
		}
	}
	
	doc.push_back( node );
	doc.write(writeFile(filePath));
}