retdec
stream.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_FILEFORMAT_TYPES_DOTNET_HEADERS_STREAM_H
8 #define RETDEC_FILEFORMAT_TYPES_DOTNET_HEADERS_STREAM_H
9 
10 #include <cstdint>
11 #include <string>
12 #include <vector>
13 
14 namespace retdec {
15 namespace fileformat {
16 
20 enum class StreamType
21 {
22  Metadata,
23  String,
24  UserString,
25  Blob,
26  Guid
27 };
28 
32 class Stream
33 {
34  private:
36  std::uint64_t offset;
37  std::uint64_t size;
38  std::string name;
39  protected:
40  Stream(StreamType streamType, std::uint64_t streamOffset, std::uint64_t streamSize) : type(streamType), offset(streamOffset), size(streamSize)
41  {
42  switch (type)
43  {
45  name = "#~";
46  break;
47  case StreamType::String:
48  name = "#Strings";
49  break;
51  name = "#US";
52  break;
53  case StreamType::Blob:
54  name = "#Blob";
55  break;
56  case StreamType::Guid:
57  name = "#GUID";
58  break;
59  default:
60  name.clear();
61  break;
62  }
63  }
64  public:
65  virtual ~Stream() = default;
66 
69  StreamType getType() const { return type; }
70  std::uint64_t getOffset() const { return offset; }
71  std::uint64_t getSize() const { return size; }
72  const std::string& getName() const { return name; }
74 };
75 
76 } // namespace fileformat
77 } // namespace retdec
78 
79 #endif
Definition: stream.h:33
StreamType type
Definition: stream.h:35
StreamType getType() const
Definition: stream.h:69
std::uint64_t getSize() const
Definition: stream.h:71
Stream(StreamType streamType, std::uint64_t streamOffset, std::uint64_t streamSize)
Definition: stream.h:40
std::uint64_t size
Definition: stream.h:37
std::uint64_t offset
Definition: stream.h:36
std::uint64_t getOffset() const
Definition: stream.h:70
virtual ~Stream()=default
std::string name
Definition: stream.h:38
const std::string & getName() const
Definition: stream.h:72
StreamType
Definition: stream.h:21
Definition: archive_wrapper.h:19