Author |
Topic |
|
jayden_shui
New Member
6 Posts |
Posted - Jan 29 2013 : 8:55:56 PM
|
For example
$Type$ m_$name$; const $Type$& $name$() const {return m_$name$;} void set$Name$(const $Type$& $name$) {m_$name$ = $name$;}
In the dialog, only need the user to input $name$. $Name$ can be derived from $name$ with a upper case letter leading. Thanks.
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Jan 30 2013 : 8:53:50 PM
|
So long as you are using a recent build of VA you can already do this. The sample VA Snippet code:
// lower name = m_$name_Lower$ // upper name = m_$name_Upper$ // entered name = m_$name$
shows how to do this. To produce the camel case effect enter "Name" when prompted, since the _Upper and _Lower modifiers make the string entirely upper or lower case. |
zen is the art of being at one with the two'ness |
|
|
jayden_shui
New Member
6 Posts |
Posted - Feb 01 2013 : 08:20:55 AM
|
Thank you. I tried but cannot make it no matter whether I input "name" or "Name". The "_Lower" is entirely lower case, while the "_Upper" is entirely the upper case. How to get camel case?
The feature may be extended by introducing "_Upper_All" "_Upper_First" "_Lower_All" "_Lower_First"
Thanks. |
Edited by - jayden_shui on Feb 01 2013 09:13:23 AM |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 01 2013 : 9:18:01 PM
|
Given my snippet, when prompted, type "Feline" into the dialog, this will then insert the code:
// lower name = m_feline // upper name = m_FELINE // entered name = m_Feline
It turns out two further modifiers have also been added, "_Camel" and "_Pascal", which are designed to help with camel case. "_Camel" upper cases the FIRST letter ONLY, and "_Pascal" lower cases the FIRST letter ONLY. Neither tries to identify word boundaries.
So you could have the snippet:
// lower name = m_$name_Lower$ // upper name = m_$name_Upper$ // camel name = m_$name_Camel$ // pascal name = m_$name_Pascal$ // entered name = m_$name$
which should give you a good range of options. |
zen is the art of being at one with the two'ness |
Edited by - feline on Feb 01 2013 9:18:19 PM |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Feb 01 2013 : 10:47:42 PM
|
Slight correction: Pascal makes first character Upper and camel makes first character lower.
|
|
|
jayden_shui
New Member
6 Posts |
Posted - Feb 02 2013 : 12:48:23 AM
|
Cool! Very convenient feature. |
|
|
chrisaverage
Junior Member
Poland
20 Posts |
Posted - Feb 20 2014 : 08:31:21 AM
|
Hi, I have a sorta related question. I use this convention:
int someSymbol_; inline int someSymbol() const { return someSymbol_; } void setSomeSymbol(int symbol) { someSymbol_ = symbol; }
I can *almost* do this with the snippet except it generates SomeSymbol() instead of someSymbol(). Not a big problem but there's this single letter that I need to fix every time :) Would it be possible to add the _Camel and _Pascal modifiers to the built-in variables like $GeneratedPropertyName$? I tried to use $GeneratedPropertyName_Camel$ but it prompts for an input for GeneratedPropertyName which is of course not what I want. |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 26 2014 : 7:19:41 PM
|
This makes sense, we are considering adding this ability:
case=66480
Unfortunately I don't currently have an estimate for when this will be done. |
zen is the art of being at one with the two'ness |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Feb 26 2014 : 7:50:33 PM
|
Use $generatedPropertyName$
It generates the same property name as $GeneratedPropertyName$ except that first letter is lower-case.
|
|
|
chrisaverage
Junior Member
Poland
20 Posts |
Posted - Feb 27 2014 : 04:34:05 AM
|
Oh, thanks sean! I didn't know about that. |
|
|
|
Topic |
|