1 //===- ArchiveEmitter.cpp ---------------------------- --------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ObjectYAML/ArchiveYAML.h"
10 #include "llvm/ObjectYAML/yaml2obj.h"
11 #include "llvm/Support/Error.h"
12 #include "llvm/Support/raw_ostream.h"
15 using namespace ArchYAML
;
20 bool yaml2archive(ArchYAML::Archive
&Doc
, raw_ostream
&Out
, ErrorHandler EH
) {
21 Out
.write(Doc
.Magic
.data(), Doc
.Magic
.size());
24 Doc
.Content
->writeAsBinary(Out
);
31 auto WriteField
= [&](StringRef Field
, uint8_t Size
) {
32 Out
.write(Field
.data(), Field
.size());
33 for (size_t I
= Field
.size(); I
!= Size
; ++I
)
37 for (const Archive::Child
&C
: *Doc
.Members
) {
38 for (auto &P
: C
.Fields
)
39 WriteField(P
.second
.Value
, P
.second
.MaxLength
);
42 C
.Content
->writeAsBinary(Out
);
44 Out
.write(*C
.PaddingByte
);