Visual C++: automatic include refactoring when moving/renaming files - c++

I just moved from CodeBlocks to Visual Studio 2013, and this is my first time using VS2013. My CodeBlocks project used virtual folders for structure, while keeping all the "physical" files in the same directory (I know, I know...) So I just spent an incredibly tedious 45 minutes replicating that structure with actual folders, creating folders and moving files around. The worst part was that, for each and every header file, I had to run a search-and-replace command like the following to update its path: #include "ObjectPtrArray.h" => #include "Structures/ObjectPtrArray.h"
This is a fairly large project (120+ source files), and I'm going to be doing much, much more refactoring over the coming days. A lot of that will include renaming classes, splitting them, creating new folders, moving files from folder to folder, and such. So is there any way I can automate this process? i.e. if I have a header file Tiles/SceneMap.h and I move it to Graphics/Tiles/SceneMap.h, can Visual Studio (or an extension for it) automatically update all of the includes that reference this file, without me having to run search-and-replace manually?
I do have ReSharper, but when I right click on a file the Refactor menu is blank. Is there another extension that I can use which would do this (preferably not conflicting with ReSharper?)
Thanks for your time!

Related

Visual Studio 2012 filters?

I just decided to learn C++ and I installed Visual Studio 2012. My friend told me it's a monstrous program and I should avoid it, but it has one of the best compiler ever (advanced error messages, etc.) and i found it useful in studying.
The problem is there are option called Filter except for real Folders. Source code is organized in IDE but the project folder is just messy, everything is in the root.
I think it's good for the compiler - you can't be wrong while including files. But since u want to share your source files with your friends who don't use VS it's necessary to have files organized in folders.
Is there any option to export files into folders based on filers?

Is it possible to export a project directly from visual Studio into it's own folder?

I am currently trying to build .net bindings for a very large project that is written in C an C++. The project was recently ported over to Windows, and I might add that is is a big giant mess.
The solution has about 12 projects, which is fine but the directory itself has alot more files than needed,since it includes OS specific source files, demo projects etc.
Also the other thing is the headers and source files are scattered all over the place. I am working on a parser to help me create the bindings for this project, but I am having a heck of a time. Especially when the internal include references are completely off.
The developer did a great job porting this large project to Windows, but isn't very organized and it is driving me bonkers with the issue my parser is having. So the easiest thing to do would be to re structure and put each project in it's own areas.
So as I asked in the title, is there somewhere that I can export each project and it's files from VS 2010(or another tool) so I can begin restructuring the folders? When I have ever needed to do this before in .net it was easy enough to just move the files. In smaller c++ projects I just open up the project file in notepad++ and move each file in the include/source list into different directories and changed the paths in the project file after. The issue with that is it will take way too long, and I have already spent days messing with this project, finding the best way to wrap it, and creating my helper tools.
Can anyone give me some assistance in this aspect?
EDIT:Just to clarify, I would like to export each project into it's own root folder with one folder for headers and one for source files so I can keep things simple.
I'm not sure about a tool for this, but the .vcxproj project files are in XML format, so you can easily extract a list of files from each project. Then you could relocate those files and write their new location back into the project.
Whenever I encounter a serious project mess, I usually end up dragging all the project files into Notepad++ and start doing global search and replace.
I haven't done it on the scale that you seem to be aiming at, where it involves relocating all the sources. You could be in for a rough ride. Fixing up include paths etc could be quite a pain.
I suggest you obtain the file lists (relative paths or whatever) in a simple text format, and then decide whether you want to take the red pill or the blue pill =)

Redeveloping MFC application

I've got a program written in c++ and have to make some modifications to it. Howerver, I haven't got any solution file or a like, just a bunch of .h, .cpp, .obj, .dpb, .dll, .mdi, .dfm, .res, .tds, .bpl files and an .exe file.
So I can start an application, see what it's doing and what the controls are, but when it comes to adding changes trying do to map behaviour of UI to source code files seems just to tedious.
Is it possible to recreate some kind of solution file or just to simply the process? (I am using VS 2012 and an app was written in 2002).
These file extensions indicate the source is from a Borland IDE. That .mdi file I think signifies Borland's multiple-document-interface... I'll venture to guess this project would be quite difficult to "recompile" using Visual Studio. I don't even see a .rc (resource file) in your list. Rewriting may be the easiest path, depending on the complexity of the application...

Qt Creator Code File Refactoring

I was wondering if anyone know of a quick and easy way to refactor the code files in my QT Project using QTCreator? Specifically I am trying to organize my source files and Its a bit of a pain to have to go back into the project file and change the filepath for each file. Not to mention moving a dialog class is even worse (there are .ui files not included in the project but you have to change those too.
The only file renaming/moving support that is "integrated" (i.e. it updates your project file automatically) is using the active project pane with your file list, rightclick and select "rename", using "../../some/new/dir/name.cpp" to move your files. It will of course not update any #include statements, but will save you the trouble of modifying your .pro file manually. It also respects "git rename" etc...
I don't think thats possible, moving files without ide support is a pain in the... :/

Using Tortoise SVN with C++ in Visual Studio 2008

I have an online repository with some .h and .cpp files that make up part of a project. I'm trying to check these out and use them in a new project, but am getting errors (C4627 and C1010). All the files have been added to the project (with Add>Existing Item...), and the subdirectories that contain these files have been added to the "Additional include directories" of the project.
Would I be better off having the entire project tree in the repository? My reason for not doing so is that my colleague and I are working on different parts of the code and so want to use different main methods to test things as we go, and I didn't see any need to be passing around any compiled code etc. since I assumed that given the .h and .cpp files (with the correct settings), visual studio would be able to compile the project.
What's the best way to make Visual Studio 2008 and TortoiseSVN work well together (without spending any money)?
Would I be better off having the entire project tree in the repository?
Most certainly yes. You should be able to check out and build without much effort. Creating a new project every time you want to build the source and having to configure it is way too much work.
My reason for not doing so is that my colleague and I are working on different parts of the code and so want to use different main methods to test things as we go, and I didn't see any need to be passing around any compiled code etc.
Ok, just put more than one project in the solution. There's no reason you can't have separate executable projects for separate tests.
I assumed that given the .h and .cpp files (with the correct settings), visual studio would be able to compile the project.
If all of the settings are the same, then, yes, it should compile fine, but why bother with the hassle when you don't have to?
Also AnkhSVN which isn't too bad and it's free. Also, lots of the windows it displays look like TFS (if you're familiar with it)
What's the best way to make Visual Studio 2008 and TortoiseSVN work well together (without spending any money)?
There are a bunch of programs that integrate SVN into Visual Studio. VisualSVN is one of them.
Apologies for the VisualSVN recommendation. We used to use it in an old project and I'm positive it was free then. Maybe they changed their license?