From 5485bab02ce31131a69bf22bb2f06bd2142ed802 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Thu, 3 Aug 2023 10:28:23 +0200 Subject: [PATCH] Add and use ``. The header `` is the top-level header for everything HighFive. It's recommended to use it instead of the other headers, unless compilation time is a concern. However, currently `` includes almost all of HighFive. Hence, the savings are likely very modest, if any. --- README.md | 2 +- doc/installation.md | 2 +- doc/poster/example3.cpp | 2 +- doc/poster/example6.cpp | 4 +--- doc/poster/example_boost.cpp | 4 +--- doc/poster/example_boost_ublas.cpp | 2 +- doc/poster/example_easy_highfive.cpp | 1 + doc/poster/example_props.cpp | 2 +- include/highfive/highfive.hpp | 14 ++++++++++++++ src/benchmarks/highfive_bench.cpp | 2 +- src/examples/boost_multi_array_2D.cpp | 2 +- src/examples/boost_multiarray_complex.cpp | 5 ++--- src/examples/boost_ublas_double.cpp | 3 ++- src/examples/compound_types.cpp | 2 +- src/examples/create_attribute_string_integer.cpp | 5 +---- src/examples/create_dataset_double.cpp | 4 +--- src/examples/create_dataset_half_float.cpp | 4 +--- src/examples/create_datatype.cpp | 3 +-- src/examples/create_extensible_dataset.cpp | 4 +--- src/examples/create_large_attribute.cpp | 5 ++--- src/examples/create_page_allocated_files.cpp | 2 +- src/examples/hl_hdf5_inmemory_files.cpp | 2 +- src/examples/parallel_hdf5_collective_io.cpp | 5 +---- src/examples/parallel_hdf5_independent_io.cpp | 5 +---- src/examples/read_write_dataset_string.cpp | 4 +--- src/examples/read_write_fixedlen_string.cpp | 4 +--- src/examples/read_write_raw_ptr.cpp | 4 +--- src/examples/read_write_single_scalar.cpp | 4 +--- src/examples/read_write_vector_dataset.cpp | 4 +--- .../read_write_vector_dataset_references.cpp | 5 +---- src/examples/readme_snippet.cpp | 2 +- src/examples/renaming_objects.cpp | 6 +----- src/examples/select_by_id_dataset_cpp11.cpp | 4 +--- src/examples/select_partial_dataset_cpp11.cpp | 4 +--- .../test_dependent_library/include/simpleton.hpp | 16 +--------------- tests/unit/test_all_types.cpp | 8 +------- tests/unit/tests_high_five_base.cpp | 9 +-------- tests/unit/tests_high_five_multi_dims.cpp | 3 +-- tests/unit/tests_high_five_parallel.cpp | 6 +----- 39 files changed, 55 insertions(+), 114 deletions(-) create mode 100644 include/highfive/highfive.hpp diff --git a/README.md b/README.md index 2ef1de8d5..3ea068015 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ It integrates nicely with other CMake projects by defining (and exporting) a Hig #### Write a std::vector to 1D HDF5 dataset and read it back ```c++ -#include +#include using namespace HighFive; diff --git a/doc/installation.md b/doc/installation.md index 36676c2c7..808e34532 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -218,7 +218,7 @@ Okay, on to configure, compile and install. The CMake commands are ### Confirming It Works We again need a dummy file called `dummy.cpp` with the following contents - #include + #include int main() { auto file = HighFive::File("foo.h5", HighFive::File::Create); diff --git a/doc/poster/example3.cpp b/doc/poster/example3.cpp index 64f2ed6be..e18fbbf83 100644 --- a/doc/poster/example3.cpp +++ b/doc/poster/example3.cpp @@ -1,4 +1,4 @@ -#include +#include typedef struct { diff --git a/doc/poster/example6.cpp b/doc/poster/example6.cpp index 8f7419f23..41a050570 100644 --- a/doc/poster/example6.cpp +++ b/doc/poster/example6.cpp @@ -2,9 +2,7 @@ #include -#include -#include -#include +#include int main(int argc, char** argv) { diff --git a/doc/poster/example_boost.cpp b/doc/poster/example_boost.cpp index aceaa2068..56b78d074 100644 --- a/doc/poster/example_boost.cpp +++ b/doc/poster/example_boost.cpp @@ -1,11 +1,9 @@ #include #define H5_USE_BOOST 1 +#include #include -#include -#include -#include using complex_t = std::complex; diff --git a/doc/poster/example_boost_ublas.cpp b/doc/poster/example_boost_ublas.cpp index 3a2b4c73a..986a671de 100644 --- a/doc/poster/example_boost_ublas.cpp +++ b/doc/poster/example_boost_ublas.cpp @@ -1,6 +1,7 @@ #include #define H5_USE_BOOST 1 +#include // In some versions of Boost (starting with 1.64), you have to // include the serialization header before ublas @@ -8,7 +9,6 @@ #include #include -#include using namespace HighFive; diff --git a/doc/poster/example_easy_highfive.cpp b/doc/poster/example_easy_highfive.cpp index 07d37a22c..700056cae 100644 --- a/doc/poster/example_easy_highfive.cpp +++ b/doc/poster/example_easy_highfive.cpp @@ -1,4 +1,5 @@ #include + #include int main() { diff --git a/doc/poster/example_props.cpp b/doc/poster/example_props.cpp index e46fe119c..0e5b14bde 100644 --- a/doc/poster/example_props.cpp +++ b/doc/poster/example_props.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace HighFive; diff --git a/include/highfive/highfive.hpp b/include/highfive/highfive.hpp new file mode 100644 index 000000000..f5e20cae9 --- /dev/null +++ b/include/highfive/highfive.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/benchmarks/highfive_bench.cpp b/src/benchmarks/highfive_bench.cpp index e4e04dee8..bcc7be93c 100644 --- a/src/benchmarks/highfive_bench.cpp +++ b/src/benchmarks/highfive_bench.cpp @@ -1,4 +1,4 @@ -#include +#include #include const std::vector> data(1000000, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); diff --git a/src/examples/boost_multi_array_2D.cpp b/src/examples/boost_multi_array_2D.cpp index 582049efd..4bec1ec12 100644 --- a/src/examples/boost_multi_array_2D.cpp +++ b/src/examples/boost_multi_array_2D.cpp @@ -12,7 +12,7 @@ #define H5_USE_BOOST #include -#include +#include using namespace HighFive; diff --git a/src/examples/boost_multiarray_complex.cpp b/src/examples/boost_multiarray_complex.cpp index 1b66b3ddf..37481db62 100644 --- a/src/examples/boost_multiarray_complex.cpp +++ b/src/examples/boost_multiarray_complex.cpp @@ -12,10 +12,9 @@ #undef H5_USE_BOOST #define H5_USE_BOOST +#include + #include -#include -#include -#include typedef std::complex complex_t; diff --git a/src/examples/boost_ublas_double.cpp b/src/examples/boost_ublas_double.cpp index ca3307ecf..b025475b9 100644 --- a/src/examples/boost_ublas_double.cpp +++ b/src/examples/boost_ublas_double.cpp @@ -11,13 +11,14 @@ #undef H5_USE_BOOST #define H5_USE_BOOST +#include + // In some versions of Boost (starting with 1.64), you have to include the serialization header // before ublas #include #include #include -#include using namespace HighFive; diff --git a/src/examples/compound_types.cpp b/src/examples/compound_types.cpp index d456859a4..158bc6dc6 100644 --- a/src/examples/compound_types.cpp +++ b/src/examples/compound_types.cpp @@ -10,7 +10,7 @@ // Compound datatype test :: May 2021 // ////////////////////////////////// -#include +#include typedef struct { diff --git a/src/examples/create_attribute_string_integer.cpp b/src/examples/create_attribute_string_integer.cpp index a716c827a..f658457ad 100644 --- a/src/examples/create_attribute_string_integer.cpp +++ b/src/examples/create_attribute_string_integer.cpp @@ -10,10 +10,7 @@ #include #include -#include -#include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/create_dataset_double.cpp b/src/examples/create_dataset_double.cpp index e5b96fcf6..d15fbdc54 100644 --- a/src/examples/create_dataset_double.cpp +++ b/src/examples/create_dataset_double.cpp @@ -10,9 +10,7 @@ #include #include -#include -#include -#include +#include // Create a dataset name "dset" of double 4x6 int main(void) { diff --git a/src/examples/create_dataset_half_float.cpp b/src/examples/create_dataset_half_float.cpp index 204e45374..2b720cd18 100644 --- a/src/examples/create_dataset_half_float.cpp +++ b/src/examples/create_dataset_half_float.cpp @@ -13,9 +13,7 @@ #include #include -#include -#include -#include +#include const std::string FILE_NAME("create_dataset_half_float_example.h5"); const std::string DATASET_NAME("dset"); diff --git a/src/examples/create_datatype.cpp b/src/examples/create_datatype.cpp index d1e342bb4..0b1a0fb52 100644 --- a/src/examples/create_datatype.cpp +++ b/src/examples/create_datatype.cpp @@ -1,7 +1,6 @@ #include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/create_extensible_dataset.cpp b/src/examples/create_extensible_dataset.cpp index 53a6b2b43..17153cd57 100644 --- a/src/examples/create_extensible_dataset.cpp +++ b/src/examples/create_extensible_dataset.cpp @@ -10,9 +10,7 @@ #include #include -#include -#include -#include +#include const std::string FILE_NAME("create_extensible_dataset_example.h5"); const std::string DATASET_NAME("dset"); diff --git a/src/examples/create_large_attribute.cpp b/src/examples/create_large_attribute.cpp index 004386e6e..022d11d87 100644 --- a/src/examples/create_large_attribute.cpp +++ b/src/examples/create_large_attribute.cpp @@ -1,9 +1,8 @@ -#include -#include -#include #include #include +#include + int main() { std::vector large_attr(16000, 0.0); diff --git a/src/examples/create_page_allocated_files.cpp b/src/examples/create_page_allocated_files.cpp index 73f15c5fb..0b4d29dff 100644 --- a/src/examples/create_page_allocated_files.cpp +++ b/src/examples/create_page_allocated_files.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include // This example requires HDF5 version 1.10.1 or newer. #if H5_VERSION_GE(1, 10, 1) diff --git a/src/examples/hl_hdf5_inmemory_files.cpp b/src/examples/hl_hdf5_inmemory_files.cpp index 58bdbbec1..088fd71cc 100644 --- a/src/examples/hl_hdf5_inmemory_files.cpp +++ b/src/examples/hl_hdf5_inmemory_files.cpp @@ -9,8 +9,8 @@ #include #include +#include -#include #include using namespace HighFive; diff --git a/src/examples/parallel_hdf5_collective_io.cpp b/src/examples/parallel_hdf5_collective_io.cpp index c7d7f9920..7261b7cf1 100644 --- a/src/examples/parallel_hdf5_collective_io.cpp +++ b/src/examples/parallel_hdf5_collective_io.cpp @@ -13,10 +13,7 @@ #include -#include -#include -#include -#include +#include const std::string file_name("parallel_collective_example.h5"); const std::string dataset_name("dset"); diff --git a/src/examples/parallel_hdf5_independent_io.cpp b/src/examples/parallel_hdf5_independent_io.cpp index f56d87f05..b43012890 100644 --- a/src/examples/parallel_hdf5_independent_io.cpp +++ b/src/examples/parallel_hdf5_independent_io.cpp @@ -13,10 +13,7 @@ #include -#include -#include -#include -#include +#include const std::string file_name("parallel_independent_example.h5"); diff --git a/src/examples/read_write_dataset_string.cpp b/src/examples/read_write_dataset_string.cpp index c5cf658a2..2a4c3c491 100644 --- a/src/examples/read_write_dataset_string.cpp +++ b/src/examples/read_write_dataset_string.cpp @@ -10,9 +10,7 @@ #include #include -#include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/read_write_fixedlen_string.cpp b/src/examples/read_write_fixedlen_string.cpp index 123e9443f..60589637e 100644 --- a/src/examples/read_write_fixedlen_string.cpp +++ b/src/examples/read_write_fixedlen_string.cpp @@ -9,9 +9,7 @@ #include #include -#include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/read_write_raw_ptr.cpp b/src/examples/read_write_raw_ptr.cpp index 5a95b03f5..b6cd9eda5 100644 --- a/src/examples/read_write_raw_ptr.cpp +++ b/src/examples/read_write_raw_ptr.cpp @@ -11,9 +11,7 @@ #include #include -#include -#include -#include +#include const std::string file_name("read_write_raw_ptr.h5"); const std::string dataset_name("array"); diff --git a/src/examples/read_write_single_scalar.cpp b/src/examples/read_write_single_scalar.cpp index b32d9b3b5..4b4c6887c 100644 --- a/src/examples/read_write_single_scalar.cpp +++ b/src/examples/read_write_single_scalar.cpp @@ -10,9 +10,7 @@ #include #include -#include -#include -#include +#include const std::string file_name("read_write_scalar.h5"); const std::string dataset_name("single_scalar"); diff --git a/src/examples/read_write_vector_dataset.cpp b/src/examples/read_write_vector_dataset.cpp index 605a231a5..9718c1c2b 100644 --- a/src/examples/read_write_vector_dataset.cpp +++ b/src/examples/read_write_vector_dataset.cpp @@ -10,9 +10,7 @@ #include #include -#include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/read_write_vector_dataset_references.cpp b/src/examples/read_write_vector_dataset_references.cpp index 2d9a8ac89..ca0846768 100644 --- a/src/examples/read_write_vector_dataset_references.cpp +++ b/src/examples/read_write_vector_dataset_references.cpp @@ -10,10 +10,7 @@ #include #include -#include -#include -#include -#include +#include // create a dataset 1D from a vector of int void write_dataset() { diff --git a/src/examples/readme_snippet.cpp b/src/examples/readme_snippet.cpp index 5ba18243a..160dabce5 100644 --- a/src/examples/readme_snippet.cpp +++ b/src/examples/readme_snippet.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace HighFive; diff --git a/src/examples/renaming_objects.cpp b/src/examples/renaming_objects.cpp index 0f2a93ac7..f0759e52a 100644 --- a/src/examples/renaming_objects.cpp +++ b/src/examples/renaming_objects.cpp @@ -1,8 +1,4 @@ -#include -#include -#include -#include -#include +#include using namespace HighFive; diff --git a/src/examples/select_by_id_dataset_cpp11.cpp b/src/examples/select_by_id_dataset_cpp11.cpp index 2e0b6f149..973c57435 100644 --- a/src/examples/select_by_id_dataset_cpp11.cpp +++ b/src/examples/select_by_id_dataset_cpp11.cpp @@ -11,9 +11,7 @@ #include #include -#include -#include -#include +#include const std::string file_name("select_partial_string.h5"); const std::string dataset_name("message"); diff --git a/src/examples/select_partial_dataset_cpp11.cpp b/src/examples/select_partial_dataset_cpp11.cpp index a21f67ed1..1e480c160 100644 --- a/src/examples/select_partial_dataset_cpp11.cpp +++ b/src/examples/select_partial_dataset_cpp11.cpp @@ -11,9 +11,7 @@ #include #include -#include -#include -#include +#include const std::string file_name("select_partial_example.h5"); const std::string dataset_name("dset"); diff --git a/tests/test_dependent_library/include/simpleton.hpp b/tests/test_dependent_library/include/simpleton.hpp index 279187a71..b98a09fda 100644 --- a/tests/test_dependent_library/include/simpleton.hpp +++ b/tests/test_dependent_library/include/simpleton.hpp @@ -3,21 +3,7 @@ // Include all headers here to catch any missing `inline` statements, since // they will be included by two different compilation units. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // Boost should always be found in this setup #include diff --git a/tests/unit/test_all_types.cpp b/tests/unit/test_all_types.cpp index 1f3aef224..d74579af6 100644 --- a/tests/unit/test_all_types.cpp +++ b/tests/unit/test_all_types.cpp @@ -8,15 +8,9 @@ */ #include -#include -#include -#include -#include -#include -#include - #include +#include #include "tests_high_five.hpp" using namespace HighFive; diff --git a/tests/unit/tests_high_five_base.cpp b/tests/unit/tests_high_five_base.cpp index b0124460f..899170d93 100644 --- a/tests/unit/tests_high_five_base.cpp +++ b/tests/unit/tests_high_five_base.cpp @@ -18,18 +18,11 @@ #include #include -#include -#include -#include -#include -#include -#include -#include - #include #include #include +#include #include "tests_high_five.hpp" using namespace HighFive; diff --git a/tests/unit/tests_high_five_multi_dims.cpp b/tests/unit/tests_high_five_multi_dims.cpp index 4a4b8231c..442f1c9cc 100644 --- a/tests/unit/tests_high_five_multi_dims.cpp +++ b/tests/unit/tests_high_five_multi_dims.cpp @@ -10,8 +10,7 @@ #include #include -#include -#include +#include #ifdef H5_USE_BOOST diff --git a/tests/unit/tests_high_five_parallel.cpp b/tests/unit/tests_high_five_parallel.cpp index b5518f48c..8b096205e 100644 --- a/tests/unit/tests_high_five_parallel.cpp +++ b/tests/unit/tests_high_five_parallel.cpp @@ -13,15 +13,11 @@ #include #include -#include -#include -#include -#include - #include #include #include +#include #include "tests_high_five.hpp" using namespace HighFive;