ComPWA
Common Partial-Wave-Analysis Framework
AsciiHeaderIO.hpp
Go to the documentation of this file.
1 // Copyright (c) 2013 The ComPWA Team.
2 // This file is part of the ComPWA framework, check
3 // https://github.com/ComPWA/ComPWA/license.txt for details.
4 
5 #ifndef COMPWA_DATA_ASCIIHEADER_HPP_
6 #define COMPWA_DATA_ASCIIHEADER_HPP_
7 
8 #include <string>
9 #include <vector>
10 
11 namespace ComPWA {
12 namespace Data {
13 namespace Ascii {
14 
21 class AsciiHeader {
22 public:
23  AsciiHeader(std::vector<int> PIDs = {}, std::string Unit = "GeV",
24  bool EnergyFirst = false)
25  : PIDs(PIDs), Unit(Unit), EnergyFirst(EnergyFirst) {}
26 
29  static std::string extractHeaderContent(std::istream &InputStream);
30 
40  void importYAML(const std::string &HeaderContent);
41  void importYAML(std::istream &InputStream) {
42  importYAML(extractHeaderContent(InputStream));
43  }
44 
48  void dumpToYAML(std::ostream &os) const;
49 
50  const std::vector<int> getFinalStatePIDs() const { return PIDs; }
51  bool isEnergyFirst() const { return EnergyFirst; }
52  const std::string &getUnit() const { return Unit; }
53 
54 private:
55  std::vector<int> PIDs;
56  std::string Unit;
58 };
59 
60 } // namespace Ascii
61 } // namespace Data
62 } // namespace ComPWA
63 
64 #endif
void importYAML(const std::string &HeaderContent)
Set data members by reading a YAML-like string (including newlines).
Representation of data contained in an ASCII header.
void dumpToYAML(std::ostream &os) const
Serialise data members to YAML format, embedded in XML header tags.
const std::string & getUnit() const
void importYAML(std::istream &InputStream)
const std::vector< int > getFinalStatePIDs() const
static std::string extractHeaderContent(std::istream &InputStream)
Extract the part that is between the XML/HTML tags <header>...</header> including newlines...
AsciiHeader(std::vector< int > PIDs={}, std::string Unit="GeV", bool EnergyFirst=false)