Overview
The neroshop code base is divided into 4 parts for flexibility, readability and just keeping the code organized.
console
: contains the code for the neroshop command line interface, also known asneroshop-console
core
: contains the core functionality of neroshopdaemon
: contains the code for the neroshop daemon executable, also known asneromon
gui
: contains the code that interfaces withQML
, a JavaScript-like language through theQt
C++ library and interacts with the GUI.
The core
directory is also divided into sections:
.
: the root directory which contains marketplace-specific code that have to do with products, listings, orders, etc.crypto
: contains cryptographic algorithms such as SHA-256 hash functions and public-key encryption algorithms like RSA.database
: contains code for specific databases such as sqlite3 or lmdbnetwork
: contains code for privacy networks such as Tor and i2p.price
: contains APIs from several cryptocurrency price aggregators and cryptocurrency exchanges used for fetching currency prices.protocol
: contains code for certain types of protocolstools
: contains helper and utility codewallet
: contains the different kinds of blockchain wallets supported by neroshop
The entire source code can be found in the src/
folder and the code for the user interface can be found in the qml/
folder.
Naming conventions
Naming conventions - snake_case vs camelCase
You may use snake_case
any where in the code but camelCase
is only allowed in the gui
and qml
code.
Variable names should also be in snake_case
form though it is not required in the gui
portion of the codebase.
Naming conventions - files
File names should be lowercase and file names containing separate words should be separated using
an underscore _
.
All cpp
files should have a header file, with files containing a main
function being the exception
to the rule. Headers do not need their own cpp
files.
Include order and placement
Place the minimum necessary includes into a header file, as anyone else who uses that header will be forced to #include
all of them too. In larger projects, this leads towards slower builds, dependency issues, and all sorts of other nastiness.
Any includes not used in the header file, but used in the source file should be added to the source file instead.
Use forward declaration when necessary.
Header files should be included in the particular order (This won't be enforced though so ignore if you want):
1. hpp file corresponding to this cpp file (if applicable)
1.1. A blank line
2. headers from the same component,
2.1. A blank line
3. headers from other components (third party)
3.1. A blank line
4. system headers (with C system headers being first and C++ system headers being last)
Namespace usages
- Never use
using namespace std;
as naming conflictions could occur. Usestd::
instead. This applies to all namespaces. - Namespaces must be
lowercase
and namespaces containing separate words should be separated using an underscore_
.
Indentation
4
spaces for each line of code. No tabs allowed.
Reminder
Files from console
, daemon
, and gui
can all depend on files from core
but core
must never depend on either of them.
Most importantly, core
MUST NOT depend on Qt
as it is intended to be solely used for the user interface and the GUI library can be replaced at anytime.