LLVM  6.0.0svn
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::LineEditor Class Reference

#include "llvm/LineEditor/LineEditor.h"

Classes

struct  Completion
 A possible completion at a given cursor position. More...
 
struct  CompletionAction
 The action to perform upon a completion request. More...
 
struct  InternalData
 

Public Member Functions

 LineEditor (StringRef ProgName, StringRef HistoryPath="", FILE *In=stdin, FILE *Out=stdout, FILE *Err=stderr)
 Create a LineEditor object. More...
 
 ~LineEditor ()
 
llvm::Optional< std::string > readLine () const
 Reads a line. More...
 
void saveHistory ()
 
void loadHistory ()
 
template<typename T >
void setCompleter (T Comp)
 Set the completer for this LineEditor. More...
 
template<typename T >
void setListCompleter (T Comp)
 Set the completer for this LineEditor to the given list completer. More...
 
CompletionAction getCompletionAction (StringRef Buffer, size_t Pos) const
 Use the current completer to produce a CompletionAction for the given completion request. More...
 
const std::string & getPrompt () const
 
void setPrompt (const std::string &P)
 

Static Public Member Functions

static std::string getDefaultHistoryPath (StringRef ProgName)
 

Detailed Description

Definition at line 23 of file LineEditor.h.

Constructor & Destructor Documentation

◆ LineEditor()

LineEditor::LineEditor ( StringRef  ProgName,
StringRef  HistoryPath = "",
FILE *  In = stdin,
FILE *  Out = stdout,
FILE *  Err = stderr 
)

Create a LineEditor object.

Parameters
ProgNameThe name of the current program. Used to form a default prompt.
HistoryPathPath to the file in which to store history data, if possible.
InThe input stream used by the editor.
OutThe output stream used by the editor.
ErrThe error stream used by the editor.

Definition at line 287 of file LineEditor.cpp.

References llvm::Data, and llvm::tgtok::In.

Referenced by getCompletionAction().

◆ ~LineEditor()

LineEditor::~LineEditor ( )

Definition at line 294 of file LineEditor.cpp.

Referenced by getCompletionAction().

Member Function Documentation

◆ getCompletionAction()

LineEditor::CompletionAction LineEditor::getCompletionAction ( StringRef  Buffer,
size_t  Pos 
) const

Use the current completer to produce a CompletionAction for the given completion request.

If the current completer is a list completer, this will return an AK_Insert CompletionAction if each completion has a common prefix, or an AK_ShowCompletions CompletionAction otherwise.

Parameters
BufferThe string to complete
PosThe zero-based cursor position in the StringRef

Definition at line 84 of file LineEditor.cpp.

References llvm::LineEditor::CompletionAction::AK_Insert, llvm::LineEditor::CompletionAction::AK_ShowCompletions, assert(), llvm::LineEditor::CompletionAction::Completions, llvm::Data, E, llvm::StringRef::empty(), getDefaultHistoryPath(), I, llvm::tgtok::In, llvm::LineEditor::CompletionAction::Kind, llvm::AArch64CC::LE, LineEditor(), loadHistory(), llvm::LineEditor::InternalData::Out, readLine(), saveHistory(), llvm::StringRef::str(), llvm::LineEditor::CompletionAction::Text, and ~LineEditor().

Referenced by setListCompleter().

◆ getDefaultHistoryPath()

std::string LineEditor::getDefaultHistoryPath ( StringRef  ProgName)
static

◆ getPrompt()

const std::string& llvm::LineEditor::getPrompt ( ) const
inline

Definition at line 106 of file LineEditor.h.

◆ loadHistory()

void LineEditor::loadHistory ( )

Definition at line 299 of file LineEditor.cpp.

Referenced by getCompletionAction().

◆ readLine()

Optional< std::string > LineEditor::readLine ( ) const

Reads a line.

Returns
The line, or llvm::Optional<std::string>() on EOF.

Definition at line 301 of file LineEditor.cpp.

Referenced by getCompletionAction().

◆ saveHistory()

void LineEditor::saveHistory ( )

Definition at line 298 of file LineEditor.cpp.

Referenced by getCompletionAction().

◆ setCompleter()

template<typename T >
void llvm::LineEditor::setCompleter ( T  Comp)
inline

Set the completer for this LineEditor.

A completer is a function object which takes arguments of type StringRef (the string to complete) and size_t (the zero-based cursor position in the StringRef) and returns a CompletionAction.

Definition at line 85 of file LineEditor.h.

◆ setListCompleter()

template<typename T >
void llvm::LineEditor::setListCompleter ( T  Comp)
inline

Set the completer for this LineEditor to the given list completer.

A list completer is a function object which takes arguments of type StringRef (the string to complete) and size_t (the zero-based cursor position in the StringRef) and returns a std::vector<Completion>.

Definition at line 93 of file LineEditor.h.

References getCompletionAction().

◆ setPrompt()

void llvm::LineEditor::setPrompt ( const std::string &  P)
inline

Definition at line 107 of file LineEditor.h.

References llvm::Data, and P.


The documentation for this class was generated from the following files: