Cpp Styles 规范


#File name:

filename.cpp file
filename.h file


#include "file.h"
#include <systemPath/file.h>

#Class header
Class header files should have


#endif // CLASSNAME_H


class DActionServer

    int run(int port, char* argv[]);
    int run(int port);
    int signalServer();
    void test();
    void initDatabase();
    void selectDatabase(QString className, QString functionName);
    QByteArray getLowlevelSymbol(QString className, QString functionName);

     //Class Member
    int m_epollListeningFd;
    int m_epollConnectionsFd;
    int m_listeningFd;
    int m_numberOfRequests;


#class single inheritance:

class DAbsTime : public DValue
    void now();
    DAbsTime(int y, int m, int d, int h, int min, int s);
    void setDate(int y, int m, int d);
    void setTime(int h, int m, int s);
    QString encodeToString();
    void encodeFromString(QString paramString);
    QString getClassName();

    int m_year;
    int m_month;
    int m_day;
    int m_hour;
    int m_minute;
    int m_second;

#class multiple inheritance:

class DColor : public DValue, public QColor



struct DThreadData{
    long m_threadId;
    DActionServer * m_ptr;



for(int i = 0; i < size; i++)


int m_size;
int m_userID;
int m_inputType


std::cout << [](int i) -> int { return std::abs(i); } (-2016);


 * @brief read callback function for libcurl
 * @param pointer of max size (size*nmemb) to write data to
 * @param size size parameter
 * @param nmemb memblock parameter
 * @param userdata pointer to user data to read data from
 * @return (size * nmemb)
size_t RestClient::readCallback(void *data, size_t size, size_t nmemb,
                            void *userdata)
  /** get upload struct */
  RestClient::upload_object* u;
  u = reinterpret_cast<RestClient::upload_object*>(userdata);
  /** set correct sizes */
  size_t curl_size = size * nmemb;
  size_t copy_size = (u->length < curl_size) ? u->length : curl_size;
  /** copy data to buffer */
  memcpy(data, u->data, copy_size);
  /** decrement length and increment data pointer */
  u->length -= copy_size;
  u->data += copy_size;
  /** return copied size */
  return copy_size;


typedef void (*DActionPoint)(DAction * action, DValue * value);

#Name Space

namespace YourNameSpace {
inline namespace Action {
  void DoSomething();
using namespace YourNameSpace;


电子邮件地址不会被公开。 必填项已用*标注