Skip to content
Snippets Groups Projects
Select Git revision
  • 2960129e790381e5d68ca4d94e8838cea5509c0c
  • master default protected
  • ccl
  • jardin
  • cms/general/lorem
  • cms/ccl/ca-marche
  • cms/grenier/index
  • content
  • preview
  • develop
  • deploy
  • test
12 results

documents-collection.html

Blame
  • Action.hpp 1.24 KiB
    #ifndef ACTION__H
    #define ACTION__H
    
    #include <functional>
    #include <string>
    #include <vector>
    #include "Config.hpp"
    
    class Action
    {
      public :
    
      enum Type
      {
        Push,
        Pop,
        Write,
        MoveWord,
        MoveChar,
        AddLines,
        Check
      };
    
      enum Object
      {
        Buffer,
        Stack
      };
    
      private :
    
      Type type;
      std::vector<std::string> data;
    
      public :
    
      std::function<void(Config & config, Action & action)> apply;
      std::function<void(Config & config, Action & action)> undo;
      std::function<bool(const Config & config, const Action & action)> appliable;
    
      private :
    
      Action(Type type, std::function<void(Config & config, Action & action)> apply, std::function<void(Config & config, Action & action)> undo, std::function<bool(const Config & config, const Action & action)> appliable);
    
      public :
    
      static Object str2object(const std::string & s);
      static Action addLinesIfNeeded(int nbLines);
      static Action moveWordIndex(int movement);
      static Action moveCharacterIndex(int movement);
      static Action addHypothesis(const std::string & colName, std::size_t lineIndex, const std::string & hypothesis);
      static Action addHypothesisRelative(const std::string & colName, Object object, int relativeIndex, const std::string & hypothesis);
    };
    
    #endif