From 165721c9bcf9268da0b054c574cbc11b8ce068ef Mon Sep 17 00:00:00 2001 From: rulrich <ralf.m.ulrich@kit.edu> Date: Sat, 11 Jul 2020 23:02:48 +0200 Subject: [PATCH] clang format --- readLib/corsika_data/Interface.h | 23 ++++++------ readLib/source/Interface.boost.cc | 60 ++++++++++++++----------------- readLib/source/Interface.dummy.cc | 45 +++++++++++++++-------- 3 files changed, 69 insertions(+), 59 deletions(-) diff --git a/readLib/corsika_data/Interface.h b/readLib/corsika_data/Interface.h index 8f7c50a..71083c4 100644 --- a/readLib/corsika_data/Interface.h +++ b/readLib/corsika_data/Interface.h @@ -16,23 +16,22 @@ namespace corsika_data { // the c++ interface functions - void CorDataOpenFile(char* name); - void CorDataFillArray(double* data, const int& length); - void CorDataCloseFile(); - double CorDataNextNumber(); + void CorDataOpenFile(char* name); + void CorDataFillArray(double* data, const int& length); + void CorDataCloseFile(); + double CorDataNextNumber(); int CorDataNextText(std::string& data); bool CorDataCanDeCompress(); // the fortran interface functions extern "C" { - void cordataopenfile_(char* name); - void cordatafillarray_(double* data, const int& length); - void cordataclosefile_(); - double cordatanextnumber_(); - int cordatanexttext_(char* data, int length); - int cordatacandecompress(); + void cordataopenfile_(char* name); + void cordatafillarray_(double* data, const int& length); + void cordataclosefile_(); + double cordatanextnumber_(); + int cordatanexttext_(char* data, int length); + int cordatacandecompress(); } -} - +} // namespace corsika_data #endif diff --git a/readLib/source/Interface.boost.cc b/readLib/source/Interface.boost.cc index 5d8dd28..fbac967 100644 --- a/readLib/source/Interface.boost.cc +++ b/readLib/source/Interface.boost.cc @@ -10,11 +10,11 @@ #include <corsika_data/Interface.h> -#include <string> +#include <boost/iostreams/filter/bzip2.hpp> +#include <boost/iostreams/filtering_stream.hpp> #include <fstream> #include <iostream> -#include <boost/iostreams/filtering_stream.hpp> -#include <boost/iostreams/filter/bzip2.hpp> +#include <string> #include <iostream> using namespace std; @@ -26,15 +26,15 @@ namespace corsika_data { boost::iostreams::filtering_istream in_; DataFile() {} ~DataFile() {} - void Open(const char *name) { + void Open(const char* name) { if (file_in_.is_open()) { - std::cout << "DataFile is still open! Close it" << std::endl; - file_in_.close(); + std::cout << "DataFile is still open! Close it" << std::endl; + file_in_.close(); } std::string s(name); auto i1 = s.find_first_not_of(" \t\r\n"); auto i2 = s.find_first_of(" \t\r\n", i1); - std::string trimmed(s.substr(i1, i2-i1)); + std::string trimmed(s.substr(i1, i2 - i1)); file_in_.open(trimmed, ios_base::in | ios_base::binary); in_.reset(); in_.push(boost::iostreams::bzip2_decompressor()); @@ -42,8 +42,7 @@ namespace corsika_data { } void Close() { file_in_.close(); } void FillArray(double* data, const int& length) { - for(int i=0; i<length; i++) - in_ >> data[i]; + for (int i = 0; i < length; i++) in_ >> data[i]; } double ReadNextNumber() { double data; @@ -55,38 +54,33 @@ namespace corsika_data { return 0; } }; - + DataFile global_DataFile; - + void CorDataOpenFile(char* name) { global_DataFile.Open(name); } - void CorDataFillArray(double* data, const int& length) { global_DataFile.FillArray(data, length); } + void CorDataFillArray(double* data, const int& length) { + global_DataFile.FillArray(data, length); + } void CorDataCloseFile() { global_DataFile.Close(); } double CorDataNextNumber() { return global_DataFile.ReadNextNumber(); } int CorDataNextText(char* data, const int length) { - std::string STR; + std::string STR; global_DataFile.ReadNextText(STR); - for (int i=0; i<length && i<(int)STR.size(); ++i) - data[i] = STR[i]; + for (int i = 0; i < length && i < (int)STR.size(); ++i) data[i] = STR[i]; return 0; } bool CorDataCanDeCompress() { return true; } - - - extern "C" { - void cordataopenfile_(char* name) { - CorDataOpenFile(name); - } - void cordatafillarray_(double* data, const int& length) { - global_DataFile.FillArray(data, length); - } - double cordatanextnumber_() { - return global_DataFile.ReadNextNumber(); - } - int cordatanexttext_(char* data, const int length) { return CorDataNextText(data, length); } - void cordataclosefile_() { - global_DataFile.Close(); - } - int cordatacandecompress() { return 1; } + extern "C" { + void cordataopenfile_(char* name) { CorDataOpenFile(name); } + void cordatafillarray_(double* data, const int& length) { + global_DataFile.FillArray(data, length); + } + double cordatanextnumber_() { return global_DataFile.ReadNextNumber(); } + int cordatanexttext_(char* data, const int length) { + return CorDataNextText(data, length); + } + void cordataclosefile_() { global_DataFile.Close(); } + int cordatacandecompress() { return 1; } } -} +} // namespace corsika_data diff --git a/readLib/source/Interface.dummy.cc b/readLib/source/Interface.dummy.cc index f6ae6f1..9045399 100644 --- a/readLib/source/Interface.dummy.cc +++ b/readLib/source/Interface.dummy.cc @@ -8,26 +8,43 @@ * the license. */ -#include <string> #include <stdexcept> +#include <string> namespace corsika_data { // the c++ interface functions - void CorDataOpenFile(char*) { std::runtime_error("Cannot read compressed data files with dummy library."); } - void CorDataFillArray(double*, const int&) { std::runtime_error("Cannot read compressed data files with dummy library."); } - void CorDataCloseFile() { std::runtime_error("Cannot read compressed data files with dummy library."); } - double CorDataNextNumber() { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } - int CorDataNextText(std::string&) { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } + void CorDataOpenFile(char*) { + std::runtime_error("Cannot read compressed data files with dummy library."); + } + void CorDataFillArray(double*, const int&) { + std::runtime_error("Cannot read compressed data files with dummy library."); + } + void CorDataCloseFile() { + std::runtime_error("Cannot read compressed data files with dummy library."); + } + double CorDataNextNumber() { + std::runtime_error("Cannot read compressed data files with dummy library."); + return 0; + } + int CorDataNextText(std::string&) { + std::runtime_error("Cannot read compressed data files with dummy library."); + return 0; + } bool CorDataCanDeCompress() { return false; } // the fortran interface functions extern "C" { - void cordataopenfile_(char* name) { CorDataOpenFile(name); } - void cordatafillarray_(double* data, const int& length) { CorDataFillArray(data,length); } - void cordataclosefile_() { CorDataCloseFile(); } - double cordatanextnumber_() { return CorDataNextNumber(); } - int cordatanexttext_(char* data) { std::runtime_error("Cannot read compressed data files with dummy library."); return 0; } - int cordatacandecompress() { return 0; } - } -} + void cordataopenfile_(char* name) { CorDataOpenFile(name); } + void cordatafillarray_(double* data, const int& length) { + CorDataFillArray(data, length); + } + void cordataclosefile_() { CorDataCloseFile(); } + double cordatanextnumber_() { return CorDataNextNumber(); } + int cordatanexttext_(char* data) { + std::runtime_error("Cannot read compressed data files with dummy library."); + return 0; + } + int cordatacandecompress() { return 0; } + } +} // namespace corsika_data -- GitLab