]> rtime.felk.cvut.cz Git - boost-statechart-viewer.git/commitdiff
Whitespace
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 29 Jul 2012 21:02:18 +0000 (23:02 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 29 Jul 2012 21:02:18 +0000 (23:02 +0200)
src/iooper.h
src/stringoper.h

index 8565a92f68e5a0d3d9b66bcacf91ba07025768ff..a934ac55a888e16bf3be00a07875462b8a9c8ec5 100644 (file)
@@ -1,6 +1,6 @@
-/** @file */ 
-////////////////////////////////////////////////////////////////////////////////////////  
-//    
+/** @file */
+////////////////////////////////////////////////////////////////////////////////////////
+//
 //    This file is part of Boost Statechart Viewer.
 //
 //    Boost Statechart Viewer is free software: you can redistribute it and/or modify
@@ -30,11 +30,11 @@ using namespace std;
 * This class provides saving information about state machine to a specified output file. It saves states and transitions and also it creates the transition table.
 */
 class IO_operations
-{      
+{
        list<string> transitions; /** list of transitions */
        list<string> states; /** list of states */
        list<string> events; /** list of events */
-       string outputFilename; 
+       string outputFilename;
        string name_of_machine;
        string name_of_first_state;
        string *table; /** transition table. It is being allocated when starting the creation of output file. */
@@ -50,7 +50,7 @@ class IO_operations
                                if(model.compare(0,model.size(),table[i])==0) return i;
                        }
                }
-               else 
+               else
                {
                        for(int i = 1;i<rows;i++)
                        if(model.compare(0,model.size(),table[i*cols+2])==0) return i;
@@ -74,12 +74,12 @@ class IO_operations
        {
                delete [] table;
        }
-       
+
        void setEvents(list<string> events) /** Set list of events to an attribute */
        {
                this->events = events;
        }
-       
+
        void setTransitions(list<string> transitions) /** Set list of transitions to an attribute */
        {
                this->transitions = transitions;
@@ -95,7 +95,7 @@ class IO_operations
                name_of_machine = name_of_FSM;
        }
 
-       void setNameOfFirstState(string first_state) /** Set name of start state to an attribute */ 
+       void setNameOfFirstState(string first_state) /** Set name of start state to an attribute */
        {
                name_of_first_state = first_state;
        }
@@ -113,7 +113,7 @@ class IO_operations
                }
                return false;
        }
-       
+
        bool write_states(ofstream& filestr) /** This method write states to the output file and also to transition table. */
        {
                int pos1, pos2, cnt, subs, num_start, orto = 0;
@@ -132,12 +132,12 @@ class IO_operations
                for(int i = 0;i<=cnt;i++)
                {
                        if(i == cnt) sState[i] = str;
-                       else 
+                       else
                        {
                                sState[i] = str.substr(0,str.find(','));
                                str = str.substr(str.find(',')+1);
                        }
-               }               
+               }
                for(list<string>::iterator i = nstates.begin();i!=nstates.end();i++) // write all states in the context of the automaton
                {
                        state = *i;
@@ -147,19 +147,19 @@ class IO_operations
                                orto = 1;
                                if(cnt>1)cnt = 2;
                        }
-                       if(cnt==1) 
+                       if(cnt==1)
                        {
                                pos1 = state.find(",");
-                               if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1));                             
-                               else ctx = cut_namespaces(state.substr(pos1+1));                        
+                               if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1));
+                               else ctx = cut_namespaces(state.substr(pos1+1));
                                if(ctx.compare(0,context.length(),context)==0 && context.length()==ctx.length())
                                {
                                        str = cut_namespaces(state.substr(0,pos1));
-                                       if(test_start(sState,str,num_start)) 
+                                       if(test_start(sState,str,num_start))
                                        {
                                                filestr<<str<<" [peripheries=2];\n";
                                                table[cols*nState] = "*";
-                                       }                       
+                                       }
                                        else filestr<<str<<"\n";
                                        table[cols*nState+2] = str;
                                        table[cols*nState+1] = context;
@@ -172,19 +172,19 @@ class IO_operations
                        {
                                pos1 = state.find(",");
                                pos2 = state.substr(pos1+1).find(",")+pos1+1;
-                               ctx = cut_namespaces(state.substr(pos1+1,pos2-pos1-1)); 
+                               ctx = cut_namespaces(state.substr(pos1+1,pos2-pos1-1));
                                if(ctx.compare(0,context.length(),context)==0 && context.length()==ctx.length())
-                               {                               
+                               {
                                        str = cut_namespaces(state.substr(0,pos1));
-                                       if(test_start(sState,str,num_start)) 
+                                       if(test_start(sState,str,num_start))
                                        {
                                                filestr<<str<<" [peripheries=2];\n";
                                                table[cols*nState] = "*";
                                        }
                                        else filestr<<str<<"\n";
                                        table[cols*nState+2] = str;
-                                       table[cols*nState+1] = context;                 
-                                       nState+=1;                                      
+                                       table[cols*nState+1] = context;
+                                       nState+=1;
                                }
                        }
                }
@@ -193,7 +193,7 @@ class IO_operations
                while(!nstates.empty()) // substates ?
                {
                        state = nstates.front();
-                       filestr<<"subgraph cluster"<<subs<<" {\n";                      
+                       filestr<<"subgraph cluster"<<subs<<" {\n";
                        pos1 = state.find(",");
                        pos2 = state.substr(pos1+1).find(",")+pos1+1;
                        if(pos1 == pos2) return false;
@@ -207,12 +207,12 @@ class IO_operations
                        for(int i = 0;i<=cnt;i++)
                        {
                                if(i == cnt) sState[i] = str;
-                               else 
+                               else
                                {
                                        sState[i] = str.substr(0,str.find(','));
                                        str = str.substr(str.find(',')+1);
                                }
-                       }       
+                       }
                        nstates.pop_front();
                        for(list<string>::iterator i = nstates.begin();i!=nstates.end();i++)
                        {
@@ -222,11 +222,11 @@ class IO_operations
                                {
                                        orto = 1;
                                        if(cnt>1)cnt = 2;
-                               }                               
+                               }
                                if(cnt==1)
                                {
                                        pos1 = state.find(",");
-                                       if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1));                             
+                                       if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1));
                                        else ctx = cut_namespaces(state.substr(pos1+1));
                                        if(ctx.compare(0,context.length(),context)==0 && context.length()==ctx.length())
                                        {
@@ -256,7 +256,7 @@ class IO_operations
                                                {
                                                        filestr<<str<<" [peripheries=2];\n";
                                                        table[cols*nState]="*";
-                                               }                                       
+                                               }
                                                else filestr<<str<<"\n";
                                                table[cols*nState+2] = str;
                                                table[cols*nState+1] = context;
@@ -266,7 +266,7 @@ class IO_operations
                        }
                        filestr<<"}\n";
                        subs+=1;
-                       delete [] sState;       
+                       delete [] sState;
                }
                return true;
        }
@@ -279,9 +279,9 @@ class IO_operations
                {
                        params = *i;
                        if(count(params,',')==2)
-                       {                       
+                       {
                                pos1 = params.find(",");
-                               if(pos1==0) 
+                               if(pos1==0)
                                {
                                        dest = "(deferred)";
                                        pos2 = params.rfind(",");
@@ -301,7 +301,7 @@ class IO_operations
                                dest.append(",");
                                table[find_place(state,2)*cols+find_place(event,1)]+=dest;
                        }
-               }               
+               }
                return;
        }
 
@@ -317,23 +317,23 @@ class IO_operations
 
        void save_to_file() /** Create output file stream and write there the name of state machine. It controls the whole process of writing into output files. */
        {
-               if(!name_of_first_state.empty())        
-               {       
+               if(!name_of_first_state.empty())
+               {
                        ofstream filestr(outputFilename.c_str());
                        filestr<<"digraph "<< name_of_machine<< " {\n";
                        cols = events.size()+3;
                        rows = states.size()+1;
                        table = new string [cols*rows];
-                       fill_table_with_events();                       
-                       if(!write_states(filestr)) 
+                       fill_table_with_events();
+                       if(!write_states(filestr))
                        {
                                cerr<<"Error during writing states.\n";
-                               filestr<<"}";           
+                               filestr<<"}";
                                filestr.close();
-                               return;                 
+                               return;
                        }
                        write_transitions(filestr);
-                       filestr<<"}";           
+                       filestr<<"}";
                        filestr.close();
                        // call write_reactions();
                        print_table();
@@ -383,17 +383,17 @@ class IO_operations
                                str = table[i*cols+j];
                                nbr = count(str,',');
                                if(nbr>0)
-                               {                               
+                               {
                                        cout<<left<<str.substr(0,str.find(","))<<" | ";
-                                       if(nbr>1) 
+                                       if(nbr>1)
                                        {
                                                table[i*cols+j] = str.substr(str.find(",")+1);
                                                multiline = 1;
                                        }
                                        else table[i*cols+j]="";
-                                               
+
                                }
-                               else 
+                               else
                                {
                                        cout<<left<<str<<" | ";
                                        table [i*cols+j]="";
index 2d91b044c876e5e34ec45d4a0fdc791e6a83550b..a16030992064c82bcc049a71820e6e480672063c 100644 (file)
@@ -1,6 +1,6 @@
-/** @file */ 
-////////////////////////////////////////////////////////////////////////////////////////  
-//    
+/** @file */
+////////////////////////////////////////////////////////////////////////////////////////
+//
 //    This file is part of Boost Statechart Viewer.
 //
 //    Boost Statechart Viewer is free software: you can redistribute it and/or modify
@@ -22,7 +22,7 @@
 
 using namespace std;
 using namespace clang;
-       
+
 string clean_spaces(const string line) /** Remove gaps from string.*/
 {
        unsigned i;
@@ -48,8 +48,8 @@ string cut_commentary(const string line) /** This function cuts commentaries at
 
 string get_line_of_code(const string code) /** Thie function return the line of code that belongs to a declaration. The output string line doesn't have gaps and commentaries.*/
 {
-       string ret;     
-       unsigned i;     
+       string ret;
+       unsigned i;
        for(i = 0;i<code.length();i++)
        {
                if(code[i]=='\n'||code[i]=='{') break;
@@ -57,11 +57,11 @@ string get_line_of_code(const string code) /** Thie function return the line of
        ret = code.substr(0,i);
        ret = clean_spaces(ret);
        return cut_commentary(ret);
-} 
+}
 
 string get_return(const string code) /** Return return statement. */
 {
-       string ret;     
+       string ret;
        unsigned i;
        for(i = 0;i<code.length();i++)
        {
@@ -145,7 +145,7 @@ string get_next_base(const string line) /** Get next super classes of this decla
                if(line[i]==',' && brackets == 0) break;
        }
        return line.substr(i+1);
-}  
+}
 
 string get_first_base(const string line) /** Get the first super class of this declarations. */
 {
@@ -158,19 +158,19 @@ string get_first_base(const string line) /** Get the first super class of this d
                if(line[i]==',' && brackets == 0) break;
        }
        return line.substr(0,i);
-}  
+}
 
 bool is_state(const string line) /** Test if this declaration is a state. It is used to test the base classes. */
 {
        if(cut_namespaces(line).compare(0,12,"simple_state")==0)
        {
-               return true;    
+               return true;
        }
        else
        {
                if(cut_namespaces(line).compare(0,5,"state")==0)
                {
-                       return true;    
+                       return true;
                }
                return false;
        }
@@ -204,10 +204,10 @@ bool is_list(const string line) /** Test if this decl is mpl::list. */
        {
                if(line[i]=='<') break;
                if(line[i]==':' && line[i+1]==':') pos = i+2;
-       }       
+       }
        if(line.substr(pos).compare(0,4,"list")==0)
        {
-               return true;    
+               return true;
        }
        else
        {
@@ -228,7 +228,7 @@ string get_inner_part(const string line) /** Get inner part of the list. */
        {
                if(str[i]=='<') pos+=1;
                if(str[i]=='>')
-               { 
+               {
                        if(pos==0) break;
                        else pos-=1;
                }
@@ -249,11 +249,11 @@ int get_model(const string line) /** Test the string to has a specified model. *
                case 7 : if(str.compare(0,7,"transit")==0) return 6;
                                   break;
                case 8 : if(str.compare(0,8,"deferral")==0) return 13;
-                                  break;               
+                                  break;
                case 10 : if(str.compare(0,10,"transition")==0) return 11;
                                         break;
                case 11 : if(str.compare(0,11,"defer_event")==0) return 7;
-                                        break; 
+                                        break;
                case 13 : if(str.compare(0,13,"state_machine")==0) return 3;
                                         break;
                case 15 : if(str.compare(0,15,"custom_reaction")==0) return 12;
@@ -269,18 +269,18 @@ string get_params(string line) /** Return parameters of the specified transition
        int pos_end = line.rfind(">");
        return line.substr(pos_front,pos_end-pos_front);
 }
-       
+
 string find_states(const CXXRecordDecl *cRecDecl, string line) /** test if the struct/class is he state (must be derived from simple_state or state). */
-{      
+{
        string super_class = get_super_class(line), base, params;
        if(cRecDecl->getNumBases()>1)
        {
-               
+
                for(unsigned i = 0; i<cRecDecl->getNumBases();i++ )
                {
                        if(i!=cRecDecl->getNumBases()-1) base = get_first_base(super_class);
                        else base = super_class;
-                       if(is_state(super_class)) 
+                       if(is_state(super_class))
                        {
                                params = get_params(super_class);
                        }
@@ -291,18 +291,18 @@ string find_states(const CXXRecordDecl *cRecDecl, string line) /** test if the s
                }
        }
        else
-       {               
-               if(is_state(super_class)) 
-               {                       
+       {
+               if(is_state(super_class))
+               {
                        params = get_params(super_class);
                }
                else params = "";
        }
        return params;
 }
-               
+
 string find_name_of_machine(const CXXRecordDecl *cRecDecl, string line) /** Find name of the state machine and the start state. */
-{      
+{
        string super_class = get_super_class(line), base, params;
        if(cRecDecl->getNumBases()>1)
        {
@@ -321,7 +321,7 @@ string find_name_of_machine(const CXXRecordDecl *cRecDecl, string line) /** Find
                }
        }
        else
-       { 
+       {
                if(get_model(super_class)==3)
                {
                        params = get_params(super_class);
@@ -331,9 +331,9 @@ string find_name_of_machine(const CXXRecordDecl *cRecDecl, string line) /** Find
 }
 
 string find_transitions (const string name_of_state, string line) /** Traverse all methods for finding declarations of transitions. */
-{      
+{
        string dest, params, base, trans;
-       int num = count(line,'<');      
+       int num = count(line,'<');
        if(num>1)
        {
                num-=1;
@@ -344,7 +344,7 @@ string find_transitions (const string name_of_state, string line) /** Traverse a
        }
        for(int j = 0;j<num;j++)
        {
-               if(j!=num-1) base = get_first_base(line);                       
+               if(j!=num-1) base = get_first_base(line);
                else base = line;
                if(get_model(base)>10)
                {
@@ -353,19 +353,19 @@ string find_transitions (const string name_of_state, string line) /** Traverse a
                        else dest = "";
                        dest.append(name_of_state);
                        params = get_params(base);
-                       dest.append(",");                                                       
+                       dest.append(",");
                        dest.append(params);
-                       trans.append(dest);             
+                       trans.append(dest);
                        if(j!=num-1) trans.append(";");
                }
                line = get_next_base(line);
        }
        if(trans[trans.length()-1]==';') return trans.substr(0,trans.length()-1);
-       else return trans;      
+       else return trans;
 }
 
 bool find_events(const CXXRecordDecl *cRecDecl, string line) /** This function provides testing if the decl is decl of event*/
-{      
+{
        string super_class = get_super_class(line), base, params;
        if(cRecDecl->getNumBases()>1)
        {
@@ -381,9 +381,8 @@ bool find_events(const CXXRecordDecl *cRecDecl, string line) /** This function p
                }
        }
        else
-       { 
+       {
                if(get_model(super_class)==1)return true;
        }
        return false;
 }
-