-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add clang-format #291
base: main
Are you sure you want to change the base?
Add clang-format #291
Changes from all commits
89c252b
0ee6ff9
a9b9d33
4120d8a
eb44c96
01866a7
15c3543
77eb101
5bfa766
4c3c36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BasedOnStyle: Google | ||
Language: Cpp | ||
TabWidth: 8 | ||
IndentWidth: 2 | ||
UseTab: Never | ||
IndentCaseLabels: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AccessModifierOffset: -4 | ||
IncludeCategories: | ||
- Regex: '^((<|")(pch.h))' | ||
Priority: -1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
# clang-format support | ||
function(add_clang_format_target) | ||
set(options) | ||
set(oneValueArgs) | ||
set(multiValueArgs SOURCES) | ||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" | ||
"${multiValueArgs}" ${ARGN}) | ||
if(NOT ${PROJECT_NAME}_CLANG_FORMAT_BINARY) | ||
find_program(${PROJECT_NAME}_CLANG_FORMAT_BINARY clang-format) | ||
endif() | ||
|
||
message(STATUS ${ARG_SOURCES}) | ||
|
||
if(${PROJECT_NAME}_CLANG_FORMAT_BINARY) | ||
add_custom_target(clang-format | ||
COMMAND ${${PROJECT_NAME}_CLANG_FORMAT_BINARY} --verbose | ||
-i ${ARG_SOURCES} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
message(STATUS "Format the project using the `clang-format` target (i.e: cmake --build build --target clang-format).\n") | ||
endif() | ||
endfunction() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,20 +15,24 @@ class DbConnection : boost::noncopyable { | |
DbResult* pCurrentResult_; | ||
bool transacting_; | ||
|
||
public: | ||
|
||
public: | ||
DbConnection(); | ||
~DbConnection(); | ||
|
||
public: | ||
void | ||
connect(const Nullable<std::string>& host, const Nullable<std::string>& user, const Nullable<std::string>& password, | ||
const Nullable<std::string>& db, unsigned int port, const Nullable<std::string>& unix_socket, | ||
unsigned long client_flag, const Nullable<std::string>& groups, const Nullable<std::string>& default_file, | ||
const Nullable<std::string>& ssl_key, const Nullable<std::string>& ssl_cert, | ||
const Nullable<std::string>& ssl_ca, const Nullable<std::string>& ssl_capath, | ||
const Nullable<std::string>& ssl_cipher, | ||
int timeout, bool reconnect); | ||
public: | ||
void connect(const Nullable<std::string>& host, | ||
const Nullable<std::string>& user, | ||
const Nullable<std::string>& password, | ||
const Nullable<std::string>& db, unsigned int port, | ||
const Nullable<std::string>& unix_socket, | ||
unsigned long client_flag, const Nullable<std::string>& groups, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we ensure that each argument gets its own line in these cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think now it's not possible. Clang-format add new line if arguments are to long, but it doesn't check the context of this lines. |
||
const Nullable<std::string>& default_file, | ||
const Nullable<std::string>& ssl_key, | ||
const Nullable<std::string>& ssl_cert, | ||
const Nullable<std::string>& ssl_ca, | ||
const Nullable<std::string>& ssl_capath, | ||
const Nullable<std::string>& ssl_cipher, int timeout, | ||
bool reconnect); | ||
void disconnect(); | ||
bool is_valid(); | ||
void check_connection(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the closing paren
);
to the next line?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature will be added to clang-format. Seems now doesn't exists.