llvm/lldb/include/lldb/Core/FormatEntity.h

//===-- FormatEntity.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_CORE_FORMATENTITY_H
#define LLDB_CORE_FORMATENTITY_H

#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-types.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>

#include <string>
#include <vector>

namespace lldb_private {
class Address;
class CompletionRequest;
class ExecutionContext;
class FileSpec;
class Status;
class Stream;
class StringList;
class SymbolContext;
class ValueObject;
}

namespace llvm {
class StringRef;
}

namespace lldb_private {
namespace FormatEntity {
struct Entry {};

bool Format(const Entry &entry, Stream &s, const SymbolContext *sc,
            const ExecutionContext *exe_ctx, const Address *addr,
            ValueObject *valobj, bool function_changed, bool initial_function);

bool FormatStringRef(const llvm::StringRef &format, Stream &s,
                     const SymbolContext *sc, const ExecutionContext *exe_ctx,
                     const Address *addr, ValueObject *valobj,
                     bool function_changed, bool initial_function);

bool FormatCString(const char *format, Stream &s, const SymbolContext *sc,
                   const ExecutionContext *exe_ctx, const Address *addr,
                   ValueObject *valobj, bool function_changed,
                   bool initial_function);

Status Parse(const llvm::StringRef &format, Entry &entry);

Status ExtractVariableInfo(llvm::StringRef &format_str,
                           llvm::StringRef &variable_name,
                           llvm::StringRef &variable_format);

void AutoComplete(lldb_private::CompletionRequest &request);

// Format the current elements into the stream \a s.
//
// The root element will be stripped off and the format str passed in will be
// either an empty string (print a description of this object), or contain a
// `.`-separated series like a domain name that identifies further
//  sub-elements to display.
bool FormatFileSpec(const FileSpec &file, Stream &s, llvm::StringRef elements,
                    llvm::StringRef element_format);

/// For each variable in 'args' this function writes the variable
/// name and it's pretty-printed value representation to 'out_stream'
/// in following format:
///
/// \verbatim
/// name_1=repr_1, name_2=repr_2 ...
/// \endverbatim
void PrettyPrintFunctionArguments(Stream &out_stream, VariableList const &args,
                                  ExecutionContextScope *exe_scope);
} // namespace FormatEntity
} // namespace lldb_private

#endif // LLDB_CORE_FORMATENTITY_H