xlight
This doc just for this project, desc the C++ code style
// Copyright (c) 2014, HelightXu
// Author: Zhwen Xu<[email protected]>
// Created: 2014-01-01
// Description:
//
#ifndef FOO_BAR_BAZ_H_
#define FOO_BAR_BAZ_H_
...
#endif // FOO_BAR_BAZ_H_
- C system files.
- C++ system files.
- Other libraries .h files.
- Your project .h files.
- class name begin captal lettel, like Cxxx, NameServer
- struct begin St, like Stxxx, StFileInfo
- enum begin En, like Enxxx, EnTreeCode
- member for class start _, like _size, _len, struct dont
- member of enum all capital letter
- method for class are capital first letter without '_' like GetFileInfo
class BaseThread
{
public:
BaseThread();
~BaseThread();
private:
bool _alive;
uint8_t _thread_count;
};
struct StFileInfo
{
std::string _name;
uint32_t _size;
};
enum EnFileOpCode
{
OPRET_OK = 0,
OPRET_NOT_EXIST = 1000,
OPRET_EXIST = 1001
};
- Has space between key words and "(" ,between operator and val
- {} has single line
for (uint8_t i = 0; i < 10; ++i)
{
......
}
while (_stop)
{
......
};
if (_test)
{
......
}
else
{
......
}
1.For short