/usr/include/bobcat/readlinebuf is in libbobcat-dev 2.20.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #ifndef INCLUDED_BOBCAT_READLINEBUF_
#define INCLUDED_BOBCAT_READLINEBUF_
#include <string>
#include <streambuf>
#include <climits>
#include <memory>
namespace FBB
{
struct HistoryExpansion
{
enum Type
{
DONT_EXPAND_HISTORY,
EXPAND_HISTORY
};
enum Expansion
{
ERROR,
NO_EXPANSION,
EXPANDED,
DONT_EXEC,
};
};
class ReadLineBuf: public HistoryExpansion, public std::streambuf
{
bool d_history;
std::string d_prompt;
char *d_buffer;
char *(ReadLineBuf::*d_readline)(); // calls readLine() or expandLine()
std::string (*d_timestamp)(); // return a timestamp
Expansion d_expansion;
std::string d_expansionError;
static std::unique_ptr<ReadLineBuf> s_readLineBuf;
public:
static ReadLineBuf &initialize(std::string const &prompt,
Type type = DONT_EXPAND_HISTORY);
static ReadLineBuf &initialize(std::string const &prompt,
size_t historySize,
Type type = DONT_EXPAND_HISTORY);
static ReadLineBuf &instance();
virtual ~ReadLineBuf();
void setPrompt(std::string const &prompt = "");
bool setExpansion(Type type);
Expansion expansion() const;
std::string const &expansionError() const;
bool useTimestamps(std::string (*timestamp)() = 0);
private:
explicit ReadLineBuf(std::string const &prompt,
Type type = DONT_EXPAND_HISTORY);
explicit ReadLineBuf(std::string const &prompt,
size_t historySize,
Type type = DONT_EXPAND_HISTORY);
virtual int underflow();
char *readLine(); // reads a line, adds it to the history
char *expandLine(); // reads a line, expands it if necessary,
// then adds it to the history
char *nextLine(char *buf);
};
inline void ReadLineBuf::setPrompt(std::string const &prompt)
{
d_prompt = prompt;
}
inline ReadLineBuf::Expansion ReadLineBuf::expansion() const
{
return d_expansion;
}
inline std::string const &ReadLineBuf::expansionError() const
{
return d_expansionError;
}
} // FBB
#endif
|