![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
ReadLine class provides a c++ wrapper around the readline c library. More...
#include <dynashell_readline.h>
Public Member Functions | |
ReadLine (const string &strName) | |
Initialization constructor. | |
ReadLine (const char *sName) | |
Initialization constructor. | |
virtual | ~ReadLine () |
Destructor. | |
int | RegisterGenerator (const string strRegEx, ReadLineAppGenFunc_T fnAppGen, void *pAppArg) |
Register application-specific tab-completion generator associated. More... | |
int | RegisterGenerator (const char *sRegEx, ReadLineAppGenFunc_T fnAppGen, void *pAppArg) |
Register application-specific tab-completion generator associated. More... | |
void | UnregisterGenerator (int nUid) |
Unregister application-specific generator associated with path. More... | |
char * | iReadLine (const char *sPrompt) |
Interactively read a line of input from standard input. More... | |
void | AddToHistory (const char *sInput) |
Add line to history. More... | |
Static Public Member Functions | |
static char * | fReadLine (FILE *fp, const char *sPrompt) |
Read one input line from the given input stream. More... | |
static char * | FileCompletionGenerator (const char *sText, int nState) |
File name tab completion generator. More... | |
static char * | UserCompletionGenerator (const char *sText, int nState) |
User name tab completion generator. More... | |
static char * | dupstr (const string &str) |
Duplicate string. More... | |
static char * | dupstr (const char *s) |
Duplicate string. More... | |
static string | strip (string &str) |
Strip string of leading and trailing white space. More... | |
static char * | strip (char *s) |
Strip string of leading and trailing white space. More... | |
static string | c14n (const string &str, size_t nLen) |
Canonicalization of a string. More... | |
static string | c14n (const char *s, size_t nLen) |
Canonicalization of a string. More... | |
static int | tokenize (char *s, char *tokv[], size_t tokmax) |
Tokenize input. More... | |
static int | wc (const string &str) |
Count the words in the string. More... | |
static int | wc (const char *s) |
Count the words in the string. More... | |
Static Public Attributes | |
static const int | FIRST = 0 |
first state | |
static const int | NOT_REG = -1 |
not registered return value | |
static ReadLine * | ReadLineThis |
static pointer this single instance More... | |
Protected Types | |
typedef vector< ReadLineEntry > | VecAppEntry |
Internal registered generator map type. | |
Protected Member Functions | |
char ** | Completion (const char *sText, int nStart, int nEnd) |
Command completion callback function. More... | |
void | MatchGenerator (int nEnd) |
Find application-specific generator associated with the first characters in the readline buffer. More... | |
Static Protected Member Functions | |
static char ** | CompletionWrap (const char *sText, int nStart, int nEnd) |
Command completion callback function wrapper. More... | |
static char * | GeneratorWrap (const char *sText, int nState) |
Generator wrapper. More... | |
Protected Attributes | |
char * | m_sName |
readline name | |
int | m_nUidCounter |
unique id counter | |
VecAppEntry | m_vecGenerators |
map of generators | |
VecAppEntry::iterator | m_posMatched |
matched entry position | |
string | m_strContext |
current readline buffer context | |
size_t | m_uTextLen |
text length of text to generator | |
ReadLine class provides a c++ wrapper around the readline c library.
Definition at line 166 of file dynashell_readline.h.
void ReadLine::AddToHistory | ( | const char * | sLine | ) |
Add line to history.
The line is added if the line is not empty and does not match the last command.
Line | to add. |
Definition at line 320 of file dynashell_readline.cxx.
Referenced by DynaShell::AddToHistory().
|
inlinestatic |
Canonicalization of a string.
s | Null-terminated string to canonicalize. |
uLen | (Sub)length of string to canonicalize. |
Definition at line 304 of file dynashell_readline.h.
Referenced by MatchGenerator().
|
static |
Canonicalization of a string.
s | Null-terminated string to canonicalize. |
uLen | (Sub)length of string to canonicalize. |
Definition at line 441 of file dynashell_readline.cxx.
References strip().
|
protected |
Command completion callback function.
sText | Text string to complete as a command. |
nStart | Start index of text string in line. |
nEnd | End index of text string in line. |
Definition at line 577 of file dynashell_readline.cxx.
|
staticprotected |
Command completion callback function wrapper.
Attempt to complete on the contents of text. The start and end bound the region of rl_line_buffer that contains the word to complete. Text is the word to complete. We can use the entire contents of rl_line_buffer in case we want to do some simple parsing.
sText | Text string to complete as a command. |
nStart | Start index of text string in line. |
nEnd | End index of text string in line. |
Definition at line 563 of file dynashell_readline.cxx.
|
inlinestatic |
Duplicate string.
str | String to dup. |
Definition at line 285 of file dynashell_readline.h.
Referenced by DynaShell::CmdListGenerator(), DynaShellCmdCreate::TabCompletion(), DynaShellCmdSetPid::TabCompletion(), DynaShellCmdLog::TabCompletion(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdLink::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), DynaShellCmdUnlink::TabCompletion(), DynaShellCmdBgtStart::TabCompletion(), DynaShellCmdReadMaxTorqueLimit::TabCompletion(), DynaShellCmdTrain::TabCompletion(), DynaShellCmdSetHalfDuplexCtl::TabCompletion(), DynaShellCmdWriteMaxTorqueLimit::TabCompletion(), DynaShellCmdPlay::TabCompletion(), DynaShellCmdReadByte::TabCompletion(), and DynaShellCmdWriteByte::TabCompletion().
|
static |
Duplicate string.
s | Null-terminated string to dup. |
Definition at line 347 of file dynashell_readline.cxx.
|
inlinestatic |
File name tab completion generator.
sText | Partial text string to complete. |
nState | Generator state. If FIRST,then initialize any statics. |
Definition at line 245 of file dynashell_readline.h.
Referenced by DynaShellCmdCreate::TabCompletion(), DynaShellCmdLoadRecording::TabCompletion(), DynaShellCmdScript::TabCompletion(), DynaShellCmdMegaScan::TabCompletion(), DynaShellCmdSaveRecording::TabCompletion(), and DynaShellCmdPlay::TabCompletion().
|
static |
Read one input line from the given input stream.
The freadline functions will read one line of input from the given input file pointer using the prompt string to prompt the user. If the prompt is NULL or an empty string then no prompt is issued. The line returned is allocated, so the caller must free it when finished.
The line returned has the final newline removed, so only the text of the line remains.
fp | File pointer to input steam. |
sPrompt | Optional user prompt string. |
Definition at line 281 of file dynashell_readline.cxx.
Referenced by DynaShell::GetInputLine().
|
staticprotected |
Generator wrapper.
Calls the matched, registered application-specific generator.
sText | Partial text string to complete. |
nState | Generator state. If FIRST,then initialize any statics. |
Definition at line 601 of file dynashell_readline.cxx.
References FIRST.
|
inline |
Interactively read a line of input from standard input.
If the readline library feature is enabled, then the input is controlled by the readline() call along with history and tab completion.
sPrompt | Optional user prompt string. |
Definition at line 217 of file dynashell_readline.h.
Referenced by DynaShell::GetInputLine().
|
protected |
Find application-specific generator associated with the first characters in the readline buffer.
nLen | Length in readline buffer. |
Definition at line 631 of file dynashell_readline.cxx.
References c14n(), and ReadLineThis.
|
inline |
Register application-specific tab-completion generator associated.
strRegEx | Regular expression applied to current readline buffer state. |
fnAppGen | Application-specific generator function. |
pAppArg | Optional application argument generator function. |
Definition at line 193 of file dynashell_readline.h.
Referenced by DynaShell::InputInit(), DynaShell::PublishCommand(), and DynaShell::PublishMap().
int ReadLine::RegisterGenerator | ( | const char * | sRegEx, |
ReadLineAppGenFunc_T | fnAppGen, | ||
void * | pAppArg | ||
) |
Register application-specific tab-completion generator associated.
sRegEx | Regular expression applied to current readline buffer state. |
fnAppGen | Application-specific generator function. |
pAppArg | Optional application argument generator function. |
Definition at line 223 of file dynashell_readline.cxx.
References ReadLineEntry::IsValid(), and ReadLineEntry::m_nUid.
|
static |
Strip string of leading and trailing white space.
[in] | str | Input string to strip. |
Definition at line 361 of file dynashell_readline.cxx.
Referenced by c14n().
|
static |
Strip string of leading and trailing white space.
A null character '\0' is inserted after the last non-white space character.
[in,out] | s | Null-terminated char*. |
Definition at line 407 of file dynashell_readline.cxx.
|
static |
Tokenize input.
[in,out] | s | Input string to tokenize. |
[out] | tokv | Array of tokens (pointer to locations in s). |
tokmax | Maximum number of tokens. |
Definition at line 472 of file dynashell_readline.cxx.
Referenced by DynaShell::Run().
void ReadLine::UnregisterGenerator | ( | int | nUid | ) |
Unregister application-specific generator associated with path.
strPath | Unique path string. |
Definition at line 248 of file dynashell_readline.cxx.
|
inlinestatic |
User name tab completion generator.
sText | Partial text string to complete. |
nState | Generator state. If FIRST,then initialize any statics. |
Definition at line 264 of file dynashell_readline.h.
|
inlinestatic |
Count the words in the string.
str | String to count. |
Definition at line 320 of file dynashell_readline.h.
Referenced by DynaShellCmdCreate::TabCompletion(), DynaShellCmdSetPid::TabCompletion(), DynaShellCmdLog::TabCompletion(), DynaShellCmdChainIn::TabCompletion(), DynaShellCmdLink::TabCompletion(), DynaShellCmdChainOut::TabCompletion(), DynaShellCmdUnlink::TabCompletion(), DynaShellCmdBgtStart::TabCompletion(), DynaShellCmdReadMaxTorqueLimit::TabCompletion(), DynaShellCmdTrain::TabCompletion(), DynaShellCmdSetHalfDuplexCtl::TabCompletion(), DynaShellCmdWriteMaxTorqueLimit::TabCompletion(), DynaShellCmdPlay::TabCompletion(), DynaShellCmdReadByte::TabCompletion(), and DynaShellCmdWriteByte::TabCompletion().
|
static |
Count the words in the string.
str | String to count. |
Definition at line 519 of file dynashell_readline.cxx.
|
static |
static pointer this single instance
Pointer to the only instance of readline supported per application.
Definition at line 172 of file dynashell_readline.h.
Referenced by MatchGenerator().