/*! * @file shell_completion.h * @brief The Shell Completion Tasks * * @todo if the second string is a Command, the third should not be completed! * @todo also make some completion for registered (or special) Types */ #ifndef _SHELL_COMPLETION_H #define _SHELL_COMPLETION_H #include #include #include // FORWARD DECLARATION class BaseObject; class ObjectListBase; namespace OrxShell { class ShellCommand; //! A class for Completing the an InputString. class ShellCompletion { //! an enumerator for different types the Shell can complete. typedef enum { NullCompletion = 0, ClassCompletion = 1, ObjectCompletion = 2, FunctionCompletion = 4, AliasCompletion = 8, ParamCompletion = 16, } CompletionType; //! A struct for ShellElements (these are used as containers to identify an Input for what it is) struct CompletionElement { CompletionElement(std::string name, CompletionType type) : name(name), type(type) {} std::string name; //!< the Name of the Element to be completed. CompletionType type; //!< the type of the Element }; public: ShellCompletion(); virtual ~ShellCompletion(); // Functions to produce the Complete Lists. bool autoComplete(std::string& input); static const std::string& typeToString(ShellCompletion::CompletionType type); private: bool objectComplete(const std::string& objectBegin, const ObjectListBase* const objectList); bool commandComplete(const std::string& commandBegin, const std::string& className); bool aliasComplete(const std::string& aliasBegin); bool paramComplete(const std::string& paramBegin, const ShellCommand* command, unsigned int paramNumber); // Generally Completes. bool generalComplete(std::string& input, const std::string& begin, const std::string& displayAs = "%s", const std::string& addBack = "", const std::string& addFront = ""); bool addToCompleteList(const std::list& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); bool addToCompleteList(const std::list& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); // Helpers. void clearCompletionList(); private: std::vector completionList; //!< A list of completions, that are io. static const std::string typeNames[]; //!< A list of Completion-Type-Names. }; } #endif /* _SHELL_COMPLETION_H */