ArchiveYAML.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <optional>
  24. namespace llvm {
  25. namespace ArchYAML {
  26. struct Archive {
  27. struct Child {
  28. struct Field {
  29. Field() = default;
  30. Field(StringRef Default, unsigned Length)
  31. : DefaultValue(Default), MaxLength(Length) {}
  32. StringRef Value;
  33. StringRef DefaultValue;
  34. unsigned MaxLength;
  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. MapVector<StringRef, Field> Fields;
  46. std::optional<yaml::BinaryRef> Content;
  47. std::optional<llvm::yaml::Hex8> PaddingByte;
  48. };
  49. StringRef Magic;
  50. std::optional<std::vector<Child>> Members;
  51. std::optional<yaml::BinaryRef> Content;
  52. };
  53. } // end namespace ArchYAML
  54. } // end namespace llvm
  55. LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::ArchYAML::Archive::Child)
  56. namespace llvm {
  57. namespace yaml {
  58. template <> struct MappingTraits<ArchYAML::Archive> {
  59. static void mapping(IO &IO, ArchYAML::Archive &A);
  60. static std::string validate(IO &, ArchYAML::Archive &A);
  61. };
  62. template <> struct MappingTraits<ArchYAML::Archive::Child> {
  63. static void mapping(IO &IO, ArchYAML::Archive::Child &C);
  64. static std::string validate(IO &, ArchYAML::Archive::Child &C);
  65. };
  66. } // end namespace yaml
  67. } // end namespace llvm
  68. #endif // LLVM_OBJECTYAML_ARCHIVEYAML_H
  69. #ifdef __GNUC__
  70. #pragma GCC diagnostic pop
  71. #endif