ArchiveYAML.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ArchiveYAML.h - Archive YAMLIO implementation ------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// This file declares classes for handling the YAML representation of archives.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_OBJECTYAML_ARCHIVEYAML_H
  19. #define LLVM_OBJECTYAML_ARCHIVEYAML_H
  20. #include "llvm/Support/YAMLTraits.h"
  21. #include "llvm/ObjectYAML/YAML.h"
  22. #include "llvm/ADT/MapVector.h"
  23. namespace llvm {
  24. namespace ArchYAML {
  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. Child() {
  36. Fields["Name"] = {"", 16};
  37. Fields["LastModified"] = {"0", 12};
  38. Fields["UID"] = {"0", 6};
  39. Fields["GID"] = {"0", 6};
  40. Fields["AccessMode"] = {"0", 8};
  41. Fields["Size"] = {"0", 10};
  42. Fields["Terminator"] = {"`\n", 2};
  43. }
  44. MapVector<StringRef, Field> Fields;
  45. Optional<yaml::BinaryRef> Content;
  46. Optional<llvm::yaml::Hex8> PaddingByte;
  47. };
  48. StringRef Magic;
  49. Optional<std::vector<Child>> Members;
  50. Optional<yaml::BinaryRef> Content;
  51. };
  52. } // end namespace ArchYAML
  53. } // end namespace llvm
  54. LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ArchYAML::Archive::Child)
  55. namespace llvm {
  56. namespace yaml {
  57. template <> struct MappingTraits<ArchYAML::Archive> {
  58. static void mapping(IO &IO, ArchYAML::Archive &A);
  59. static std::string validate(IO &, ArchYAML::Archive &A);
  60. };
  61. template <> struct MappingTraits<ArchYAML::Archive::Child> {
  62. static void mapping(IO &IO, ArchYAML::Archive::Child &C);
  63. static std::string validate(IO &, ArchYAML::Archive::Child &C);
  64. };
  65. } // end namespace yaml
  66. } // end namespace llvm
  67. #endif // LLVM_OBJECTYAML_ARCHIVEYAML_H
  68. #ifdef __GNUC__
  69. #pragma GCC diagnostic pop
  70. #endif