forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContent.cpp
More file actions
91 lines (72 loc) · 2.43 KB
/
Copy pathContent.cpp
File metadata and controls
91 lines (72 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "Content.h"
#include "details/ErrorHandling.h"
using namespace SFS;
Result Content::Make(std::string contentNameSpace,
std::string contentName,
std::string contentVersion,
const std::vector<File>& files,
std::unique_ptr<Content>& out) noexcept
try
{
out.reset();
std::unique_ptr<Content> tmp(new Content());
RETURN_IF_FAILED(ContentId::Make(std::move(contentNameSpace),
std::move(contentName),
std::move(contentVersion),
tmp->m_contentId));
for (const auto& file : files)
{
std::unique_ptr<File> clone;
RETURN_IF_FAILED(file.Clone(clone));
tmp->m_files.push_back(std::move(*clone));
}
out = std::move(tmp);
return Result::Success;
}
SFS_CATCH_RETURN()
Result Content::Make(std::string contentNameSpace,
std::string contentName,
std::string contentVersion,
std::vector<File>&& files,
std::unique_ptr<Content>& out) noexcept
try
{
out.reset();
std::unique_ptr<Content> tmp(new Content());
RETURN_IF_FAILED(ContentId::Make(std::move(contentNameSpace),
std::move(contentName),
std::move(contentVersion),
tmp->m_contentId));
tmp->m_files = std::move(files);
out = std::move(tmp);
return Result::Success;
}
SFS_CATCH_RETURN()
Result Content::Make(std::unique_ptr<ContentId>&& contentId,
std::vector<File>&& files,
std::unique_ptr<Content>& out) noexcept
try
{
out.reset();
std::unique_ptr<Content> tmp(new Content());
tmp->m_contentId = std::move(contentId);
tmp->m_files = std::move(files);
out = std::move(tmp);
return Result::Success;
}
SFS_CATCH_RETURN()
Content::Content(Content&& other) noexcept
{
m_contentId = std::move(other.m_contentId);
m_files = std::move(other.m_files);
}
const ContentId& Content::GetContentId() const noexcept
{
return *m_contentId;
}
const std::vector<File>& Content::GetFiles() const noexcept
{
return m_files;
}