IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 165721c9 authored by Ralf M Ulrich's avatar Ralf M Ulrich
Browse files

clang format

parent 34a4a830
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment