T O P I C R E V I E W |
Rain Dog |
Posted - Feb 15 2009 : 10:11:45 PM For supported containers such as STL containers and arrays, it would be nice if you could have a container:
std::set<std::string> foo;
Select "foo" and choose "iterate over container" and it would generate the following code:
for(std::set<std::string>::const_iterator i = foo.begin();
i!= foo.end(); ++i)
{
}
This is superior to using code templates because templates do not know the type of container and therefore would require typing of the iterator type. |
11 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - May 07 2010 : 3:04:01 PM Unfortunately no progress to report on this so far, but it is down as a high priority feature request. We have been spending a lot of time recently focussing on supporting VS2010. |
jamiecook |
Posted - May 05 2010 : 08:50:51 AM BUMP
Does this feature have an approximate completion date? |
feline |
Posted - Feb 21 2009 : 11:29:41 AM This does sound useful overall I have put in a feature request for a new token / reserved word in VA Snippets:
case=24243 |
Rain Dog |
Posted - Feb 21 2009 : 02:01:45 AM quote: Originally posted by feline
re-reading this, to fix the problem with overwriting the original code, just change the snippet to read:
$selected$; for($SymbolType$::const_iterator i = $selected$.begin(); i!= $selected$.end(); ++i) { }
or type the variable on a new line, using a suggestion listbox to enter it quickly and easily, then trigger the original snippet on it, replacing the variable with the loop.
That looks like a good solution.
It would be able to help also in the typedef thread as the user could then write snippets that would declare multiple typedefs for them for say const/non-const iterators |
feline |
Posted - Feb 20 2009 : 5:42:59 PM boost::FOREACH I have never heard of, so never used. I did use Qt 3 for quite a while at my old job, and some of its containers required a custom syntax to iterate across them *sigh*. Still it sounds useful.
Replacing the selected code is probably the biggest concern here. I am not sure about $NextStatement$ and $PrevStatement$, I am wondering if this really helps, or if simply typing the variable name, and then replacing it with something else, via a VA Snippet is good enough. |
accord |
Posted - Feb 20 2009 : 4:25:24 PM One side effect of this solution is that you get an extra semicolon: (after '}')
std::set<std::string> foo;
for(std::set<std::string>::const_iterator i = foo.begin(); i!= foo.end(); ++i)
{
};
A possible solution can be to introduce a $NextStatement$ and $PrevStatement$. It would jump to the next statement and would continue processing and inserting the snippet from here. I know it would require addition work, but would enable other "refactorings".
About extract typedef:
Consider the code:
static void testGeneralCode() { std::vector<int> foo; }
select foo, and use this snippet:
typedef $SymbolType$ $type_name$; $type_name$ $selected$
And you end up with:
static void testGeneralCode() { typedef std::vector<int> TypeVectorInt; TypeVectorInt foo; }
This is almost the same as your example here:
http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=7954
The only little difference is that it may be easier to use this, since you can select foo by double click. |
lance |
Posted - Feb 20 2009 : 11:55:17 AM Personally I use boost::FOREACH. It's great, copes with most types, and does dereference from iterator to contained type for you.
|
feline |
Posted - Feb 20 2009 : 11:53:29 AM re-reading this, to fix the problem with overwriting the original code, just change the snippet to read:
$selected$; for($SymbolType$::const_iterator i = $selected$.begin(); i!= $selected$.end(); ++i) { }
or type the variable on a new line, using a suggestion listbox to enter it quickly and easily, then trigger the original snippet on it, replacing the variable with the loop. |
feline |
Posted - Feb 20 2009 : 11:49:52 AM This is what I am thinking, starting with the code line:
std::set<std::string> foo;
select "foo", and then trigger a VA Snippet that looks line:
for($SymbolType$::const_iterator i = $selected$.begin(); i!= $selected$.end(); ++i) { }
where $SymbolType$ is a new VA Snippet token.
Personally I really like this, and it sounds like it could be really useful. I have not thought about the extract typedef thread yet, do you think this would help there as well?
Are there any obvious problems here? For a local variable or class member variable working out the type should be quite reliable.
This will allow you to trigger this snippet for a variable of type "int", which will be silly, but I don't think that is a real problem. |
accord |
Posted - Feb 19 2009 : 6:03:56 PM Personally I love this idea. I have thought about this idea myself, but the question is that where to put the result? Simply overwriting "foo" is not enough here. Or are we talking about different things?
This would help also to create extract typedef: http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=8528 |
feline |
Posted - Feb 17 2009 : 10:49:19 AM If there was a reserved word / token in VA Snippets for "symbol type" then you would simply be able to write your own VA Snippet to do this, plus any other standard actions.
I am just wondering if this is a better solution or not. I think it probably would be. You could also write Snippets for container types that VA does not know about.
Would this do what you want? |