blob: 254121cd318a3845911d5e04bf22fbbd60e6cb46 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- ResourceScriptToken.h -----------------------------------*- C++-*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
16#ifndef LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_SCRIPTTOKEN_H
17#define LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_RESOURCE_SCRIPTTOKEN_H
18
19#include "llvm/ADT/StringRef.h"
20
21namespace llvm {
22
23// A definition of a single resource script token. Each token has its kind
24// (declared in ResourceScriptTokenList) and holds a value - a reference
25// representation of the token.
26// RCToken does not claim ownership on its value. A memory buffer containing
27// the token value should be stored in a safe place and cannot be freed
28// nor reallocated.
29class RCToken {
30public:
31 enum class Kind {
32#define TOKEN(Name) Name,
33#define SHORT_TOKEN(Name, Ch) Name,
34#include "ResourceScriptTokenList.h"
35#undef TOKEN
36#undef SHORT_TOKEN
37 };
38
39 RCToken(RCToken::Kind RCTokenKind, StringRef Value);
40
41 // Get an integer value of the integer token.
42 uint32_t intValue() const;
43 bool isLongInt() const;
44
45 StringRef value() const;
46 Kind kind() const;
47
48 // Check if a token describes a binary operator.
49 bool isBinaryOp() const;
50
51private:
52 Kind TokenKind;
53 StringRef TokenValue;
54};
55
56} // namespace llvm
57
58#endif