Code Styler: Custom Styles and List of Rules of the various Standard Styles - page 2

 
And in dual screen I have notepad++
 

Fernando Carreiro:

How can we see what rules are implemented for the current styles already available?


    I like how in the "MetaQuotes" classes style, the inside of the class looks like a clean list of attributes and functions

    enum ONE_TWO_THREE
      {
       ONE,
       TWO,
       THREE
      };
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    class MQLStyleClass
      {
    private:
       int               integer;
       datetime          time;
    
    public:
                         MQLStyleClass(void);
                        ~MQLStyleClass(void);
       double            GetLastClosePrice(void) {return(iClose(_Symbol, _Period, 0));}
       datetime          GetLastDateTime(void) {return(iTime(_Symbol, _Period, 0);}
       string            GetTimeString(datetime inp_time) {return(TimeToString(inp_time, TIME_DATE | TIME_SECONDS));}
       int               GetHighestHigh(int bars);
       ONE_TWO_THREE     Switchfunction(ONE_TWO_THREE one_two_three);
      };
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    int   MQLStyleClass::GetHighestHigh(int bars)
      {
       int     res = 0;
       double   high = 0.0;
    
       for(int i = 0; i < bars; i++)
         {
          if(high == 0.0)
             high = iHigh(_Symbol, _Period, i);
    
          if(high < iHigh(_Symbol, _Period, i))
             high = iHigh(_Symbol, _Period, 0);
         }
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE  MQLStyleClass::Switchfunction(ONE_TWO_THREE one_two_three)
      {
       ONE_TWO_THREE result = ONE;
    
       switch(one_two_three)
         {
          case ONE :
             FunctionOne();
             break;
          case TWO :
             FunctionTwo();
             break;
          case THREE :
             FunctionThree();
             break;
         }
      }
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE FunctionOne(void) {return(ONE);}
    ONE_TWO_THREE FunctionTwo(void) {return(TWO);}
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE FunctionThree(void) {return(THREE);}
    //+------------------------------------------------------------------+



    On the other hand I like the "google"/"mozilla"/"java" function style, where the curly braces meet on the top left corner of a rectangle that encompasses the function it helps with nested functions

    enum ONE_TWO_THREE {
       ONE,
       TWO,
       THREE
    };
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    class MQLStyleClass {
     private:
       int               integer;
       datetime          time;
    
     public:
                         MQLStyleClass(void);
                        ~MQLStyleClass(void);
       double            GetLastClosePrice(void) {
          return(iClose(_Symbol, _Period, 0));
       }
       datetime          GetLastDateTime(void) {
          return(iTime(_Symbol, _Period, 0);
       }
       string            GetTimeString(datetime inp_time) {
          return(TimeToString(inp_time, TIME_DATE | TIME_SECONDS));
       }
       int               GetHighestHigh(int bars);
       ONE_TWO_THREE     Switchfunction(ONE_TWO_THREE one_two_three);
    };
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    int   MQLStyleClass::GetHighestHigh(int bars) {
       int     res = 0;
       double   high = 0.0;
    
       for(int i = 0; i < bars; i++) {
          if(high == 0.0)
             high = iHigh(_Symbol, _Period, i);
    
          if(high < iHigh(_Symbol, _Period, i))
             high = iHigh(_Symbol, _Period, 0);
       }
    }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE  MQLStyleClass::Switchfunction(ONE_TWO_THREE one_two_three) {
       ONE_TWO_THREE result = ONE;
    
       switch(one_two_three) {
       case ONE :
          FunctionOne();
          break;
       case TWO :
          FunctionTwo();
          break;
       case THREE :
          FunctionThree();
          break;
       }
    }
    
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE FunctionOne(void) {
       return(ONE);
    }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE FunctionTwo(void) {
       return(TWO);
    }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    ONE_TWO_THREE FunctionThree(void) {
       return(THREE);
    }
    //+------------------------------------------------------------------+
    

    Unfortunately in the latter the classes don't look so good. It would be nice if the inside of classes would be an exception to the style rule, like it obviously is in the "MetaQuotes" style.