GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
GpgData.h
1 
29 #pragma once
30 
31 #include "core/GpgFrontendCoreExport.h"
32 #include "core/model/GFBuffer.h"
33 #include "core/typedef/CoreTypedef.h"
34 
35 namespace GpgFrontend {
36 
37 class GFDataExchanger;
38 
43 class GPGFRONTEND_CORE_EXPORT GpgData {
44  public:
49  GpgData();
50 
58  GpgData(const void* buffer, size_t size, bool copy = true);
59 
65  explicit GpgData(int fd);
66 
72  explicit GpgData(std::shared_ptr<GFDataExchanger>);
73 
79  explicit GpgData(const QString& path, bool read);
80 
85  explicit GpgData(GFBuffer);
86 
91  ~GpgData();
92 
98  operator gpgme_data_t();
99 
105  auto Read2GFBuffer() -> GFBuffer;
106 
107  private:
112  struct DataRefDeleter {
113  void operator()(gpgme_data_t _data) {
114  if (_data != nullptr) gpgme_data_release(_data);
115  }
116  };
117 
118  GFBuffer cached_buffer_;
119 
120  std::unique_ptr<struct gpgme_data, DataRefDeleter> data_ref_ = nullptr;
121  FILE* fp_ = nullptr;
122  int fd_ = -1;
123 
124  struct gpgme_data_cbs data_cbs_;
125  std::shared_ptr<GFDataExchanger> data_ex_;
126 };
127 
128 } // namespace GpgFrontend
Definition: GFBuffer.h:36
Definition: GpgData.h:43
Definition: app.cpp:39
Definition: GpgData.h:112