Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include "unistd.h"
  3. #include "vector"
  4. #include "map"
  5. #include "stdlib.h"
  6. #include "sstream"
  7.  
  8. using namespace std;
  9. vector<string> mots;
  10. string m;
  11. bool fini = false;
  12.  
  13. using Action= bool (*) (const vector<string>&);
  14. const std::map <string,Action> actions{
  15. {"exit",commande_exit},
  16. {"!",commande_exclamation},
  17. {"cd",commande_cd}
  18.  
  19. };
  20.  
  21.  
  22.  
  23.  
  24.  
  25. void cd(string path)
  26. {
  27. chdir(path.c_str());
  28. }
  29.  
  30. string concat()
  31. {
  32. string commande = (mots[0]+" "+mots[1]+" "+mots[2]+" "+mots[3]);
  33. cout<<commande<<endl;
  34. return commande;
  35.  
  36. }
  37. /*
  38. void afficherContenuMots()
  39. {
  40. for(string s : mots)
  41. {
  42. cout<< " " <<s<<endl;
  43. }
  44. }
  45. */
  46.  
  47. vector<string> decouper(const string &ligne)
  48. {
  49. istringstream in(ligne);
  50. string m;
  51. while(in >> m)
  52. {
  53. mots.push_back(m);
  54. }
  55. return mots;
  56. }
  57.  
  58.  
  59. void commande_exit()
  60. {
  61. fini = true;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement