Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Flexible upper and lower case in snippet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jayden_shui
New Member

6 Posts

Posted - Jan 29 2013 :  8:55:56 PM  Show Profile  Reply with Quote
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  Show Profile  Reply with Quote
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
Go to Top of Page

jayden_shui
New Member

6 Posts

Posted - Feb 01 2013 :  08:20:55 AM  Show Profile  Reply with Quote
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
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Feb 01 2013 :  9:18:01 PM  Show Profile  Reply with Quote
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
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Feb 01 2013 :  10:47:42 PM  Show Profile  Reply with Quote
Slight correction: Pascal makes first character Upper and camel makes first character lower.
Go to Top of Page

jayden_shui
New Member

6 Posts

Posted - Feb 02 2013 :  12:48:23 AM  Show Profile  Reply with Quote
Cool! Very convenient feature.
Go to Top of Page

chrisaverage
Junior Member

Poland
20 Posts

Posted - Feb 20 2014 :  08:31:21 AM  Show Profile  Reply with Quote
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.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Feb 26 2014 :  7:19:41 PM  Show Profile  Reply with Quote
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
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Feb 26 2014 :  7:50:33 PM  Show Profile  Reply with Quote
Use $generatedPropertyName$

It generates the same property name as $GeneratedPropertyName$ except that first letter is lower-case.
Go to Top of Page

chrisaverage
Junior Member

Poland
20 Posts

Posted - Feb 27 2014 :  04:34:05 AM  Show Profile  Reply with Quote
Oh, thanks sean! I didn't know about that.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000