Skip to content

Commit

Permalink
Merge branch 'feature/update_clang_format' into 'master'
Browse files Browse the repository at this point in the history
Update clang format

See merge request minknow/pod5-file-format!143
  • Loading branch information
0x55555555 committed Nov 29, 2022
2 parents 9135f00 + 3a39371 commit 62028c7
Show file tree
Hide file tree
Showing 92 changed files with 8,858 additions and 4,023 deletions.
52 changes: 44 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
---
# See https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
# AlignArrayOfStructures can cause crashes, see https://github.com/llvm/llvm-project/issues/55269
#AlignArrayOfStructures: Left
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: All
BreakConstructorInitializers: BeforeColon
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BraceWrapping:
# NB: due to https://github.com/llvm/llvm-project/issues/55582 the Multiline setting will not
# always work (should be fixed in clang-format 15, but that is not available as a python wheel yet
# due to https://github.com/ssciwr/clang-format-wheel/issues/49)
AfterControlStatement: MultiLine # makes sure multiline ifs don't run into their bodies
AfterFunction: true # makes constructors with initialisers much nicer
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 100
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
CompactNamespaces: true
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DerivePointerAlignment: false # force use of the PointerAlignment setting
FixNamespaceComments: true
IncludeBlocks : Regroup
IncludeCategories:
# Aim is:
# 0. the "main" header file (#include "foo.h" in foo.cpp) automatically gets priority 0
# 1. internal headers (#include "util/helpers.h"): quotation marks, with a '/'
# 2. third-party headers (#include <boost/string_view.hpp>): angle brackets, '/' or .h/.hpp/.h++
# file ext
# 3. standard library headers (#include <vector>): angle brackets, no file ext, no '/'
- Regex: '^"'
Priority: 1
- Regex: '^<.*/'
Expand All @@ -22,12 +48,22 @@ IncludeCategories:
- Regex: '\.h\+\+>'
Priority: 2
IncludeIsMainRegex: '(_test|_tests|Tests|Test)?$'
# foo.h will be considered the "main" header (and sorted to the top) for all of the following:
# - foo.cpp
# - foo_test.cpp
# - foo_tests.cpp
# - fooTests.cpp (although this is intended for Foo.h and FooTests.cpp)
# - fooTest.cpp (although this is intended for Foo.h and FooTest.cpp)
IndentCaseLabels: false
IndentWidth: 4
PackConstructorInitializers: CurrentLine
PointerAlignment: Middle
QualifierAlignment: Right # const east
# clang 14 *should* know about QualifierOrder (according to its docs) but claims it doesn't
#QualifierOrder: ['static', 'constexpr', 'inline', 'type', 'const', 'volatile', 'restrict']
ReflowComments: false
SortIncludes: true
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
Standard: Cpp11

...
SpaceAroundPointerQualifiers: Before
Standard: c++20
13 changes: 8 additions & 5 deletions c++/examples/find_all_read_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <fstream>
#include <iostream>

int main(int argc, char** argv) {
int main(int argc, char ** argv)
{
if (argc != 2) {
std::cerr << "Expected one argument - an pod5 file to search\n";
}
Expand All @@ -16,7 +17,7 @@ int main(int argc, char** argv) {
pod5_init();

// Open the file ready for walking:
Pod5FileReader_t* file = pod5_open_file(argv[1]);
Pod5FileReader_t * file = pod5_open_file(argv[1]);
if (!file) {
std::cerr << "Failed to open file " << argv[1] << ": " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -35,7 +36,7 @@ int main(int argc, char** argv) {
std::size_t read_count = 0;

for (std::size_t batch_index = 0; batch_index < batch_count; ++batch_index) {
Pod5ReadRecordBatch_t* batch = nullptr;
Pod5ReadRecordBatch_t * batch = nullptr;
if (pod5_get_read_batch(&batch, file, batch_index) != POD5_OK) {
std::cerr << "Failed to get batch: " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -50,8 +51,10 @@ int main(int argc, char** argv) {
for (std::size_t row = 0; row < batch_row_count; ++row) {
uint16_t read_table_version = 0;
ReadBatchRowInfo_t read_data;
if (pod5_get_read_batch_row_info_data(batch, row, READ_BATCH_ROW_INFO_VERSION,
&read_data, &read_table_version) != POD5_OK) {
if (pod5_get_read_batch_row_info_data(
batch, row, READ_BATCH_ROW_INFO_VERSION, &read_data, &read_table_version)
!= POD5_OK)
{
std::cerr << "Failed to get read " << row << "\n";
return EXIT_FAILURE;
}
Expand Down
27 changes: 18 additions & 9 deletions c++/examples/find_specific_read_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <iostream>
#include <vector>

int main(int argc, char** argv) {
int main(int argc, char ** argv)
{
if (argc != 3) {
std::cerr << "Expected two arguments:\n"
<< " - an pod5 file to search\n"
Expand All @@ -19,7 +20,7 @@ int main(int argc, char** argv) {
pod5_init();

// Open the file ready for walking:
Pod5FileReader_t* file = pod5_open_file(argv[1]);
Pod5FileReader_t * file = pod5_open_file(argv[1]);
if (!file) {
std::cerr << "Failed to open file " << argv[1] << ": " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -41,7 +42,7 @@ int main(int argc, char** argv) {
search_uuids.push_back(boost::lexical_cast<boost::uuids::uuid>(line));
}
std::cout << " Read " << search_uuids.size() << " ids from the text file\n";
} catch (std::exception const& e) {
} catch (std::exception const & e) {
std::cerr << "Failed to parse UUID values from " << input_path << ": " << e.what() << "\n";
}

Expand All @@ -53,9 +54,15 @@ int main(int argc, char** argv) {
std::vector<std::uint32_t> traversal_batch_counts(batch_count);
std::vector<std::uint32_t> traversal_row_indices(search_uuids.size());
std::size_t find_success_count = 0;
if (pod5_plan_traversal(file, (uint8_t*)search_uuids.data(), search_uuids.size(),
traversal_batch_counts.data(), traversal_row_indices.data(),
&find_success_count) != POD5_OK) {
if (pod5_plan_traversal(
file,
(uint8_t *)search_uuids.data(),
search_uuids.size(),
traversal_batch_counts.data(),
traversal_row_indices.data(),
&find_success_count)
!= POD5_OK)
{
std::cerr << "Failed to plan traversal of file: " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
}
Expand All @@ -70,7 +77,7 @@ int main(int argc, char** argv) {
// Walk the suggested traversal route, storing read data.
std::size_t step_index = 0;
for (std::size_t batch_index = 0; batch_index < batch_count; ++batch_index) {
Pod5ReadRecordBatch_t* batch = nullptr;
Pod5ReadRecordBatch_t * batch = nullptr;
if (pod5_get_read_batch(&batch, file, batch_index) != POD5_OK) {
std::cerr << "Failed to get batch: " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -83,8 +90,10 @@ int main(int argc, char** argv) {

uint16_t read_table_version = 0;
ReadBatchRowInfo_t read_data;
if (pod5_get_read_batch_row_info_data(batch, batch_row, READ_BATCH_ROW_INFO_VERSION,
&read_data, &read_table_version) != POD5_OK) {
if (pod5_get_read_batch_row_info_data(
batch, batch_row, READ_BATCH_ROW_INFO_VERSION, &read_data, &read_table_version)
!= POD5_OK)
{
std::cerr << "Failed to get read " << batch_row << "\n";
return EXIT_FAILURE;
}
Expand Down
27 changes: 18 additions & 9 deletions c++/examples/find_specific_read_ids_with_signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include <iostream>
#include <vector>

int main(int argc, char** argv) {
int main(int argc, char ** argv)
{
if (argc != 3) {
std::cerr << "Expected two arguments:\n"
<< " - an pod5 file to search\n"
Expand All @@ -19,7 +20,7 @@ int main(int argc, char** argv) {
pod5_init();

// Open the file ready for walking:
Pod5FileReader_t* file = pod5_open_file(argv[1]);
Pod5FileReader_t * file = pod5_open_file(argv[1]);
if (!file) {
std::cerr << "Failed to open file " << argv[1] << ": " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -41,7 +42,7 @@ int main(int argc, char** argv) {
search_uuids.push_back(boost::lexical_cast<boost::uuids::uuid>(line));
}
std::cout << " Read " << search_uuids.size() << " ids from the text file\n";
} catch (std::exception const& e) {
} catch (std::exception const & e) {
std::cerr << "Failed to parse UUID values from " << input_path << ": " << e.what() << "\n";
}

Expand All @@ -53,9 +54,15 @@ int main(int argc, char** argv) {
std::vector<std::uint32_t> traversal_batch_counts(batch_count);
std::vector<std::uint32_t> traversal_row_indices(search_uuids.size());
std::size_t find_success_count = 0;
if (pod5_plan_traversal(file, (uint8_t*)search_uuids.data(), search_uuids.size(),
traversal_batch_counts.data(), traversal_row_indices.data(),
&find_success_count) != POD5_OK) {
if (pod5_plan_traversal(
file,
(uint8_t *)search_uuids.data(),
search_uuids.size(),
traversal_batch_counts.data(),
traversal_row_indices.data(),
&find_success_count)
!= POD5_OK)
{
std::cerr << "Failed to plan traversal of file: " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
}
Expand All @@ -72,7 +79,7 @@ int main(int argc, char** argv) {
// Walk the suggested traversal route, storing read data.
std::size_t step_index = 0;
for (std::size_t batch_index = 0; batch_index < batch_count; ++batch_index) {
Pod5ReadRecordBatch_t* batch = nullptr;
Pod5ReadRecordBatch_t * batch = nullptr;
if (pod5_get_read_batch(&batch, file, batch_index) != POD5_OK) {
std::cerr << "Failed to get batch: " << pod5_get_error_string() << "\n";
return EXIT_FAILURE;
Expand All @@ -85,8 +92,10 @@ int main(int argc, char** argv) {

uint16_t read_table_version = 0;
ReadBatchRowInfo_t read_data;
if (pod5_get_read_batch_row_info_data(batch, batch_row, READ_BATCH_ROW_INFO_VERSION,
&read_data, &read_table_version) != POD5_OK) {
if (pod5_get_read_batch_row_info_data(
batch, batch_row, READ_BATCH_ROW_INFO_VERSION, &read_data, &read_table_version)
!= POD5_OK)
{
std::cerr << "Failed to get read " << batch_row << "\n";
return EXIT_FAILURE;
}
Expand Down
Loading

0 comments on commit 62028c7

Please sign in to comment.