c_cpp.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ace.define("ace/snippets/c_cpp",["require","exports","module"], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "## STL Collections\n\
  4. # std::array\n\
  5. snippet array\n\
  6. std::array<${1:T}, ${2:N}> ${3};${4}\n\
  7. # std::vector\n\
  8. snippet vector\n\
  9. std::vector<${1:T}> ${2};${3}\n\
  10. # std::deque\n\
  11. snippet deque\n\
  12. std::deque<${1:T}> ${2};${3}\n\
  13. # std::forward_list\n\
  14. snippet flist\n\
  15. std::forward_list<${1:T}> ${2};${3}\n\
  16. # std::list\n\
  17. snippet list\n\
  18. std::list<${1:T}> ${2};${3}\n\
  19. # std::set\n\
  20. snippet set\n\
  21. std::set<${1:T}> ${2};${3}\n\
  22. # std::map\n\
  23. snippet map\n\
  24. std::map<${1:Key}, ${2:T}> ${3};${4}\n\
  25. # std::multiset\n\
  26. snippet mset\n\
  27. std::multiset<${1:T}> ${2};${3}\n\
  28. # std::multimap\n\
  29. snippet mmap\n\
  30. std::multimap<${1:Key}, ${2:T}> ${3};${4}\n\
  31. # std::unordered_set\n\
  32. snippet uset\n\
  33. std::unordered_set<${1:T}> ${2};${3}\n\
  34. # std::unordered_map\n\
  35. snippet umap\n\
  36. std::unordered_map<${1:Key}, ${2:T}> ${3};${4}\n\
  37. # std::unordered_multiset\n\
  38. snippet umset\n\
  39. std::unordered_multiset<${1:T}> ${2};${3}\n\
  40. # std::unordered_multimap\n\
  41. snippet ummap\n\
  42. std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4}\n\
  43. # std::stack\n\
  44. snippet stack\n\
  45. std::stack<${1:T}> ${2};${3}\n\
  46. # std::queue\n\
  47. snippet queue\n\
  48. std::queue<${1:T}> ${2};${3}\n\
  49. # std::priority_queue\n\
  50. snippet pqueue\n\
  51. std::priority_queue<${1:T}> ${2};${3}\n\
  52. ##\n\
  53. ## Access Modifiers\n\
  54. # private\n\
  55. snippet pri\n\
  56. private\n\
  57. # protected\n\
  58. snippet pro\n\
  59. protected\n\
  60. # public\n\
  61. snippet pub\n\
  62. public\n\
  63. # friend\n\
  64. snippet fr\n\
  65. friend\n\
  66. # mutable\n\
  67. snippet mu\n\
  68. mutable\n\
  69. ## \n\
  70. ## Class\n\
  71. # class\n\
  72. snippet cl\n\
  73. class ${1:`Filename('$1', 'name')`} \n\
  74. {\n\
  75. public:\n\
  76. $1(${2});\n\
  77. ~$1();\n\
  78. \n\
  79. private:\n\
  80. ${3:/* data */}\n\
  81. };\n\
  82. # member function implementation\n\
  83. snippet mfun\n\
  84. ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {\n\
  85. ${5:/* code */}\n\
  86. }\n\
  87. # namespace\n\
  88. snippet ns\n\
  89. namespace ${1:`Filename('', 'my')`} {\n\
  90. ${2}\n\
  91. } /* namespace $1 */\n\
  92. ##\n\
  93. ## Input/Output\n\
  94. # std::cout\n\
  95. snippet cout\n\
  96. std::cout << ${1} << std::endl;${2}\n\
  97. # std::cin\n\
  98. snippet cin\n\
  99. std::cin >> ${1};${2}\n\
  100. ##\n\
  101. ## Iteration\n\
  102. # for i \n\
  103. snippet fori\n\
  104. for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\
  105. ${4:/* code */}\n\
  106. }${5}\n\
  107. \n\
  108. # foreach\n\
  109. snippet fore\n\
  110. for (${1:auto} ${2:i} : ${3:container}) {\n\
  111. ${4:/* code */}\n\
  112. }${5}\n\
  113. # iterator\n\
  114. snippet iter\n\
  115. for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {\n\
  116. ${6}\n\
  117. }${7}\n\
  118. \n\
  119. # auto iterator\n\
  120. snippet itera\n\
  121. for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {\n\
  122. ${2:std::cout << *$1 << std::endl;}\n\
  123. }${3}\n\
  124. ##\n\
  125. ## Lambdas\n\
  126. # lamda (one line)\n\
  127. snippet ld\n\
  128. [${1}](${2}){${3:/* code */}}${4}\n\
  129. # lambda (multi-line)\n\
  130. snippet lld\n\
  131. [${1}](${2}){\n\
  132. ${3:/* code */}\n\
  133. }${4}\n\
  134. ";
  135. exports.scope = "c_cpp";
  136. });