Created
March 4, 2013 00:04
-
-
Save Rolias/5078989 to your computer and use it in GitHub Desktop.
Export of my Eclipse C++ templates (warts and all) as an xml file. Paste into an .xml file and then use Window->Preferences->C/C++->Editor->Templates and then select the Import... button and pick the file where you stored this data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
-<templates><template name=",,e" enabled="true" description="<< endl;" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"><< endl;</template><template name="Action" enabled="true" description="Typedef for pointer to member function of any class that returns void and takes no parameters" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">typedef std::tr1::function<void ()> Action; //Need to include <functional> to use this. Create an action like this //Action the_action = std::tr1::bind(&SomeClass::MemberWithMatchSig, this); //Using this binds to current class, otherwise use ptr to class to invoke upon.</template><template name="alian" enabled="true" description="alias a namespace" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">namespace ${Alias} = ${FullNamespaceName};</template><template name="assign" enabled="true" description="Assginment Operator" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">${ClassName}& operator=(const ${ClassName}& rhs);</template><template name="author" enabled="true" description="author name" deleted="false" context="org.eclipse.cdt.ui.text.templates.comment" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.comment.author">author ${user} ${copyright}</template><template name="bms" enabled="true" description="Boost Make Shared Ptr" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">make_shared<${cursor}>()</template><template name="braces" enabled="true" description="Surround With Braces" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">{ ${line_selection} } </template><template name="bsp" enabled="true" description="Boost Shared Ptr" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">shared_ptr<${cursor}> </template><template name="c,," enabled="true" description="cout <<" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">cout << </template><template name="cae" enabled="true" description="Check Array Equal" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">CHECK_ARRAY_EQUAL(${expected},${actual},${expected}.size());</template><template name="catch" enabled="true" description="catch block" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.catch">catch (${Exception} e) { ${cursor} }</template><template name="cem" enabled="true" description="CHECK EQUAL with message" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">CHECK_EQUAL_MSG(expected, actual, "${cursor}");</template><template name="ceq" enabled="true" description="Check Equal" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">CHECK_EQUAL(${expected},${actual});</template><template name="ck" enabled="true" description="CHECK" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">CHECK(${UnaryOp});</template><template name="class" enabled="true" description="class declaration" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.class">class ${name} { public: ${cursor} private: };</template><template name="comFields" enabled="true" description="Comment section for Private fields" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//========================================================== // Fields //==========================================================</template><template name="comment" enabled="true" description="default multiline comment" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.comment">//================================================================= // author ${user} // //=================================================================</template><template name="comMethods" enabled="true" description="Comment for Methods Section" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//================================================================= // Methods //=================================================================</template><template name="comprops" enabled="true" description="Comment for properties" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//================================================================= // Properties //=================================================================</template><template name="copy" enabled="true" description="Copy Constructor" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">explicit ${ClassName}(const ${ClassName}& rhs);</template><template name="couts" enabled="true" description="cout typical usage cout << something << endl;" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">std::cout << ${cursor} << std::endl;</template><template name="cvbe" enabled="true" description="Check Vector Bytes Equal" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">CHECK_VECBYTE_EQUAL(expected, actual, "${cursor}");</template><template name="do" enabled="true" description="do while statement" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.do">do { ${line_selection}${cursor} } while (${condition});</template><template name="else" enabled="true" description="else block" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.else">else { ${cursor} }</template><template name="elseif" enabled="true" description="else if block" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.elseif">else if (${condition}) { ${cursor} }</template><template name="enum" enabled="true" description="enum wrapped in a namespace" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">namespace ${GoodName} { enum ${AnyName}{} } typedef ${GoodName}::${AnyName} ${GoodName}Type </template><template name="findif" enabled="true" description="using find_if with functor - remove parens for static or free function" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"> const ${iterType} iter = std::find_if(${coll}.begin(), ${coll}.end(), ${Functor}(${optConstArg})); if (iter != ${coll}.end()) { ${cursor} } else { std::cout << "Item not found in collection.\n"; }</template><template name="findif_m" enabled="true" description="using find_if with a member function of containing class (not collector class)" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"> const ${iterType} iter = std::find_if(${coll}.begin(), ${coll}.end(), std::bind1st(std::mem_fun(&${thisClass}::${memberFunc}), this); if (iter != ${coll}.end()) { ${cursor} } else { std::cout << "Item not found in collection.\n"; }</template><template name="for" enabled="true" description="for loop" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.for">for (int ${var} = 0; ${var} < ${max}; ++${var}) { ${line_selection}${cursor} }</template><template name="for" enabled="true" description="for loop with temporary variable" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.for">for (int ${var} = 0; ${var} < ${max}; ++${var}) { ${line_selection}${cursor} }</template><template name="foref" enabled="true" description="For each that uses a functor" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">std::for_each(${coll}.begin, ${coll}.end, ${functor}(${optionalConstructorParams}));</template><template name="forem" enabled="true" description="For each that uses a functor" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">std::for_each(${coll}.begin, ${coll}.end, std::bind1st(std::mem_fun(&${thisClass}::${memberFunc}), this));</template><template name="forvec" enabled="true" description="for loop using iterators" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">for (std::vector<${Type}*>::const_iterator ${item} = ${collection}.begin(); ${item} != ${collection}.end(); ++${item}) { ${cursor} }</template><template name="functor" enabled="true" description="Create a basic functor - could have 0 or more than one parameter " deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"> class ${FunctorClassName}: public std::unary_function<${typeInCollection}, ${typeOfPredicateResult}> { public: explicit ${FunctorClassName}(const ${typeOfOptionalStateParameter} value) : m_value(value) { } bool operator()(const ${typeInCollection} collItem) const { //do something here that make sense like if collItem is a ptr //return collItem->getButtonNumber() == m_value; } private: int m_value; };</template><template name="if" enabled="true" description="if statement" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.if">if (${condition}) { ${line_selection}${cursor} }</template><template name="ifelse" enabled="true" description="if else statement" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.ifelse">if (${condition}) { ${cursor} } else { }</template><template name="insClass" enabled="true" description="Insert the class name" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">${cursor}::</template><template name="main" enabled="true" description="main method" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.main">int main(int argc, char **argv) { ${cursor} } </template><template name="mcomment" enabled="true" description="method comment" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//============================================================================== //${enclosing_method} //${cursor} //==============================================================================</template><template name="myAction" enabled="true" description="Function Pointer Typedef named MyAction to a member function of current class" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//if tr1 is available don't use this. Use Action instead. It's syntactically much nicer. typedef void (${SomeClass}::*MyAction) (); //Use: MyAction some_name = &SomeClass::SomeMethod; //Then in the function of that class that receives my_action as a parameter it can be invoked with // ((*this).*SomeMethod)(); or you can define a macro //#define INVOKE_ACTION (object, ptrToMember) ((object).*ptrToMember)) //and then invoke like this // INVOKE_ACTION(*this, SomeMethod)(); </template><template name="namespace" enabled="true" description="namespace declaration" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.namespace">namespace ${name} { ${cursor} } // namespace ${name}</template><template name="new" enabled="true" description="create new object" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.new">${type} ${name} = new ${type}(${arguments});</template><template name="nsl" enabled="true" description="namespace SL" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">namespace SL = SyncorLibrary;</template><template name="op<<" enabled="true" description="operator << overload" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//operator >> and << are NEVER members friend std::ostream& operator<< (std::ostream& out, const ${ClassName}& myclass);</template><template name="op=" enabled="true" description="canonical declare for operator= (make private to hide)" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">${ClassName}& operator= (const ${ClassName}& rhs);</template><template name="op==" enabled="true" description="operator == " deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">bool operator==(const ${ClassName}& rhs) const${cursor};</template><template name="privSec" enabled="true" description="Private Section Comment for Source File" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//======================================================================== //private methods //========================================================================</template><template name="propfull" enabled="true" description="Property Getter and Setter" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">const ${type} Get${name}() const {return m_${name};} void Set${name}(const ${type} value){ m_${name} = value;}</template><template name="propget" enabled="true" description="Typical property getter" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">const ${type} Get${name}() const {return m_${name};}</template><template name="propset" enabled="true" description="property setting" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">void Set${name}(const ${type} value){ m_${name} = value;}</template><template name="pubsec" enabled="true" description="Public Section Comment for Source File" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">//======================================================================== //public methods //========================================================================</template><template name="sc<" enabled="true" description="static cast wrapper" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">static_cast<${CastToType}>(${word_selection})</template><template name="stderr" enabled="true" description="print to standard error" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.fprintf">fprintf(stderr, ${cursor});</template><template name="stdout" enabled="true" description="print to standard output" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.printf">printf(${cursor});</template><template name="svb" enabled="true" description="std::vector<byte>" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">std::vector<byte></template><template name="switch" enabled="true" description="switch case statement" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.c.switch">switch (${key}) { case ${value}: ${cursor} break; default: break; }</template><template name="testy" enabled="true" description="" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">Put some text ${sel} around the selected text.</template><template name="tf" enabled="true" description="Test Fixture" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">TEST_FIXTURE(${Fixture}, ${do_something_test_name}) { ${cursor} }</template><template name="tm" enabled="true" description="Simple Test Method" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">TEST (${TestName}) { //Test Code }</template><template name="try" enabled="true" description="try catch block" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.try">try { ${line_selection}${cursor} } catch (${Exception} e) { }</template><template name="trydestructor" enabled="true" description="Try Catch For Destructor With Comment" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"> try { ${line_selection} } catch (...)//Don't allow throw in destructor - More Effective C++ #11 { }</template><template name="tsf" enabled="true" description="Test Suite Fixture" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">SUITE(${SuiteName}) { //Can put reusable test constants here //static string LEFT_IMAGE_NAME = "Art\\SwitchLeft_up.bmp"; struct ${SuiteName}Fixture { ${SuiteName}Fixture() : //initializer list items go here { } //Member fields go here ~${SuiteName}Fixture() { } }; TEST_FIXTURE(${SuiteName}Fixture, ${TestName}) { //Test Code } }</template><template name="tsfb" enabled="true" description="Test Suit Fixture For Reach Library using Boost shared pointer" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">#include <string> #include "../src/StubReaderWriter.h" #include "../src/TestHelper.h" #include <boost/shared_ptr.hpp> #include <DisplayObject.h> #include <Drawing/Point.h> //INCLUDE The unit under test here. If it doesn't //Include <Drawing/Point.h> from SyncorLibrary and DisplayObject.h from Reach Lib //Add those as well. using namespace ReachLib; using namespace SyncorLibrary; using std::string; using boost::shared_ptr; using boost::make_shared; SUITE(${SuiteName}Should) { struct ${SuiteName}Fixture { ${SuiteName}Fixture() : m_reachStub(make_shared<StubReaderWriter>()), m_loc(make_shared<Point>(5,50)) { DisplayObject::SetWriter(m_reachStub.get()); } shared_ptr <StubReaderWriter> m_reachStub; shared_ptr<Point> m_loc; }; TEST_FIXTURE(${SuiteName}Fixture, ${TestName}) { //Test Code } } </template><template name="tsfr" enabled="true" description="Test Suit Fixture For Reach Library" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">#include <string> #include "../src/StubReaderWriter.h" #include "../src/TestHelper.h" //INCLUDE The unit under test here. If it doesn't //Include <Drawing/Point.h> from SyncorLibrary and DisplayObject.h from Reach Lib //Add those as well. using namespace ReachLib; using namespace SyncorLibrary; using std::string; SUITE(${SuiteName}Should) { //Can put reusable test constants here //static string LEFT_IMAGE_NAME = "Art\\SwitchLeft_up.bmp"; struct ${SuiteName}Fixture { ${SuiteName}Fixture() : m_reachStub(new StubReaderWriter()), m_loc(new Point(5,50)) { DisplayObject::SetWriter(m_reachStub); } StubReaderWriter* m_reachStub; //Member fields go here Point* m_loc; ~${SuiteName}Fixture() { delete m_reachStub; delete m_loc; } }; TEST_FIXTURE(${SuiteName}Fixture, ${TestName}) { //Test Code } } </template><template name="tst" enabled="true" description="Basic Test code" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">TEST (${TestName}) { }</template><template name="usc" enabled="true" description="Create using statement for cout and endl;" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">using std::cout; using std::endl;</template><template name="using" enabled="true" description="using a namespace" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true" id="org.eclipse.cdt.ui.text.templates.cpp.using">using namespace ${name}; </template></templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment