C++ naming::rules



Keywords: c++ naming, cpp naming, code style, code formating, coding convention.
Description: My vison of naming convention in C++ programing language.


Introduction:
This naming define only the prefix.
There are four subtypes: soft, hard, soft extreme i hard extreme.
TOC
  1. Class's members
    1. instance
    2. function
    3. typedef
    4. enum
    5. class
    6. union
  2. Global things
    1. instance
    2. function
    3. typedef
    4. enum
    5. class
    6. union
    7. define
  3. Function's things
    1. instance
    2. parameters
    3. define
    4. enum
    5. funnction
    6. typedef
    7. class
    8. union
  4. Templates
    1. parameters
  5. Namespace
  6. Very very brief

1. Class's members
1.1 instance
1.1.1 Soft
M_       plain  
Ms_       static member  

1.1.2 Hard
M0_       public member  
M0s_       public static member  
M1_       protected member  
M1s_       protected static member  
M2_       private member  
M2s_       private static member  

1.1.3 Soft extreme
M_       Plain member  
Ms_       Static member  
Mc_       const member  
Msc_      Static const member  

1.1.4 Hard extreme
M0_       public Plain member  
M0s_       public Static member  
M0c_       public const member  
M0sc_       public Static const member  
M1_       protected Plain member  
M1s_       protected Static member  
M1c_       protected const member  
M1sc_       protected Static const member  
M2_       private Plain member  
M2s_       private Static member  
M2c_       private const member  
M2sc_       private Static const member  
NOTE: There is no default what is M_ if you mix hard and soft style.


1.2 Function
1.2.1 Soft
F_       plain function  
Fs_       static function  
Fv_       virtual function  

1.2.2 Hard
F0_       public function  
F0s_       public static function  
F1_       protected function  
F1s_       protected static function  
F2_       private function  
F2s_       private static function  

1.2.3 Soft Extreme
F_       Plain function  
Fs_       Static function  
Fv_       virtual function  
Fc_       Plain const function  
Fvc_       virtual const function  

1.1.4 Hard Extreme
F0_       public function  
F0s_       public Static function  
F0v_       public virtual function  
F0c_       public const function  
F0vc_       public virtual const function  
F1_       protected function  
F1s_       protected Static function  
F1v_       protected virtual function  
F1c_       protected const function  
F1vc_       protected virtual const function  
F2_       private function  
F2s_       private Static function  
F2v_       private virtual function  
F2c_       private const function  
F2vc_       private virtual const function  
NOTE: By default F_ are public if you mix hard and soft style.


1.3 Typedef
1.3.1 Soft
T_       typedef  

1.3.2 Hard
T0_       public  
T1_       protected  
T2_       private  
NOTE: By default T_ is public if you mix hard and soft style.

1.4 Enums
1.4.1 Soft
Ee_       enum type  
En_       enum number  

1.4.2 Hard
Ee0_       public enum type  
En0_       public enum number  
Ee1_       protected enum type  
En1_       protected enum number  
Ee2_       private enum type  
En2_       private enum number  
NOTE: By default E_ is public if you mix hard and soft style.


1.5 Class
1.5.1 Soft
C_       class  

1.5.2 Hard
C0_       public  
C1_       protected  
C2_       private  
NOTE: By default C_ is public if you mix hard and soft style.


1.6 Union
1.6.1 Soft
U_       union  

1.6.2 Hard
U0_       public  
U1_       protected  
U2_       private  
NOTE: By default U_ is public if you mix hard and soft style



2. Global things
2.1 typedef
GT_       typedef  
GTs_       local typedef  

2.2 functions
GF_       free function  
GFs_       local free function  


2.3 enums
GEe_       Globl enum type  
GEn_       Globl enum number  
GEes_       Local enum type  
GEns_       Local enum number  


2.4. instances
2.4.1 Soft / Hard
GI_       Global  
GIs_       Local  

2.4.1 Extreme
GI_       Global instance.  
GIs_       Local instance. ("static")  
GIc_       Global const instance.  
GIsc_       Local const instance.  

2.5 Class
GC_       global class  
GCs_       local class ("static")  


2.6 Union
GU_       Global union  
GUs_       Local union ("static")  


2.7 Define
Dh_       This macro prevent double header inclusion.  
D_       Global macro who acts as function.  
Dc_       Global macro who acts as constant.  
Dt_       Global text replacer.  
Ds_       Local macro who acts as function.  
Dsc_       Local macro who acts as constant.  
Dst_       Local text replacer.  
DP_ or ( DA_ )       Parameter (Argument) of defines  
DI_       Instance in define.  
Dd_       Translation directive.  



3. Function's stuffs
3.1 Instances in functions
3.1.1 Soft / Hard
I_       Plain  
Is_       static  
Ir_       This instance will be returned.  
3.1.2 Extreme
I_       Plain  
Is_       Static  
Ir_       This instance will be returned  
Ic_       Const  
Isc_       Static const  
Irc_       This const instance will be returned  
Irsc_       This static const instance will be returned  

3.2 Parameters
For P_ vs. A_ See Programming languages ( ISO/IEC 14882:1998(E) ) - C++ section -1.3.1 argument- and -1.3.9 parameter-.

3.2.1 Soft
P_       parameter  
3.2.2 Hard
P_       input/output  
Pi_       input  
Po_       output  

3.3 Define
Df_       macro who acts as function.  
Dfc_       macro who acts as constant.  
Dfd_       translation directive  
Dft_       Text replacer  

3.4 Enum
Eef_       enum type.  
Enf_       enum number.  


3.5 Rest
Cf_       class  
Uf_       union  
Tf_       typedef.  
Ff_       function.  
L_       labela  



4. Template
4.1 parameters
N_       typename  
Ne_       enum  
Ni_       integer  
Nt_       template  
N1_       nested templates parameter  


5. Namespace
S_       namespace


6. Very Very Brief
C_       class  
D_       define  
Ee_       enum type  
En_       enum number 
F_       functions  
G_       globals  
I_       instances  
M_       Class's members  
N_       template parameters  
P_       function parameters  
S_       nameSpace  
T_       typedefs  
U_       union