mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-22 11:37:59 +02:00
write rawfiles (single file) and read rawfiles in order (#66)
* read subfiles with unordered and missing frames * save work debugging * Revert "save work debugging" This reverts commite791992a05
. * Revert "read subfiles with unordered and missing frames" This reverts commit1177fd129d
. * throw when two frames have different frame numbers * write single part RawFile (working beta) * correct total number of frames in master file * add new mythen file with syncd frames * read frames with same frame number * clang-tidy fixes, formatting, add tests * improve readability in loop * fix failing tests --------- Co-authored-by: Bechir <bechir.brahem420@gmail.com>
This commit is contained in:
@ -1,66 +1,9 @@
|
||||
|
||||
#include "aare/network_io/ZmqHeader.hpp"
|
||||
#include "aare/utils/json.hpp"
|
||||
|
||||
#include "simdjson.h"
|
||||
|
||||
// helper functions to write json
|
||||
// append to string for better performance (not tested)
|
||||
|
||||
/**
|
||||
* @brief write a digit to a string
|
||||
* takes key and value and outputs->"key": value,
|
||||
* @tparam T type of value (int, uint32_t, ...)
|
||||
* @param s string to append to
|
||||
* @param key key to write
|
||||
* @param value value to write
|
||||
* @return void
|
||||
* @note
|
||||
* - can't use concepts here because we are using c++17
|
||||
*/
|
||||
template <typename T> void write_digit(std::string &s, const std::string &key, const T &value) {
|
||||
s += "\"";
|
||||
s += key;
|
||||
s += "\": ";
|
||||
s += std::to_string(value);
|
||||
s += ", ";
|
||||
}
|
||||
void write_str(std::string &s, const std::string &key, const std::string &value) {
|
||||
s += "\"";
|
||||
s += key;
|
||||
s += "\": \"";
|
||||
s += value;
|
||||
s += "\", ";
|
||||
}
|
||||
void write_map(std::string &s, const std::string &key, const std::map<std::string, std::string> &value) {
|
||||
s += "\"";
|
||||
s += key;
|
||||
s += "\": {";
|
||||
for (const auto &kv : value) {
|
||||
write_str(s, kv.first, kv.second);
|
||||
}
|
||||
// remove last comma or trailing spaces
|
||||
for (size_t i = s.size() - 1; i > 0; i--) {
|
||||
if (s[i] == ',' or s[i] == ' ') {
|
||||
s.pop_back();
|
||||
} else
|
||||
break;
|
||||
}
|
||||
s += "}, ";
|
||||
}
|
||||
void write_array(std::string &s, const std::string &key, const std::array<int, 4> &value) {
|
||||
s += "\"";
|
||||
s += key;
|
||||
s += "\": [";
|
||||
s += std::to_string(value[0]);
|
||||
s += ", ";
|
||||
s += std::to_string(value[1]);
|
||||
s += ", ";
|
||||
s += std::to_string(value[2]);
|
||||
s += ", ";
|
||||
s += std::to_string(value[3]);
|
||||
s += "], ";
|
||||
}
|
||||
|
||||
namespace aare {
|
||||
|
||||
std::string ZmqHeader::to_string() const {
|
||||
|
Reference in New Issue
Block a user