Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:21

0001 //===- ArchiveYAML.h - Archive YAMLIO implementation ------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// This file declares classes for handling the YAML representation of archives.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_OBJECTYAML_ARCHIVEYAML_H
0015 #define LLVM_OBJECTYAML_ARCHIVEYAML_H
0016 
0017 #include "llvm/Support/YAMLTraits.h"
0018 #include "llvm/ObjectYAML/YAML.h"
0019 #include "llvm/ADT/MapVector.h"
0020 #include <optional>
0021 
0022 namespace llvm {
0023 namespace ArchYAML {
0024 
0025 struct Archive {
0026   struct Child {
0027     struct Field {
0028       Field() = default;
0029       Field(StringRef Default, unsigned Length)
0030           : DefaultValue(Default), MaxLength(Length) {}
0031       StringRef Value;
0032       StringRef DefaultValue;
0033       unsigned MaxLength;
0034     };
0035 
0036     Child() {
0037       Fields["Name"] = {"", 16};
0038       Fields["LastModified"] = {"0", 12};
0039       Fields["UID"] = {"0", 6};
0040       Fields["GID"] = {"0", 6};
0041       Fields["AccessMode"] = {"0", 8};
0042       Fields["Size"] = {"0", 10};
0043       Fields["Terminator"] = {"`\n", 2};
0044     }
0045 
0046     MapVector<StringRef, Field> Fields;
0047 
0048     std::optional<yaml::BinaryRef> Content;
0049     std::optional<llvm::yaml::Hex8> PaddingByte;
0050   };
0051 
0052   StringRef Magic;
0053   std::optional<std::vector<Child>> Members;
0054   std::optional<yaml::BinaryRef> Content;
0055 };
0056 
0057 } // end namespace ArchYAML
0058 } // end namespace llvm
0059 
0060 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ArchYAML::Archive::Child)
0061 
0062 namespace llvm {
0063 namespace yaml {
0064 
0065 template <> struct MappingTraits<ArchYAML::Archive> {
0066   static void mapping(IO &IO, ArchYAML::Archive &A);
0067   static std::string validate(IO &, ArchYAML::Archive &A);
0068 };
0069 
0070 template <> struct MappingTraits<ArchYAML::Archive::Child> {
0071   static void mapping(IO &IO, ArchYAML::Archive::Child &C);
0072   static std::string validate(IO &, ArchYAML::Archive::Child &C);
0073 };
0074 
0075 } // end namespace yaml
0076 } // end namespace llvm
0077 
0078 #endif // LLVM_OBJECTYAML_ARCHIVEYAML_H