ResourceScriptToken.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===-- ResourceScriptToken.h -----------------------------------*- 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. // This declares the .rc script tokens.
  10. // The list of available tokens is located at ResourceScriptTokenList.h.
  11. //
  12. // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx
  13. //
  14. //===---------------------------------------------------------------------===//
  15. #ifndef LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_SCRIPTTOKEN_H
  16. #define LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_SCRIPTTOKEN_H
  17. #include "llvm/ADT/StringRef.h"
  18. namespace llvm {
  19. // A definition of a single resource script token. Each token has its kind
  20. // (declared in ResourceScriptTokenList) and holds a value - a reference
  21. // representation of the token.
  22. // RCToken does not claim ownership on its value. A memory buffer containing
  23. // the token value should be stored in a safe place and cannot be freed
  24. // nor reallocated.
  25. class RCToken {
  26. public:
  27. enum class Kind {
  28. #define TOKEN(Name) Name,
  29. #define SHORT_TOKEN(Name, Ch) Name,
  30. #include "ResourceScriptTokenList.h"
  31. #undef TOKEN
  32. #undef SHORT_TOKEN
  33. };
  34. RCToken(RCToken::Kind RCTokenKind, StringRef Value);
  35. // Get an integer value of the integer token.
  36. uint32_t intValue() const;
  37. bool isLongInt() const;
  38. StringRef value() const;
  39. Kind kind() const;
  40. // Check if a token describes a binary operator.
  41. bool isBinaryOp() const;
  42. private:
  43. Kind TokenKind;
  44. StringRef TokenValue;
  45. };
  46. } // namespace llvm
  47. #endif