示例#1
0
void Compiler::generateSourceFiles(const Project& project)
{
    ofDirectory src(project.getPath() + "/src");
    src.remove(true);
    src.create(true);

    Json::Value projectData = project.getData();
    std::string projectFile = _projectFileTemplate;
    ofStringReplace(projectFile, "<projectfile>", projectData["projectFile"]["fileContents"].asString());
    ofStringReplace(projectFile, "<projectname>", projectData["projectFile"]["name"].asString());
    _replaceIncludes(projectFile);
    ofBuffer sourceBuffer(projectFile);
    ofBufferToFile(src.getAbsolutePath() + "/main.cpp", sourceBuffer);

    if (project.hasClasses())
    {
        for (unsigned int i = 0; i < projectData["classes"].size(); ++i)
        {
            Json::Value c = projectData["classes"][i];
        
            std::string classFile = _classTemplate;
            ofStringReplace(classFile, "<classname>", c["name"].asString());
            ofStringReplace(classFile, "<classfile>", c["fileContents"].asString());
            _replaceIncludes(classFile);
        
            ofBuffer sourceBuffer(classFile);
            ofBufferToFile(src.getAbsolutePath() + "/" + c["name"].asString() + ".h", sourceBuffer);
        }
    }
}
示例#2
0
void ofApp::sendBodyDataJSON(){

	ostringstream buff;
	buff << "{";
	buff << "\"bodies\":[";

	if (bSingleUserMode) {
		if (currLegitimateTrackingId != 0) {
			auto * b = kinect.getBodyFrame()->getBodyPtrById(currLegitimateTrackingId);
			if (b && b->tracked) {
				buff << getBodyJSON(*b);
			}
		}
	}
	else {
		for (auto & b : kinect.getBodyFrame()->getBodies()) {
			if (!b.tracked) continue;
			buff << getBodyJSON(b);
		}
	}

	buff << "]}";

	string val = buff.str();
	ofStringReplace(val, ",]", "]");
	ofStringReplace(val, ",}", "}");
	sockets->send(val);
}
示例#3
0
string ofXml::toString() const
{
    ostringstream stream;
    
    Poco::XML::DOMWriter writer;
    writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
    if(document) {
        try {
            writer.writeNode( stream, getPocoDocument() );
        } catch( exception & e ) {
            ofLogError("ofXml") << "toString(): " << e.what();
        }
    } else if(element){
        element->normalize();
        writer.writeNode( stream, element );
    }
    
    string tmp = stream.str();
    
    // don't know how else to get rid of the hidden <#text></#text> nodes :/
    ofStringReplace(tmp, "<#text>", "");
    ofStringReplace(tmp, "</#text>", "");
    
    return tmp;
}
示例#4
0
    //------------------------------------------------------------------------------------
    void startRecording()
    {
        if (bOpeningRecorder)
            finishRecording();
        
        ///add directory select
        SkeletonMap &map = skeleton::SkeletonManager::getInstance().getSkeletons();

        if (map.empty()) {
            ofLogNotice("Recorder") << "No skeleton avairable";
            return;
        }

        for (SkeletonMap::iterator it = map.begin(); it!=map.end(); ++it) {
            SkeletonPtr skeleton = it->second;
            const string name = skeleton->getName();
            //string filePath = ret.getPath();
            string filePath = ofToDataPath("motion/mot/"+ram::getDefaultRecordingDataFileName());
            const string escape = "__WILDCARD_ESCAPE__";
            ofStringReplace(filePath, "\\*", escape);
            ofStringReplace(filePath, "*", name);
            ofStringReplace(filePath, escape, "*");
            skeleton->prepareRecording(filePath);
            skeleton->startRecording();
        }
    
        bOpeningRecorder = true;
    }
