Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionArgParser.h ---------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONARGPARSER_H
0010 #define LLDB_INTERPRETER_OPTIONARGPARSER_H
0011 
0012 #include "lldb/lldb-private-types.h"
0013 
0014 #include <optional>
0015 
0016 namespace lldb_private {
0017 
0018 struct OptionArgParser {
0019   /// Try to parse an address. If it succeeds return the address with the
0020   /// non-address bits removed.
0021   static lldb::addr_t ToAddress(const ExecutionContext *exe_ctx,
0022                                 llvm::StringRef s, lldb::addr_t fail_value,
0023                                 Status *error_ptr);
0024 
0025   /// As for ToAddress but do not remove non-address bits from the result.
0026   static lldb::addr_t ToRawAddress(const ExecutionContext *exe_ctx,
0027                                    llvm::StringRef s, lldb::addr_t fail_value,
0028                                    Status *error_ptr);
0029 
0030   static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr);
0031 
0032   static llvm::Expected<bool> ToBoolean(llvm::StringRef option_name,
0033                                         llvm::StringRef option_arg);
0034 
0035   static char ToChar(llvm::StringRef s, char fail_value, bool *success_ptr);
0036 
0037   static int64_t ToOptionEnum(llvm::StringRef s,
0038                               const OptionEnumValues &enum_values,
0039                               int32_t fail_value, Status &error);
0040 
0041   static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s,
0042                                                lldb::ScriptLanguage fail_value,
0043                                                bool *success_ptr);
0044 
0045   // TODO: Use StringRef
0046   static Status ToFormat(const char *s, lldb::Format &format,
0047                          size_t *byte_size_ptr); // If non-NULL, then a
0048                                                  // byte size can precede
0049                                                  // the format character
0050 
0051 private:
0052   static std::optional<lldb::addr_t>
0053   DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
0054               Status *error);
0055 };
0056 
0057 } // namespace lldb_private
0058 
0059 #endif // LLDB_INTERPRETER_OPTIONARGPARSER_H