ResourceProcessor.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- ResourceProcessor.h -------------------------------------*- 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. #ifndef LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_PROCESSOR_H
  14. #define LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_PROCESSOR_H
  15. #include "llvm/ADT/StringMap.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include "llvm/Support/Error.h"
  18. #include "llvm/Support/raw_ostream.h"
  19. #include <memory>
  20. #include <vector>
  21. namespace llvm {
  22. class WindowsResourceProcessor {
  23. public:
  24. using PathType = SmallVector<char, 64>;
  25. WindowsResourceProcessor() {}
  26. void addDefine(StringRef Key, StringRef Value = StringRef()) {
  27. PreprocessorDefines.emplace_back(Key, Value);
  28. }
  29. void addInclude(const PathType &IncludePath) {
  30. IncludeList.push_back(IncludePath);
  31. }
  32. void setVerbose(bool Verbose) { IsVerbose = Verbose; }
  33. void setNullAtEnd(bool NullAtEnd) { AppendNull = NullAtEnd; }
  34. Error process(StringRef InputData,
  35. std::unique_ptr<raw_fd_ostream> OutputStream);
  36. private:
  37. StringRef InputData;
  38. std::vector<PathType> IncludeList;
  39. std::vector<std::pair<StringRef, StringRef>> PreprocessorDefines;
  40. bool IsVerbose, AppendNull;
  41. };
  42. }
  43. #endif
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif