QualityControl  1.5.1
O2 Data Quality Control Framework
stringUtils.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef QC_STRING_UTILS_H
17 #define QC_STRING_UTILS_H
18 
19 #include <string>
20 #include <sstream>
21 #include <vector>
22 #include <iomanip>
23 #include <bitset>
24 
26 {
27 
28 std::vector<std::string> getBinRepresentation(unsigned char* data, size_t size)
29 {
30  std::stringstream ss;
31  std::vector<std::string> result;
32  result.reserve(size);
33 
34  for (size_t i = 0; i < size; i++) {
35  std::bitset<16> x(data[i]);
36  ss << x << " ";
37  result.push_back(ss.str());
38  ss.str(std::string());
39  }
40  return result;
41 }
42 
43 std::vector<std::string> getHexRepresentation(unsigned char* data, size_t size)
44 {
45  std::stringstream ss;
46  std::vector<std::string> result;
47  result.reserve(size);
48  ss << std::hex << std::setfill('0');
49 
50  for (size_t i = 0; i < size; i++) {
51  ss << std::setw(2) << static_cast<unsigned>(data[i]) << " ";
52  result.push_back(ss.str());
53  ss.str(std::string());
54  }
55  return result;
56 }
57 } // namespace o2::quality_control::core
58 
59 #endif // QC_STRING_UTILS_H
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19