brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · ded496f Raw
57 lines · c
1//===-- flags_parser.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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef SCUDO_FLAGS_PARSER_H_10#define SCUDO_FLAGS_PARSER_H_11 12#include "report.h"13#include "string_utils.h"14 15#include <stddef.h>16 17namespace scudo {18 19enum class FlagType : u8 {20  FT_bool,21  FT_int,22};23 24class FlagParser {25public:26  void registerFlag(const char *Name, const char *Desc, FlagType Type,27                    void *Var);28  void parseString(const char *S);29  void printFlagDescriptions();30  void parseStringPair(const char *Name, const char *Value);31 32private:33  static const u32 MaxFlags = 20;34  struct Flag {35    const char *Name;36    const char *Desc;37    FlagType Type;38    void *Var;39  } Flags[MaxFlags];40 41  u32 NumberOfFlags = 0;42  const char *Buffer = nullptr;43  uptr Pos = 0;44 45  void reportFatalError(const char *Error);46  void skipWhitespace();47  void parseFlags();48  void parseFlag();49  bool runHandler(const char *Name, const char *Value, char Sep);50};51 52void reportUnrecognizedFlags();53 54} // namespace scudo55 56#endif // SCUDO_FLAGS_PARSER_H_57