Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef INITIALIZATION_H
- #define INITIALIZATION_H
- #include "CommandInterface.h"
- //Cutting Class
- class CutCOmmandInterface : public CommandInterface
- {
- public:
- class CutInterface : public TextTransform
- {
- public:
- std::string cuttedText;
- virtual void invokeOn(std::string& text, int startIndex, int endIndex) override {
- if (startIndex == endIndex)
- {
- cuttedText.clear();
- }
- else
- {
- cuttedText = text.substr(startIndex, endIndex);
- }
- text.erase(startIndex, endIndex);
- }
- };
- virtual std::vector<Command> initCommands() override {
- std::vector<Command> commands;
- commands.push_back(Command("cut", std::make_shared<CutInterface>()));
- return commands;
- }
- };
- //Pasting Class
- class PasteCommandInterface : public CommandInterface
- {
- public:
- class PasteInterface : public TextTransform
- {
- public:
- virtual void invokeOn(std::string& text, int startIndex, int endIndex) override {
- CutCOmmandInterface::CutInterface cut;
- text.replace(startIndex, endIndex, cut.cuttedText);
- }
- };
- virtual std::vector<Command> initCommands() override {
- std::vector<Command> commands;
- commands.push_back(Command("paste", std::make_shared<PasteInterface>()));
- return commands;
- }
- };
- #endif // !INITIALIZATION_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement