61 #ifndef _RNR_READ_LINE_H 62 #define _RNR_READ_LINE_H 64 #include <sys/types.h> 77 #include <readline/readline.h> 78 #include <readline/history.h> 79 #endif // HAVE_READLINE 158 typedef char *(*AppGenFunc)(
void *pAppArg,
159 const std::string &strText,
161 const std::string &strContext);
212 const std::string &strText,
214 const std::string &strContext,
230 ReadLine(
const std::string strName =
"",
231 const std::string strPrompt =
"> ",
232 bool bUseRlLib =
true);
364 void addToHistory(
const std::string &strLine);
383 #else // !HAVE_READLINE 385 #endif // HAVE_READLINE 515 return rl_filename_completion_function(sText, nState);
516 #else // !HAVE_READLINE 518 #endif // HAVE_READLINE 536 return rl_username_completion_function(sText, nState);
537 #else // !HAVE_READLINE 539 #endif // HAVE_READLINE 556 static char *
dupstr(
const std::string &str)
570 static char *
dupstr(
const char *s);
600 size_t tokenize(
char *s,
char *tokv[],
size_t tokmax);
609 static int wc(
const std::string &str)
621 static int wc(
const char *s);
665 char **
completion(
const char *sText,
int nStart,
int nEnd);
686 char **
altCompletion(
const std::string strText,
int nStart,
int nEnd);
719 #endif // _RNR_READ_LINE_H bool m_bFError
last file op file error condition
std::string m_strError
error string
void setLineNum(const size_t uLineNum)
Set the current line number.
std::string m_strName
readline name
no filename TAB completion attempt
RlFlags
ReadLine flag modifiers.
std::vector< std::string > StringVec
Useful types.
std::string & rlreadLine()
Interactively read a line of input from standard input (stdin).
static char ** completionWrapper(const char *sText, int nStart, int nEnd)
Command completion callback function wrapper.
size_t getLineNum() const
Get the line number of the last read line.
void clearStreamStatus()
Clear stream status prior to next read operation.
AppGenFunc m_fnAppGen
application-specific generator
char *(* AppGenFunc)(void *pAppArg, const std::string &strText, int nState, const std::string &strContext)
Application-specific TAB completion generator function type.
void registerAltGenerator(AltAppGenFunc fnAltAppGen, void *pAppArg)
Register alternate application-specific tab-completion generator.
const std::string & getLastRead() const
Get last read line.
std::string m_strPrompt
prompt string
bool m_bUseRlLib
[do not] use readline library
no space(' ') after TAB completion
bool haveRlLib() const
Test if have readline library.
Of string spaces and their strangian operators.
const std::string & getPrompt() const
Get the current prompt string.
static int wc(const std::string &str)
Count the words in the string.
bool m_bEoF
last file op end of file condition
char ** altCompletion(const std::string strText, int nStart, int nEnd)
Command completion callback function.
static size_t tokenize(const std::string &str, str::StringVec &tokens)
Tokenize the given string.
static const int FIRST
first state
void * m_pAppArg
application-specific argument
void setStreamStatus(FILE *fp)
Set stream status for the last read operation.
std::string & freadLine(FILE *fp)
Read one input line from the given input stream.
static char * generatorWrapper(const char *sText, int nState)
Generator wrapper.
bool isInteractive(FILE *fp)
Test if input file pointer is interactive.
virtual ~ReadLine()
Destructor.
void resetLineNum()
Reset the line number to zero.
char ** completion(const char *sText, int nStart, int nEnd)
Command completion callback function.
const std::string & getName() const
Get this instance of readline name.
size_t m_uLineNum
line number
bool useRlLib() const
Test if the readline library is enabled.
ReadLine class provides a C++ wrapper around the readline C library.
bool isFError() const
Test if the last read operation resulted in an I/O error condition.
const std::string(* AltAppGenFunc)(void *pAppArg, const std::string &strText, int nIndex, const std::string &strContext, int nStart, int nEnd, unsigned &uFlags)
Alternative application-specific TAB completion generator function type.
static const char * RlTabEnd
no more matches value (empty string)
static char * usernameCompletionGenerator(const char *sText, int nState)
Username TAB completion generator.
no default TAB completion match
ReadLine(const std::string strName="", const std::string strPrompt="> ", bool bUseRlLib=true)
Default initialization constructor.
void registerGenerator(AppGenFunc fnAppGen, void *pAppArg)
Register application-specific tab-completion generator.
AltAppGenFunc m_fnAltAppGen
alternate app-specific generator
void setPrompt(const std::string &strPrompt)
Set the prompt string.
std::string & ireadLine()
Interactively read a line of input from standard input (stdin).
static ReadLine * ThisObj
static pointer to this single instance
static char * dupstr(const std::string &str)
Duplicate string.
bool isEoF() const
Test if the last read operation resulted in an end-of-file condition.
void unregisterGenerator()
Unregister application-specific generator associated with path.
static char * filenameCompletionGenerator(const char *sText, int nState)
Filename TAB completion generator.
std::string m_strLine
last read line
const std::string & getErrorStr() const
Get the most recently set error string.