Obsah
Základní údaje - Konvence
Zde jsou sepisovány pravidla, která by se při vývoji měla dodržovat.
Formátování kódu
Formátování kódu obstarává program Astyle s tímto nastavením (.astylerc):
indent=spaces=2 brackets=linux indent-classes indent-switches indent-namespaces max-instatement-indent=50 min-conditional-indent=8 pad=oper one-line=keep-statements one-line=keep-blocks convert-tabs
Jména datových typů a struktur
Všechny datové typy, struktury a promenné pojmenovaváme anglicky.
- Jméno třídy začíná vždy velkým C, každé další počáteční písmeno je také velké.
- Jméno struktur začína vždy velkým T, každé další počáteční písmeno je také velké.
- Jméno enumu začíná vždy velkým E, každé další počáteční písmeno je také velké.
- Jméno property třídy začíná skupinou m_ pak následuje malé písmeno, každé další počáteční písmeno je také velké.
// příklad třídy a property class CServerEnvironment { private: int m_intProperty; }; // příklad struktury struct TScriptFile; // příklad enumu enum EFourDirections;
Jména metod a funkcí
Jména metod a funkcí začínají vždy malým písmenem, každé další počáteční písmeno je velké. Jména jsou anglicky.
int myFunction(int param); CMyClass::staticMethod(5);
Jména souborů
Všechna jména souborů v rámci projektu mohou obsahovat jen malá písmena a znaky ‘.’, ‘_’, ‘-’.
Hlavička (*.h)
/* * Pax Imperialis MMORPG Project by Arcanea <www.arcanea.net> * Copyright (C) 2007 Michal Rost, Josef Smolka * * <file>.h * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * Class / Struct / Enum descritpion */
Hlavička (*.cpp)
/*
* Pax Imperialis MMORPG Project by Arcanea <www.arcanea.net>
* Copyright (C) 2007 Michal Rost, Josef Smolka
*
* <file>.cpp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/