Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- ArchiveYAML.h - Archive YAMLIO implementation ------------*- C++ -*-===// |
2 | // |
||
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 |
||
6 | // |
||
7 | //===----------------------------------------------------------------------===// |
||
8 | /// |
||
9 | /// \file |
||
10 | /// This file declares classes for handling the YAML representation of archives. |
||
11 | /// |
||
12 | //===----------------------------------------------------------------------===// |
||
13 | |||
14 | #ifndef LLVM_OBJECTYAML_ARCHIVEYAML_H |
||
15 | #define LLVM_OBJECTYAML_ARCHIVEYAML_H |
||
16 | |||
17 | #include "llvm/Support/YAMLTraits.h" |
||
18 | #include "llvm/ObjectYAML/YAML.h" |
||
19 | #include "llvm/ADT/MapVector.h" |
||
20 | #include <optional> |
||
21 | |||
22 | namespace llvm { |
||
23 | namespace ArchYAML { |
||
24 | |||
25 | struct Archive { |
||
26 | struct Child { |
||
27 | struct Field { |
||
28 | Field() = default; |
||
29 | Field(StringRef Default, unsigned Length) |
||
30 | : DefaultValue(Default), MaxLength(Length) {} |
||
31 | StringRef Value; |
||
32 | StringRef DefaultValue; |
||
33 | unsigned MaxLength; |
||
34 | }; |
||
35 | |||
36 | Child() { |
||
37 | Fields["Name"] = {"", 16}; |
||
38 | Fields["LastModified"] = {"0", 12}; |
||
39 | Fields["UID"] = {"0", 6}; |
||
40 | Fields["GID"] = {"0", 6}; |
||
41 | Fields["AccessMode"] = {"0", 8}; |
||
42 | Fields["Size"] = {"0", 10}; |
||
43 | Fields["Terminator"] = {"`\n", 2}; |
||
44 | } |
||
45 | |||
46 | MapVector<StringRef, Field> Fields; |
||
47 | |||
48 | std::optional<yaml::BinaryRef> Content; |
||
49 | std::optional<llvm::yaml::Hex8> PaddingByte; |
||
50 | }; |
||
51 | |||
52 | StringRef Magic; |
||
53 | std::optional<std::vector<Child>> Members; |
||
54 | std::optional<yaml::BinaryRef> Content; |
||
55 | }; |
||
56 | |||
57 | } // end namespace ArchYAML |
||
58 | } // end namespace llvm |
||
59 | |||
60 | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ArchYAML::Archive::Child) |
||
61 | |||
62 | namespace llvm { |
||
63 | namespace yaml { |
||
64 | |||
65 | template <> struct MappingTraits<ArchYAML::Archive> { |
||
66 | static void mapping(IO &IO, ArchYAML::Archive &A); |
||
67 | static std::string validate(IO &, ArchYAML::Archive &A); |
||
68 | }; |
||
69 | |||
70 | template <> struct MappingTraits<ArchYAML::Archive::Child> { |
||
71 | static void mapping(IO &IO, ArchYAML::Archive::Child &C); |
||
72 | static std::string validate(IO &, ArchYAML::Archive::Child &C); |
||
73 | }; |
||
74 | |||
75 | } // end namespace yaml |
||
76 | } // end namespace llvm |
||
77 | |||
78 | #endif // LLVM_OBJECTYAML_ARCHIVEYAML_H |