/usr/include/bobcat/cmdfinderbase is in libbobcat-dev 4.08.02-2build1.
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 | #ifndef INCLUDED_BOBCAT_CMDFINDERBASE_
#define INCLUDED_BOBCAT_CMDFINDERBASE_
#include <string>
namespace FBB
{
// Key: the textual elements in the char */function * arrays (e.g., help)
// Cmd: what is entered interactively (e.g., h, hel, or help)
class CmdFinderBase
{
enum: size_t // mask testing the Mode-validity
{
s_all = (1 << 3) - 1
};
std::string d_cmd;
std::string d_beyond;
public:
// The default is:
// Use the key as provided
// Match case sensitively and exactly
// The last function is the catch-all
enum Mode
{
USE_FIRST = 1 << 0, // Use/rm the first word from the key
UNIQUE = 1 << 1, // Unique cmd abbreviations are OK
INSENSITIVE = 1 << 2, // Key-cmd matched case insensitively
};
void setMode(size_t mode); // to change the mode afterwards
protected:
explicit CmdFinderBase(size_t mode = 0); // 1.f
std::string const &beyond() const; // .f info beyond the command
std::string const &cmd() const; // .f the used command
// returns true if the cmd represents the
// key
bool (CmdFinderBase::*d_match)(std::string const &key) const;
// stores the command to use
void (CmdFinderBase::*d_useCmd)(std::string const &cmd);
void swap(CmdFinderBase &rhs);
private:
void useCmd(std::string const &key);
void useFirstCmd(std::string const &key);
bool matchExact(std::string const &key) const; // .f
// the command is found in the key
bool matchUnique(std::string const &key) const; // .f
bool matchInsensitive(std::string const &key) const;
bool matchUniqueInsensitive(std::string const &key) const;
};
inline CmdFinderBase::CmdFinderBase(size_t mode)
{
setMode(mode);
}
inline std::string const &CmdFinderBase::beyond() const
{
return d_beyond;
}
inline std::string const &CmdFinderBase::cmd() const
{
return d_cmd;
}
} // FBB
#endif
|