Example #1
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    if(key == 'r'){
        parseYAML();
    }
    if(key == 's'){
        ofColor color = ofColor(ofRandom(255),ofRandom(255),ofRandom(255));
        ofPoint p1 = ofPoint(ofRandom(3,10), ofRandom(3,10));
        ofPoint p2 = ofPoint(ofRandom(20,50), ofRandom(20,50));
        int s1 = ofRandom(10);
        int s2 = ofRandom(20);
        
        YAML::Emitter out;
        out << YAML::BeginMap;     
        out << YAML::Key << "name";
        out << YAML::Value << "Greg Borenstein";
        out << YAML::Key << "color";
        out << YAML::Value << color;
        out << YAML::Key << "point1";
        out << YAML::Value << p1;
        out << YAML::Key << "point2";
        out << YAML::Value << p2;
        out << YAML::Key << "size1";
        out << YAML::Value << s1;
        out << YAML::Key << "size2";
        out << YAML::Value << s2;
        
        out << YAML::EndMap;
        
        int l = strlen(out.c_str());
        
        ofBuffer yamlData;
        yamlData.set((const char *)out.c_str(), l);
        bool fileWritten = ofBufferToFile(ofToDataPath("my_points.yml"), yamlData); 
    }
}
Example #2
0
//--------------------------------------------------------------
void testApp::setup(){
   parseYAML();
}
Example #3
0
	void parseYAML(const char* fileName, Array &buf)
	{
		parseYAML(fileName, buf.mas, buf.rows, buf.columns);
	}