示例#5
0
void testApp::loadURL_recentPostcards(ofHttpResponse &response){
    if (allEntries.size()>1) {
        for(int i=0; i<allEntries.size(); i++){
            vector<string> cutEntries =ofSplitString(allEntries[i], ",");
            /*for (int i=0; i<cutEntries.size(); i++) {
                printf("%s\n", cutEntries[i].c_str());
            }*/
            //delete the first parts in all of them
            ofStringReplace(cutEntries[0], "\"ID\":\"", "");
            ofStringReplace(cutEntries[1], "\"longitude\":\"", "");
            ofStringReplace(cutEntries[2], "\"latitude\":\"", "");
            ofStringReplace(cutEntries[3], "\"postcardText\":\"", "");
            ofStringReplace(cutEntries[4], "\"owner\":\"", "");
            //delete the last " in all of them
            ofStringReplace(cutEntries[0], "\"", "");
            ofStringReplace(cutEntries[1], "\"", "");
            ofStringReplace(cutEntries[2], "\"", "");
            ofStringReplace(cutEntries[3], "\"", "");
            ofStringReplace(cutEntries[4], "\"", "");
            //printf("cutEntries0=%s", cutEntries[0].c_str());
            Postcard entry(cutEntries[0], cutEntries[1], cutEntries[2],cutEntries[3],cutEntries[4]);
            
            if(allPostcards.size()<5){
                allPostcards.push_back(entry);
                allPostcards[allPostcards.size()-1].loadImage();
            } else{
                for (int i=0; i<allPostcards.size(); i++) {
                    /*printf("allPostcardssize-1: %i", (int)allPostcardsBerlin.size()-1);
                     printf("i: %i", i);
                     printf("entry id: %i  ", entry._id);
                     printf("postcard id: %i\n", allPostcards[i]._id);*/
                    if (entry._id==allPostcards[i]._id) {
                        break;
                    }
                    if (i==allPostcards.size()-1) {
                        allPostcards.insert(allPostcards.begin(),entry);
                        allPostcards[0].loadImage();
                        allPostcards.pop_back();
                        break;
                    }
                }
            }
        }
    }
    
    //just for testing
    //printf("allPostcards size %lu \n", allPostcards.size());
    /*for (int i=0; i<allPostcardsBerlin.size(); i++) {
     allPostcardsBerlin[i].print();
     }*/
    if (response.status==200 && response.request.name=="async_req") {
        //setup which ones are shown first
        currImgNo=allPostcards.size()-1;
    } else{
        //printf("not loaded \n");
        
    }

}
示例#6
0
string ofxToString(ofMatrix4x4 m) {
    stringstream ss;
    ss << m;
    string s = ss.str();
    ofStringReplace(s, "\n", ",");
    ofStringReplace(s, " ", "");
    return s;
}
示例#7
0
void ofxSlider<Type>::loadFromXml(ofxXmlSettings& xml) {
	string xmlName = name;
	ofStringReplace(xmlName," ","_");
	ofStringReplace(xmlName,",","_");
	ofStringReplace(xmlName,"(","_");
	ofStringReplace(xmlName,")","_");
	ofStringReplace(xmlName,"/","_");
	value = xml.getValue(xmlName, value);
}
示例#8
0
void ofxSlider<Type>::saveToXml(ofxXmlSettings& xml) {
	string xmlName = name;
	ofStringReplace(xmlName," ","_");
	ofStringReplace(xmlName,",","_");
	ofStringReplace(xmlName,"(","_");
	ofStringReplace(xmlName,")","_");
	ofStringReplace(xmlName,"/","_");
	xml.setValue(xmlName, value);
}
示例#9
0
void testApp::loadQuestion(ofHttpResponse &response){
    //delete the first parts in all of them
    ofStringReplace(allEntries[0], "\"ID\":\"", "");
    //delete the last " in all of them
    ofStringReplace(allEntries[0], "\"", "");

    currentQuestionNumber=ofToInt(allEntries[0])-1;
    
    currentURLNo++;
    sendRequest();
}
示例#10
0
Json::Value Compiler::parseError(std::string message) const
{
    // i.e. Mike-Test:8:6: error: cannot initialize a variable of type 'int' with an lvalue of type 'const char [3]'

    Json::Value compileError;

    Poco::RegularExpression errorExpression(".+:[0-9]+:[0-9]+: (fatal error|error|warning|note): .+$", Poco::RegularExpression::RE_ANCHORED);

    if (errorExpression.match(message))
    {
        std::vector<std::string> vals = ofSplitString(message, ":");

        if (vals.size() == 5)
        {
            ofStringReplace(vals[3], " ", "");
        
            // ACE Editor refers to "note" as "info"
            if (vals[3] == "note") vals[3] = "info";
            else if (vals[3] == "fatalerror") vals[3] = "error";
        
            compileError["tabName"] = vals[0];
            compileError["annotation"]["row"] = ofToInt(vals[1]);
            compileError["annotation"]["column"] = ofToInt(vals[2]);
            compileError["annotation"]["type"] = vals[3];
            compileError["annotation"]["text"] = vals[4];
       
        }
    }

    return compileError;
}
示例#11
0
void ofxTLPage::saveTrackPositions(){
	ofxXmlSettings trackPositions;
	trackPositions.addTag("positions");
	trackPositions.pushTag("positions");
	
	int curElement = 0;
	map<string, ofRectangle>::iterator it;
	for(it = savedTrackPositions.begin(); it != savedTrackPositions.end(); it++){
		trackPositions.addTag("element");
		trackPositions.addAttribute("element", "name", it->first, curElement);
		
		trackPositions.pushTag("element", curElement);
		trackPositions.addValue("x", it->second.x);
		trackPositions.addValue("y", it->second.y);
		trackPositions.addValue("width", it->second.width);
		trackPositions.addValue("height", it->second.height);
		
		trackPositions.popTag(); //element
		
		curElement++;
	}
	trackPositions.popTag();
	string xmlPageName = name;
	ofStringReplace(xmlPageName," ", "_");
	string trackPositionsFile = ofToDataPath(timeline->getWorkingFolder() + timeline->getName() + "_" +  xmlPageName + "_trackPositions.xml");
	trackPositions.saveFile( trackPositionsFile );
}
示例#12
0
void ofxTLPage::loadTrackPositions(){
	ofxXmlSettings trackPositions;
	string xmlPageName = name;
	ofStringReplace(xmlPageName," ", "_");
	string positionFileName = ofToDataPath(timeline->getWorkingFolder() + timeline->getName() + "_" + xmlPageName + "_trackPositions.xml");
	if(trackPositions.loadFile(positionFileName)){
		
		//cout << "loading element position " << name << "_trackPositions.xml" << endl;
		
		trackPositions.pushTag("positions");
		int numtracks = trackPositions.getNumTags("element");
		for(int i = 0; i < numtracks; i++){
			string name = trackPositions.getAttribute("element", "name", "", i);
			trackPositions.pushTag("element", i);
			ofRectangle elementPosition = ofRectangle(ofToFloat(trackPositions.getValue("x", "0")),
													  ofToFloat(trackPositions.getValue("y", "0")),
													  ofToFloat(trackPositions.getValue("width", "0")),
													  ofToFloat(trackPositions.getValue("height", "0")));
			savedTrackPositions[name] = elementPosition;
			trackPositions.popTag();
		}
		trackPositions.popTag();
	}
	else{
		 ofLogNotice("ofxTLPage::loadTrackPositions") << "Couldn't load position file";
	}
}
示例#13
0
void ofApp::timerCompleteHandler( int &args )
{
    ofLogNotice("Starting Record and Convert");

    ifstream fin;
    
    ofFile file;
    
    file.open("stt/stt.txt");
    
    if (!file.exists()) {
        ofLogNotice("FILE DOESN'T EXIST");
        return;
    }
    
    
    ofBuffer buffer = file.readToBuffer();
    
    searchCriteria = buffer.getFirstLine();
        
    ofStringReplace(searchCriteria, " ", "+");
    
    getImageForText(searchCriteria);
    
//    file.close();
    
    //file.remove();
    
}
示例#14
0
//----------------------------
string checkXmlName(string friendlyName, string xmlName){
	if( xmlName == "" ){
		xmlName = friendlyName;
		ofStringReplace(xmlName, " ", "_");
	}
	return xmlName;
}
示例#15
0
void testApp::urlResponse(ofHttpResponse & response){
    loadingResponseDone=true;
    theResponse=ofToString(response.data);
    ofStringReplace(theResponse, "[{", "");
    ofStringReplace(theResponse, "}]", "");
    //printf("%s", theResponse.c_str());
    
    allEntries=ofSplitString(theResponse, "},{");
    if (currentURL==recentPostcards){
        loadURL_recentPostcards(response);
    } else if (currentURL==recentLetters){
        loadURL_recentLetters(response);
    } else if(currentURL==currentAlphabet){
        loadURL_alphabet(response);
    }
}
示例#16
0
void ofxTLPage::timelineChangedName(string newName, string oldName){
    for(int i = 0; i < headers.size(); i++){
		string filename = tracks[headers[i]->name]->getXMLFileName();
		ofStringReplace(filename, oldName+"_", newName+"_");
        tracks[headers[i]->name]->setXMLFileName(filename);
    }
}
示例#17
0
void ofAddon::exclude(vector<string> & variable, vector<string> exclusions){
	for(int i=0;i<(int)exclusions.size();i++){
		string exclusion = exclusions[i];
		//ofStringReplace(exclusion,"/","\\/");
		ofStringReplace(exclusion,".","\\.");
		ofStringReplace(exclusion,"%",".*");
		exclusion =".*"+ exclusion;
		Poco::RegularExpression regExp(exclusion);
		for(int j=0;j<(int)variable.size();j++){
			cout << "checking " << variable[j] << endl;
			if(regExp.match(variable[j])){
				variable.erase(variable.begin()+j);
				j--;
			}
		}
	}
}
示例#18
0
bool ofxTextBlock::isMetaTag( string str_, string tag_ ){

    if ( ofStringTimesInString( str_, tag_) > 0) {
        ofStringReplace( str_, tag_, "");
        return true;
    }
    return false;

};
示例#19
0
void ofApp::loadURL_recentPostcards(ofHttpResponse &response){
    if (allEntries.size()>1) {
        for(int i=0; i<allEntries.size(); i++){
            vector<string> cutEntries =ofSplitString(allEntries[i], ",");
            //delete the first parts in all of them
            ofStringReplace(cutEntries[0], "\"ID\":\"", "");
            ofStringReplace(cutEntries[1], "\"longitude\":\"", "");
            ofStringReplace(cutEntries[2], "\"latitude\":\"", "");
            ofStringReplace(cutEntries[3], "\"postcardText\":\"", "");
            ofStringReplace(cutEntries[4], "\"owner\":\"", "");
            //delete the last " in all of them
            ofStringReplace(cutEntries[0], "\"", "");
            ofStringReplace(cutEntries[1], "\"", "");
            ofStringReplace(cutEntries[2], "\"", "");
            ofStringReplace(cutEntries[3], "\"", "");
            ofStringReplace(cutEntries[4], "\"", "");
            Postcard entry(cutEntries[0], cutEntries[1], cutEntries[2],cutEntries[3],cutEntries[4]);
            if(allPostcards.size()<4){
                allPostcards.push_back(entry);
                allPostcards[allPostcards.size()-1].loadImage();
            } else{
                for (int i=0; i<allPostcards.size(); i++) {
                    if (entry._id==allPostcards[i]._id) {
                        break;
                    }
                    if (i==allPostcards.size()-1) {
                        allPostcards.insert(allPostcards.begin(),entry);
                        allPostcards[0].loadImage();
                        allPostcards.pop_back();
                        break;
                    }
                }
            }
        }
    }
    //initialize the question;
    initQuestion(currentQuestionNumber, allAlphabet);
    //Question questionFacadeAnimated(currentQuestionNumber, allAlphabet);
    //printf("question size %lu",question.size());
    if (response.status==200 && response.request.name=="async_req") {
        //setup which ones are shown first
        currImgNo=allPostcards.size()-1;
    }
}
示例#20
0
void testApp::loadURL_recentPostcards(ofHttpResponse &response){
    allPostcards.clear();
    for(int i=0; i<allEntries.size(); i++){
        vector<string> cutEntries =ofSplitString(allEntries[i], ",");
        //delete the first parts in all of them
        ofStringReplace(cutEntries[0], "\"ID\":\"", "");
        ofStringReplace(cutEntries[1], "\"longitude\":\"", "");
        ofStringReplace(cutEntries[2], "\"latitude\":\"", "");
        ofStringReplace(cutEntries[3], "\"postcardText\":\"", "");
        ofStringReplace(cutEntries[4], "\"owner\":\"", "");
        //delete the last " in all of them
        ofStringReplace(cutEntries[0], "\"", "");
        ofStringReplace(cutEntries[1], "\"", "");
        ofStringReplace(cutEntries[2], "\"", "");
        ofStringReplace(cutEntries[3], "\"", "");
        ofStringReplace(cutEntries[4], "\"", "");
        //printf("%i ", i);
        Postcard entry(cutEntries[0], cutEntries[1], cutEntries[2],cutEntries[3],cutEntries[4], i);
        allPostcards.push_back(entry);
        

    }
    //just for testing
    //printf("allPostcards size %lu \n", allPostcards.size());
    /*for (int i=0; i<allPostcards.size(); i++) {
        allPostcards[i].print();
    }*/
    
    if (response.status==200 && response.request.name=="async_req") {
        //load all postcard images
        for (int i=0; i<allPostcards.size(); i++) {
            allPostcards[i].loadImage();
        }
        //setup which ones are shown first
        currImgNo1=allPostcards.size()-1;
        currImgNo2=allPostcards.size()-2;
        currImgNo3=allPostcards.size()-3;
        currImgNo4=allPostcards.size()-4;
        currImgNo5=allPostcards.size()-5;
    } else{
        //printf("not loaded \n");
        
    }
}
示例#21
0
void ofApp::urlResponse(ofHttpResponse & response){
    printf("  received response\n");
    loadingResponseDone=true;
    theResponse=ofToString(response.data);
    ofStringReplace(theResponse, "[{", "");
    ofStringReplace(theResponse, "}]", "");
    //printf("%s", theResponse.c_str());
    
    allEntries=ofSplitString(theResponse, "},{");
    if (URLsToLoad[currentURLNo]==recentPostcards){
        loadURL_recentPostcards(response);
    } else if (URLsToLoad[currentURLNo]==recentLetters){
        loadURL_recentLetters(response);
    } else if(URLsToLoad[currentURLNo]==currentAlphabet){
        loadURL_alphabet(response);
    } else if (URLsToLoad[currentURLNo]==currentQuestion){
        loadQuestion(response);
    }

}
示例#22
0
void testApp::urlResponse(ofHttpResponse & response){
    loadingResponseDone=true;
    theResponse=ofToString(response.data);
    ofStringReplace(theResponse, "[{", "");
    ofStringReplace(theResponse, "}]", "");
    
    allEntries=ofSplitString(theResponse, "},{");
    if (URLsToLoad[currentURLNo]==recentPostcardsBerlin){
        loadURL_recentPostcards(response);
    } else if (URLsToLoad[currentURLNo]==recentLettersBerlin){
        loadURL_recentLetters(response);
    } else if(URLsToLoad[currentURLNo]==currentAlphabetBerlin && berlinAlphabetLoaded==false){
        loadURL_alphabetGerman(response);
    } else if(URLsToLoad[currentURLNo]==currentAlphabetBerlin && berlinAlphabetLoaded==true){
        loadURL_alphabetLatvian(response);
    } else if (URLsToLoad[currentURLNo]==currentQuestion){
        loadQuestion(response);
    }

}
void ofxManagedAudioUnit::setup(string _unitName, OSType type, OSType subType, OSType manufacturer,
                                string _className) {
    unitName = _unitName;
    unitSlug = _unitName;
    ofStringReplace(unitSlug, " ", "_");
    unit = ofxAudioUnit(type, subType, manufacturer);
    this->type = stringify(type) == "aumu" ? AU_TYPE_SYNTH : AU_TYPE_UNIT;
    className = _className;
    if(className == "") {
        className = stringify(type, subType, manufacturer);
    }
}
示例#24
0
void ramActorsScene::gotMessage(ofMessage &msg)
{
	vector<string> keys = ofSplitString(msg.message, "/");
	
	const string route = ofSplitString(msg.message, " ")[0];
	string value = msg.message;
	ofStringReplace(value, route+" ", "");
	
	if (route == "/PlaybackSegment/remove")
	{
		removeControlSegment(value);
	}
}
示例#25
0
//--------------------------------------------------------------
void Path3D::parsePts(string filename, ofPolyline &polyline){
    ofFile file = ofFile(ofToDataPath(filename));
    polyline.clear();
    if(!file.exists()){
        ofLogError("The file " + filename + " is missing");
    }
    ofBuffer buffer(file);
    
    //Read file
    for (ofBuffer::Line it = buffer.getLines().begin(); it != buffer.getLines().end(); it++) {
        string line = *it;
        
        float scalar = 10;
        
        ofVec3f offset;
        if (filename == "path_XZ.txt"){
            offset = ofVec3f(0, 0, 0);
            scalar = 3;
        }
        else if (filename == "path_YZ.txt"){
            offset = ofVec3f(0, 0, 0);
            scalar = 3;
        }
        else{
            offset = ofVec3f(0, 0, .25);
            scalar = 3;
        }
        
        ofStringReplace(line, "{", "");
        ofStringReplace(line, "}", "");
        cout<<line<<endl;
        vector<string> coords = ofSplitString(line, ", ");  // get x y z coordinates
        
        ofVec3f p = ofVec3f(ofToFloat(coords[0])*scalar,ofToFloat(coords[1])*scalar,ofToFloat(coords[2])*scalar);
        p += offset;
        
        polyline.addVertex(p);
    }
}
示例#26
0
void Cinema::load(){
        ofDirectory dir("cinema/");
        dir.listDir();
        vector<string> dirs;
        for(int i=0;i<dir.size();i++){
            string d = dir.getPath(i);
            if(d.find("DB")!=string::npos){
                vector<string> vids;
                vector<ofVideoPlayer*> ps;
                ofDirectory dir2(d);
                dir2.listDir();
                for(int j=0;j<dir2.size();j++){
                    vector<double> scene;
                    vector<string> movs;
                    string vidpath = dir2.getPath(j);
                    string origVidPath = vidpath;
                    if(dir2.getName(j)[0] != '.' &&
                            (vidpath.find(".mov")!=string::npos || vidpath.find(".mp4")!=string::npos ||
                       vidpath.find(".avi")!=string::npos ||
                       vidpath.find(".3gp")!=string::npos
                       || vidpath.find(".gif")!=string::npos
                       || vidpath.find(".webm")!=string::npos
                       || vidpath.find(".mkv")!=string::npos)){
                        vids.push_back(vidpath);
                        playerPaths.push_back(vidpath);
                        ofVideoPlayer* p = new ofVideoPlayer;
                        playerIntensities.push_back(0);
                        ps.push_back(p);
                        
                        string txtPath = vidpath;
                        ofStringReplace(txtPath, ".mov", ".txt");
                        ofStringReplace(txtPath, ".mp4", ".txt");
                        ofStringReplace(txtPath, ".mkv", ".txt");
                        ofStringReplace(txtPath, ".webm", ".txt");
                        ofStringReplace(txtPath, ".avi", ".txt");
                        ofStringReplace(txtPath, ".gif", ".txt");
                        string t = ofBufferFromFile(txtPath).getText();
                        if(t.compare("")){
                            vector<string > splitted = ofSplitString(t, "\n");
                            for(int x=0;x<splitted.size();x++){
                                vector<string> line = ofSplitString(splitted[x]," ");
                                scene.push_back(ofToDouble(line[0]));
                                if(line.size()>1)
                                    movs.push_back((line[1]));
                                else
                                    movs.push_back(" ");
                            }
                            ofFile vf(vidpath) ;
                            string absoluteVidPath = vf.getAbsolutePath();
                            playerScenes[absoluteVidPath] = scene;
                            playerScenesMovements[origVidPath] = movs;
                        }
                    }
                   
                }
                strdb.push_back(vids);
            }
        }
    }
