| 1 | ## Coding style |
| 2 | |
| 3 | Coding style in PoDoFo follows the following general rules: |
| 4 | - Visual Studio formatting conventions (see for example [C# convetions](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)), where they apply to C/C++ like constructs; |
| 5 | - Capitalized case for **public** `MethodNames()`; |
| 6 | - Camel case for variables, parameters and fields (example `variableName`); |
| 7 | |
| 8 | Some language specific programming stylistic choices will be hard enforced, namely: |
| 9 | - C style programming (`malloc`/`free`, string formatting, etc.) shall be converted to equivalent modern C++ constructs/API calls, unless there's still no other modern C++ alternative (eg. `scanf`). Where possible `new`/`delete` semantics shall be replaced by use of shared pointers; |
| 10 | - `m_` and `s_` prefixes shall be used respectively for instance member and static fields/variables. For example `m_Value` or `s_instance`. No other Hungarian notation prefixes will be accepted; |
| 11 | - Implicit confersion from pointer types to bool (eg. `if (!ptr)` or `while (ptr)` conditionals) shall be converted to check for `nullptr`, eg. `if (ptr == nullptr)` or `while (ptr != nullptr)`; |
| 12 | - Increment/decrement operators shall always be postfixed in epxressions as in `it++`, unless the prefixed operator is necessary for the correctness of an algorithm or allows to shorten/optimize the code. |
| 13 | |
| 14 | It follows other lenient rules that are not truly enforced in all the code base, but that it is still recommended to follow: |
| 15 | |
| 16 | - Lower case method names for private methods used only in this class. Example `initOperation()`; |
| 17 | - Capitalized case for method for private or protected methods used outside of this class boundary, in case of class friendship or inheritance. For example `FriendMethod()` or `ProtectedMethod`; |
| 18 | - Lower case field names for private fields used only in this class boundary, for example `m_privateField`; |
| 19 | - Capitalized field names for private fields exposed by public getters/setters, example `m_Value`. |
| 20 | |
| 21 | Some examples of expected coding style can be found at the following permalinks: |
| 22 | |
| 23 | - [PdfEncoding](https://github.com/pdfmm/pdfmm/blob/588ee42ca16e0996c73a7d7887d189672ae4cc18/src/pdfmm/base/PdfEncoding.cpp) |
| 24 | - [PdfCharCodeMap](https://github.com/pdfmm/pdfmm/blob/588ee42ca16e0996c73a7d7887d189672ae4cc18/src/pdfmm/base/PdfCharCodeMap.cpp) |
| 25 | - [PdfFontFactory](https://github.com/pdfmm/pdfmm/blob/588ee42ca16e0996c73a7d7887d189672ae4cc18/src/pdfmm/base/PdfFontFactory.cpp) |
| 26 | - [PdfTrueTypeSubset](https://github.com/pdfmm/pdfmm/blob/588ee42ca16e0996c73a7d7887d189672ae4cc18/src/pdfmm/base/PdfFontTrueTypeSubset.cpp) |