diff options
author | MÃ¥rten Kongstad <marten.kongstad@sony.com> | 2019-03-01 08:35:37 +0100 |
---|---|---|
committer | Todd Kennedy <toddke@google.com> | 2019-03-20 13:45:14 -0700 |
commit | ce42490bb5b499acbf0cc6738e4481e077a6d31a (patch) | |
tree | 60e54956ac4257ee03b5b4176e54346fe6a6b140 /tools/aapt2/java/JavaClassGenerator_test.cpp | |
parent | 3be2db9bbf33f56efb92c97c0a91ad8ab670f0e0 (diff) |
idmap2: move Idmap.h to Result
Change the signatures of Idmap::FromApkAssets and
Idmap::FromBinaryStream from
std::unique_ptr<const Idmap> func(..., std::ostream& out_error);
to
Result<std::unique_ptr<const Idmap>> func(...);
The returned pointer is still a unique pointer to ensure the dynamically
allocated memory is automatically released when no longer used. This
means that using the returned value of either function requires one of
two patterns:
const auto idmap = func(...);
if (!idmap) {
return Error(...);
}
(*idmap)->accept(...);
or
auto result = func(...);
if (!result) {
return Error(...);
}
const auto idmap = std::move(*result);
idmap->accept(...);
Note that in the second example, result must be non-const or
the call to std::move(*result) will not compile.
With this change, the entire idmap2 project has been converted to use
Result.
Test: make idmap2_tests
Change-Id: I533f4e03b99645523d94dd5f446ad76fb435f661
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
0 files changed, 0 insertions, 0 deletions