Audacity 3.2.0
MultipartData.h
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file MultipartData.h
6
7 Dmitry Vedenko
8 **********************************************************************/
9
10#pragma once
11
12#include <vector>
13#include <memory>
14#include <cstddef>
15#include <string_view>
16#include <string>
17
18#include <wx/filename.h>
19
20#include "HeadersList.h"
21
22namespace audacity
23{
24namespace network_manager
25{
27{
28public:
29 MultipartData() = default;
30 MultipartData(const MultipartData&) = delete;
31 MultipartData& operator =(const MultipartData&) = delete;
32
34 {
35 public:
36 virtual ~Part() = default;
37 void SetHeader(const std::string& headerName, const std::string& headerValue);
38
39 void SetContentType(const std::string& mimeType);
40 void SetContentDisposition(const std::string& disposition);
41
42 virtual int64_t GetSize() const = 0;
43 virtual size_t GetOffset() const = 0;
44
45 virtual size_t Read(void* buffer, size_t maxBytes) = 0;
46 virtual bool Seek(int64_t offset, int origin = SEEK_SET) = 0;
47
48 const HeadersList& GetHeaders() const;
49 private:
51 };
52
53 void Add(std::string_view name, std::string_view value);
54 void Add(
55 std::string_view name, std::string_view contentType, const void* value,
56 size_t size);
57
58 void AddFile(std::string_view name, std::string_view contentType, const wxFileName& fileName);
59
60 size_t GetPartsCount() const;
61
62 Part* GetPart(size_t idx);
63 const Part* GetPart(size_t idx) const;
64
65 bool IsEmpty() const;
66
67private:
68 std::vector<std::unique_ptr<Part>> mParts;
69};
70}
71}
Declare HTTP headers list class.
#define NETWORK_MANAGER_API
wxString name
Definition: TagsEditor.cpp:166
virtual bool Seek(int64_t offset, int origin=SEEK_SET)=0
virtual size_t Read(void *buffer, size_t maxBytes)=0
std::vector< std::unique_ptr< Part > > mParts
Definition: MultipartData.h:68
MultipartData(const MultipartData &)=delete
PROJECT_FILE_IO_API void Add(const FilePath &path)