Warning, /frameworks/ktexteditor/src/script/data/indentation/cppstyle.README.md is written in an unsupported language. File is not indexed.
0001 C++/boost Style Indenter 0002 ======================== 0003 0004 This indenter (initially) was designed to help code typing in a boost::mpl style 0005 (i.e. w/ leading comma in formatted parameters list). One may read rationale of such 0006 approach in the "C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond" 0007 by David Abrahams and Aleksey Gurtovoy. It is really easy to miss a comma when "calling" templates and 0008 it would leads to really complicated compile errors. This technique helps to visually control syntax 0009 in a stricter way. 0010 0011 Example: 0012 0013 typedef typename boost::mpl::eval_if< 0014 boost::is_same<iter, boost::mpl::end<types_map>::type> 0015 , boost::mpl::int_<-1> 0016 , boost::mpl::distance<boost::mpl::begin<types_map>::type, iter> 0017 >::type type; 0018 0019 In practice I've noticed that this style can be used to format long function calls or even 0020 `for` statements. Actually everything that can be split into several lines could be formatted that way. 0021 And yes, it is convenient to have a delimiter (comma, semicolon, whatever) as leading character to 0022 make it visually noticeable. 0023 0024 // Inheritance list formatting 0025 struct sample 0026 : public base_1 0027 , public base_2 0028 , ... 0029 , public base_N 0030 { 0031 // Parameter list formatting 0032 void foo( 0033 const std::string& param_1 ///< A string parameter 0034 , double param_2 ///< A double parameter 0035 , ... 0036 , const some_type& param_N ///< An user defined type parameter 0037 ) 0038 { 0039 // 0040 for ( 0041 auto first = std::begin(param_1) 0042 , last = std::end(param_1) 0043 ; it != last 0044 ; ++it 0045 ) 0046 { 0047 auto val = check_some_condition() 0048 ? get_then_value() 0049 : get_else_value() 0050 ; 0051 } 0052 } 0053 }; 0054 0055 It looks unusual for awhile :) but later it become "normal" and easily to read and edit :) 0056 Really! When you want to add one more parameter to a function declaration or change order it will 0057 takes less typing comparing to "traditional" way :) (especially if you have some help from editor, 0058 like moving current line or selected block up/down by hotkey or having indenter like this :) 0059 0060 Features 0061 -------- 0062 0063 * support for boost-like formatting style everywhere is possible 0064 * align inline comments to 60th position after typing `'//'` 0065 * turn `'///'` into `'/// '` or `'///< '` depending on comment placement 0066 * take care of inline comments when `ENTER` pressed on a commented line (before, middle or after comment start) 0067 * turn `'/*'` or `'/**'` into multiline (doxygen style) comment 0068 * auto continue multiline comment on `ENTER` 0069 * indent preprocessor directives according nesting level of `#if`/`#endif` 0070 * take care about backslashes alignment in preprocessor macro definitions 0071 * append a space after comma or some keywords (like `if`, `for`, `while`, etc...) or `operator<<` 0072 * align access modifiers 0073 0074 0075 TODO 0076 ---- 0077 0078 Initially it was designed as typing helper and nowadays it lacks of align functionality (it's capable to 0079 align only few basic constructs). But I have plans to add some logic here to better align source code keeping 0080 C++/boost style in mind.