llvm/lldb/include/lldb/Interpreter/Options.h

//===-- Options.h -----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_INTERPRETER_OPTIONS_H
#define LLDB_INTERPRETER_OPTIONS_H

#include <set>
#include <vector>

#include "lldb/Utility/Args.h"
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/OptionDefinition.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-private.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"

namespace lldb_private {

struct Option;

OptionArgVector;
OptionArgVectorSP;

struct OptionArgElement {};

OptionElementVector;

/// \class Options Options.h "lldb/Interpreter/Options.h"
/// A command line option parsing protocol class.
///
/// Options is designed to be subclassed to contain all needed options for a
/// given command. The options can be parsed by calling the Parse function.
///
/// The options are specified using the format defined for the libc options
/// parsing function getopt_long_only: \code
///     #include <getopt.h>
///     int getopt_long_only(int argc, char * const *argv, const char
///     *optstring, const struct option *longopts, int *longindex);
/// \endcode
///
class Options {};

class OptionGroup {};

class OptionGroupOptions : public Options {};

/// Creates an error that represents the failure to parse an command line option
/// argument. This creates an error containing all information needed to show
/// the developer what went wrong when parsing their command. It is recommended
/// to use this instead of writing an error by hand.
///
/// \param[in] option_arg
///   The argument that was attempted to be parsed.
///
/// \param[in] short_option
///   The short form of the option. For example, if the flag is -f, the short
///   option is "f".
///
/// \param[in] long_option
///   The long form of the option. This field is optional. If the flag is
///   --force, then the long option is "force".
///
/// \param[in] additional_context
///   This is extra context that will get included in the error. This field is
///   optional.
///
/// \return
///   An llvm::Error that contains a standardized format for what went wrong
///   when parsing and why.
llvm::Error CreateOptionParsingError(llvm::StringRef option_arg,
                                     const char short_option,
                                     llvm::StringRef long_option = {};

static constexpr llvm::StringLiteral g_bool_parsing_error_message =;
static constexpr llvm::StringLiteral g_int_parsing_error_message =;
static constexpr llvm::StringLiteral g_language_parsing_error_message =;

} // namespace lldb_private

#endif // LLDB_INTERPRETER_OPTIONS_H