示例#27
0
ofColor ofxToColor(string s) {
  ofColor c;
  if (ofxStringStartsWith(s,"#")) ofStringReplace(s,"#","0x"); //#123456
  if (ofxStringStartsWith(s,"0x")) return ofColor::fromHex(ofxToInteger(s)); //0x123456 (hex)
  else if (ofStringTimesInString(s,",")==3) return ofxToColor(ofxToVec4f(s)); //255,255,255,128 (r,g,b,alpha)
  else if (ofStringTimesInString(s,",")==2) return ofxToColor(ofxToVec3f(s)); //255,255,255 (r,g,b)
  else if (ofStringTimesInString(s,",")==1) return ofColor(ofxToVec2f(s).x,ofxToVec2f(s).y); //255,128 (gray,alpha)
  else if (ofStringTimesInString(s,",")==0) return ofColor(ofxToInteger(s)); //gray
  else {
    ofLogError() << "ofxToColor(" << s << ") is not a valid color";
    return ofColor();
  }
}
示例#28
0
void ofxLayout::populateExpressions(string& value){
    while(ofStringTimesInString(value, "{{") > 0){
        string leftDeliminator = "{{";
        string rightDeliminator = "}}";
        
        int leftDeliminatorPos = value.find(leftDeliminator);
        int rightDeliminatorPos = value.find(rightDeliminator);
        
        int dataKeyPos = leftDeliminatorPos+leftDeliminator.length();
        int dataKeyLength = rightDeliminatorPos-dataKeyPos;

        string dataKey = value.substr(dataKeyPos, dataKeyLength);
        
        if(data.count(dataKey) > 0){
            ofStringReplace(value, leftDeliminator+dataKey+rightDeliminator, data[dataKey]);
        }
        else{
            ofLogWarning("ofxLayout::populateExpressions","Could not find data value for key '{{"+dataKey+"}}', replaced with ''.");
            ofStringReplace(value, leftDeliminator+dataKey+rightDeliminator, "");
        }
    }
}
示例#29
0
void PMSc10Thanks::setup()
{
    //Primer ha de pillar el nom, sino No es pot generar l'fbo
    songName = PMSongSelector::getInstance().getSongname();
    userName = "******" + PMSharedSettings::getInstance().getUserName();
    dateName = ofGetTimestampString("%d/%m/%Y, %H%:%M");

    //carrega la imatge, alloca el fbo i genera fbo
    ofClear(0, 0, 0);
    printImage.load("TempRender.png");
    printFbo.allocate(1181, 1772, GL_RGB);
    drawIntoFbo();
    //exportem fbo i el guardem
    ofPixels pix;
    printFbo.readToPixels(pix);
//    ofSaveImage(pix, "toPrint.png", OF_IMAGE_QUALITY_BEST);
    ofStringReplace(songName, " ", "_");
    ofStringReplace(userName, " ", "_");
    ofStringReplace(dateName, " ", "_");
    ofStringReplace(dateName, "/", "_");
//    string saveFilename= "exports/toprint/"+songName+"-"+userName+"_"+dateName+".png";
//    cout<<songName<<"     "<<userName<<"       "<<dateName<<"         "<<saveFilename<<endl;
    string saveFilename = "exports/toprint/toPrint_" + ofGetTimestampString() + ".png";
    ofSaveImage(pix, saveFilename, OF_IMAGE_QUALITY_BEST);

    //imprimir fbo.

#if ENABLE_PRINTING
    string c = "lp -o media=Custom.4x6in -o page-left=0 -o page-right=0 -o page-top=0 -o page-bottom=0 " + ofToDataPath(saveFilename);
    system(c.c_str());
#endif

    countdown.set();
    countdown.setAlarm(COUNTDOWN_TIME * 1000);
    
    count=0;
}
示例#30
0
void Compiler::_replaceIncludes(std::string& fileContents)
{
    Poco::RegularExpression includesExpression("#include .*\n");
    Poco::RegularExpression::Match match;

    std::vector<std::string> includes;

    int numMatches = 0;
    std::size_t matchOffset = 0;

    while (matchOffset < fileContents.size())
    {
        if (includesExpression.match(fileContents, matchOffset, match) == 0) break;
        std::string include;
        includesExpression.extract(fileContents, match.offset, include);
        includes.push_back(include);
        matchOffset = match.offset + match.length;
        numMatches++;
    }

    includesExpression.subst(fileContents, "", Poco::RegularExpression::RE_GLOBAL);
    ofStringReplace(fileContents, "<includes>", ofJoinString(includes, ""));
    ofStringReplace(fileContents, "<line>", ofToString(includes.size()));
}