Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ##### main.cpp
- // ##### Used for IOTest
- // ##### Created by WeltEnSTurm on Feb 2, 2011
- #include <fstream>
- #include <string>
- #include <iostream>
- using namespace std;
- typedef unsigned int uint;
- bool processcmd(string cmd, string& data){
- cout<<"CMD: "<<cmd<<endl;
- if(cmd=="FMT"){
- string tmp;
- for(uint i=0; i<data.size(); i++){
- char lc=data[i];
- if(lc==' ' || lc=='/t' || lc=='/n' || lc=='{' || lc=='}' || lc==';')
- if(tmp.size()){
- cout<<tmp<<endl;
- data=data.substr(i,data.size()-i);
- return true;
- }
- else
- tmp+=lc;
- }
- }if(cmd=="TRI"){
- uint start=data.find_first_of('{');
- uint end=data.find_first_of('}');
- string tmp=data.substr(start, data.size()-end);
- data=data.substr(end, data.size()-end);
- cout<<tmp<<endl;
- return true;
- }
- }
- int main(){
- ifstream in;
- cout<<"opening files/model.umf"<<endl;
- in.open("files/model.umf");
- string smdata;
- char buf[1024];
- while(in.good()){
- in.getline(buf,1024);
- smdata+=buf;
- }
- string tcmd;
- for(uint i=0; i<smdata.size(); i++){
- char lc=smdata[i];
- if(lc==' ' || lc=='/t' || lc=='/n' || lc=='{' || lc=='}' || lc==';')
- if(tcmd.size()){
- smdata=smdata.substr(i, smdata.size()-i);
- if(processcmd(tcmd, smdata)) i=0;
- }
- else{
- tcmd+=lc;
- cout<<lc<<endl;
- }
- }
- in.close();
- cout<<"done"<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment