If I want to call a function/method in C++ my normal way is to type the first letters of the name and investigate the IntelliSense suggestions. If I choose one, the name will be inserted, but it would be great if also the parenthesis could be inserted. Of course the caret should be placed in the middle of the new parenthesis. I am using Visual Studio 2015 and ReSharper. Is there a setting in VS or R# about this?
eg
std::string s;
s.em
the result after the use of IntelliSense should be
std::string s;
s.empty(_CARET_);
I don't think that having the cursor between parentheses for empty function makes sense since empty one has no parameters. But at the same time, having the cursor between parentheses for any function which has parameters is definitely handy. So, ReSharper C++ provides exactly this:
in case a function has no parameters
type s.e;
hit Tab to complete empty from the completion popup;
as a result, you will get s.empty()_cursor_ and you can continue typing whatever you like after closing parenthesis.
in case a function has parameters (e.g. append)
type s.a;
hit Tab to complete append from the completion popup;
as a result, you will get s.append(_cursor_) and you can specify parameters.
Well, as you may see, ReSharper C++ locates the cursor depending on a function's signature.
In VS2017 you can do the following to achieve the desired result:
s
.
e
Shift+(
Related
I try to find method(function) declerations on which 6th argument is true. Actually I think I can return ,just using regex, wished group without using an extra programming language's feature, unfortunately no option exits as such.
sdfsdfs(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff);
sdfsdfs(123,234,true,23324,234324,true,dwfwefwer);
sdfsdfs(123,234,234234,23324,234324,r23423,dwfwefwer);
sdfsdfs(123,234,234234,23324,234324,false,dwfwefwer);
(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff)
erterterterter(123,234,werer,23324,234324,true,dwfwefwer,sdfdsdff);
What I have tried is here. (\b\w+(?=\s*[,()]))
You can check the following regex.
(?i)\w*\([^,]+,[^,]+,[^,]+,[^,]+,[^,]+,true\b,[^\)]+\)
I have done here https://regex101.com/r/BEJNp4/1/
What is this weird syntax you can use the the watch window (or even to set breakpoints) and where can I find it documented:
{,,test2.exe}<variable name>
When starting the program, the first will translate to my entry point and will break on execution start.
Intuitively I can see what this means, but where is it documented and what are the leading commas for (what stuff can you put in there)?
Why does using the syntax in the watch window help?
As the VS2015 documentation states, that is called a Context Operator, valid only for C++ native applications.
You could put function and source file before the first and the second comma.
For VS2010 and previous versions the documentation is slightly different and more verbose.
I'm trying to find using visual studio regular expressions (https://msdn.microsoft.com/en-us/library/2k3te2cs.aspx) all calls to Assert.IsTrue that only pass the Boolean argument, for example Assert.IsTrue(parameter) would be one and Assert.IsTrue(parameter, "message") wouldn'
t.
For simple things, Assert.IsTrue\(([a-zA-Z ]+)\) does the trick, this works for the example provided above but not for things when there are evaluations done for example Assert.IsTrue(2 > 3). For this I tried using Assert.IsTrue\((.+[^,])\) so it matches everything that doesn't have "," but this only filters when the , is at the end, I'm not sure how to filter commas inside.
Finally, what I really want to do (which I'm not sure if it's possible with regular expressions alone) is to find Assert.IsTrue that have only one parameter but this parameter could be a method call, so it could have commas or not, something like Assert.IsTrue(isTrue(p1,p2))
I don't know why you want the solution to be programmatically, but if it's ok for you to have a Visual Studio based solution, you could just look for an example of Assert.IsTrue(parameter);, right click the method and select "Find all references`.
Remove the .+ from your second example and add a * also you should escape the period directly after Assert.
Assert\.IsTrue\(([^,])*\)
As for your expanded expression, something like this might work.
Assert\.IsTrue\(([a-zA-Z\.])*\(.*\)\)
This should let you find what you're looking for.
I have to show/enable a bunch of dialog items in an MFC application. They all have names like IDC_EDIT_CHANNEL1_x, where x is an int value from 0 to 15. The IDs from the resource file are not ordered so I want to get the items by that string.
Is it possible to get the resourceId named IDC_EDIT_CHANNEL1_1, from a string "IDC_EDIT_CHANNEL1_1"?
As you all know GetDlgItem() only works with int values.
The problem you don't see is that the preprocessor replaces IDC_EDIT_CHANNEL1_x with an integer at compile time. This is a macro, not a string.
So your application never "sees" a string. The string has been substituted by the preprocessor before the source code reaches the compiler.
My advice is to use consecutive IDs. I don't know why you don't want to do that, but it will probably be the quickest and most straightforward way to solve your problem.
The other way is to not use macros at all. The resource editor can use strings, and if the preprocessor doesn't replace them with ints, that's what will be used. You can filter them by string then.
I'm writing a (Win32 Console) program that wraps another process; it takes parameters as in the following example:
runas.exe user notepad foo.txt
That is: runas parses user and then will run notepad, passing the remaining parameters.
My problem is that argv is broken down into individual parameters, but CreateProcessAsUser requires a single lpszCommandLine parameter.
Building this command line is probably not as simple as just joining argv back together with spaces. Any pointers?
This is just an example. My first argument isn't actually a user name, and might have spaces in it. This makes manually parsing the result of GetCommandLine tricky.
Similarly, a naive concatenation of argv won't work, because it needs to deal with the case where the original arguments were quoted and might have spaces in them.
Manually recombining them is hard:
You could try to re-combine them, I think it would work, but be sure to following the same command line escaping rules that windows has. This could be more than the trivial solution you're looking for.
Also if there are any parameters that have spaces in them, then you would want to join them to the string with quotes around them. Here is an example of a strange escaping rule: if you have --folderpath "c:\test\" then the last backslash has to be doubled --folderpath "c:\test\\".
If you are using MFC:
You can can get the value you want from your derived CWinApp's theApp.m_lpCmdLine. Note you could still access them the other way too with __argc, and __argv or CommandLineToArgvW.
If you are using Win32 only (even without a GUI):
You can get it from WinMain. Which can be your program's entry point.
Note you could still access them the other way too with __argc, and __argv or CommandLineToArgvW.
If you must use a console based application with main or wmain:
The Win32 API GetCommandLine seems to be the way to go. You would need to still parse this to get past the .exe name though. Take into account quotes around the exe name/path too. If there are no such quotes at the start, then just go to the next space for the start.
You can use the GetCommandLine function.
Why not use 'WinMain' instead of 'main'? This should give you the string in the format you want.
There is Win32 API call that returns command line: GetCommandLine
Provided you have a string allocated with enough space then use strcat on each item in the list. Yes, it is as simple as joining them back together with spaces.
Edit: Of course, you would need to enclose any items containing spaces within quotes.