Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. class %Object% {
  2.  
  3. public:
  4.  
  5. explicit %Object%() = default;
  6. ~%Object%() = default;
  7.  
  8. %Object%(%Object%&& rhs) = default;
  9. %Object%(const %Object%& rhs) = default;
  10. %Object%& operator=(%Object%&& rhs) = default;
  11. %Object%& operator=(const %Object%& rhs) = default;
  12.  
  13. protected:
  14.  
  15. private:
  16.  
  17. }
  18.  
  19. #include "%Object%.hpp"
  20.  
  21. " Function to substitute the class names in a file
  22. function! SubstituteClassName()
  23. execute "1,$s/%Object%/" . expand("%:t:r") . "/g"
  24. endfunction
  25.  
  26. " Function to create the skeleton of a header file
  27. function! CreateHeaderFile()
  28. 1
  29. insert
  30. #pragma once
  31. #ifndef %Object%_H
  32. #define %Object%_H
  33.  
  34. class %Object% {
  35.  
  36. public:
  37.  
  38. explicit %Object%() = default;
  39. ~%Object%() = default;
  40.  
  41. %Object%(%Object%&& rhs) = default;
  42. %Object%(const %Object%& rhs) = default;
  43. %Object%& operator=(%Object%&& rhs) = default;
  44. %Object%& operator=(const %Object%& rhs) = default;
  45.  
  46. protected:
  47.  
  48. private:
  49.  
  50. }
  51. .
  52. call SubstituteClassName()
  53. endfunction
  54.  
  55. " Function to create the skeleton of a source file
  56. function! CreateSourceFile()
  57. 1
  58. insert
  59. #include "%Object%.hpp"
  60. .
  61. call SubstituteClassName()
  62. endfunction
  63.  
  64. function! CreateClassFiles(name)
  65.  
  66. " Open the header file.
  67. execute "edit " . a:name . ".hpp"
  68. " Create the skeleton of the header file
  69. call CreateHeaderFile()
  70. " Write the file
  71. wa
  72.  
  73. " Open the source file.
  74. execute "edit " . a:name . ".cpp"
  75. " Create the skeleton of the header file
  76. call CreateSourceFile()
  77. " Write the file
  78. wa
  79.  
  80. endfunction
  81.  
  82. call CreateClassFiles("myclassname")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement