Search up include hierarcy - c

Is there an easy way to do a text search on a c file that goes up the include tree (including files in the include search locations)? Preferably in eclipse.

check for ctags, Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility.
http://en.wikipedia.org/wiki/Ctags
http://ctags.sourceforge.net/

Related

How would I store different types of data in one file

I need to store data in a file in this format
word, audio, jpeg
How would I store that all in one file? Is it even possible do would I need to store links to other data files in place of the audio and jpeg. Would I need a custom file format?
1. Your own filetype
As mentioned by #Ken White you would need to be creating your own custom file format for this sort of thing, which would then mean creating your own parser type. This could be achieved in almost any language you wanted but since you are planning on using word format, then maybe C# would be best for you. However, this technique could be quite complicated and take a relatively large amount of time to thoroughly test your file compresser / decompressor, but may be best depending on your needs.
2. Command line utilities
Another way to go about this would be to use a bash script to combine all of the files into one file, and then decompress it at the other end. For example the steps could involve:
Combine files using windows copy / linux cat command on command line
Create a metdata file of your own that says how many files are in this custom file, and how much memory each one takes up (could be a short XML or JSON file for example...)
Use the linux split command or install a Windows command line file splitter program (here's just one example) to split the file back into whatever components have made it up.
This way you only have to create a really small file type, and let the OS utilities handle the combining of them for you.
Example on Windows:
Copy all of the files in your current directory into one output file called 'file.custom'
copy /b * file.custom
Generate custom file format describing metadata (i.e. get the file size on disk in C# example here). This is just maybe what I would do in JSON. SO formatting was being annoying so here's a link (Copy paste it into an editor or online JSON viewer).
Use a decompress windows / linux command line tool to decompress each files to the exact length (and export it back to the exact name) specified in the JSON (metadata) file. (More info on splitting files on this post).
3. ZIP files
You could always store all of the files in a compressed zip file, and then just use a zip compressor, expander as and when you like to retreive any number of file formats stored within.
I found a couple of examples of :
Combining multiple files into one ZIP file in only C# .net,
Unzipping ZIP files in C#
Zipping & Unzipping with only windows built-in utilities
Zipping & Unzipping in Linux command line
Good Zipping/Unzipping library in Java
Zipping/Unzipping in Python

Visualizing A Directory's File Structure and File Contents

I am interested in creating a tool that can be run from the command line (pref. linux) and which will scour a select group of files (think .gitignore in reverse), parse those files, and create an image that looks like this Conceptboard. It doesn't need to look exactly like that, but I should be able to control graphical effects and layout of the boxed elements. Each boxed element should simply have the file name up top, and the contents of the file below.
My questions are:
What tools are available for this type of project?
Where would I logically start?
How long should I expect this to take me?
edit: graphviz could definitely work, but is it able to show file contents?
Graphviz can't directly show file contents, but I've often coupled it with code in java or python to build the appropriate .dot file, then run graphviz on that .dot file to produce the final graphic, something like this pseudocode:
open .dot text file and add graphviz header information
for each file in directory:
save filename for future reference
read and save file contents
create node in .dot file formatted with filename at top and contents below
for each file in directory:
parse file to locate links to other files
if filename has been processed above, add a link line to .dot output file
add graphviz footer to .dot file
run DOT on .dot file
the final .dot file would look something like this, only much longer:
digraph fileStructure {
node [shape=box, color=black, fontsize=14, fillcolor=white, style=filled]
1 [label="filename\nfile contents"]
2 [label="filename\nfile contents"]
3 [label="filename\nfile contents"]
1 -> 2
1 -> 3
}
There are libraries for most major programming language to simplify the process of creating .dot files and running graphviz, but it's not too hard to do directly.
How long it would take depends on your skill level, but I wouldn't think this would take more than a few hours to complete.

Is there a quick file open/find like IntelliJ's find file, or Sublime's? Something with fuzzy search. But in Emacs?

I'm looking for something that's a bit robust in how it finds files in Emacs. I have a project made up a number of different files, and a lot of them. So, I think maybe Emacs would need to cache a lookup or something like that to make a quick find/open facility to work. It would need to also be configured per project to consider only some directories and exclude others inside of this project, since a number of files and directories are generated and hold a massive amount of text and sometimes a concatenated representation of the rest of the code.
Is there a quick file open/find like IntelliJ's find file, or Sublime's? Something with fuzzy search. But in Emacs? That could help with this problem?
Projectile can probably do what you're after. It describes itself as a "project interaction library" with facilities for finding project files quickly.
Try projectile: https://github.com/bbatsov/projectile (see its fancy UI, helm-projectile). You'll have the command projectile-find-file. It is based on projects (they are defined by a .git/.gh/… or a .projectile).
permanent caching ? Yes
filter out directories ? Yes (with a command or a config into the .projectile)
fuzzy search ? Yes, a few: emacs'default, ido, ido-fuzzy, grizzl or helm.
you install it simply with M-x package-install RET projectile RET.
See this EmacsWiki page, which is is a jumping-off place for multiple answers to your question.
Emacs has a built-in file-name cache -- see (emacs) File Name Cache and this page.
See also Emacs bookmarks, and in particular, Bookmark+. You can bookmark any file or set of files. You can bookmark a Dired buffer, including its omit set, markings, and included subdirs. You can bookmark a set of such Dired buffers. You can aggregate bookmarks and use them to perform actions that set up environments etc. They can be triggered in various ways. You can bookmark Emacs desktops. You can tag bookmarks and files & dirs with free-form tags, which lets you organize them flexibly into overlapping sets.
See also this page about project support with Icicles.

Remove link to source code in doxygen?

I want my doxygen output to show only documentation, without showing any raw source code. I know that it is possible to hide the file browsing tab so that the user can only browse by namespace/class, and that this effectively hides source.
However, I have lots of functions in a top level namespace that are organized by file only, so I do want to maintain the capability to browse by filename. I just want to remove the link inside a file doc that says "Go to the source code of this file." Is there any way to remove this link?
Of course, I could write a script that analyzed all output HTML files and deletes any file ending in _source.html and also removes lines of this sort from remaining HTML:
<p>Go to the source code of this file.</p>
However I was hoping there would be a cleaner way to do this.
In your configuration file, set the following options:
SOURCE_BROWSER = NO
VERBATIM_HEADERS = NO
This still lists the namespaces in each file, but does not include the source code.

How to achieve symbol referencing across directories in vim?

Can ctags tag symbols from a directory up in the hierarchy also or is it limited to create tags for current and sub-directories only?
Basically I'm looking for Visual Studio like symbol cross referencing it is very helpful in understanding alien source code flow.
If not Vim, then which other editor should I use?
thanks
Ctags only recurses to subdirectories. But all you have to do is run ctags -R . in your project home directory, and it will create a tags file for your whole project.
You aren't limited to specifying one tags file in Vim. This is an alternative to the other answers; you can just do something like:
set tags=tags,~/wintags,c:/path/to/moretags/etc
So you don't need to take the time regenerating a monolithic tags file when you just want to update your local tags.
Regarding the OP's comment in another answer,
yes thats correct but when i open a file say proj/dir1/def.c and press ctrl+] on a function name which is defined say in proj/dir2/abc.c, I get tag not found :(
You could also create one tags file for all of your projects at the 'proj' root:
set tags=tags;c:/path/to/proj
This will use the first file named tags that it finds as it walks up the directory hierarchy from where you are.
You can combine these two techniques to have a project-local tags file and then a "global" tags file that isn't updated as often.
Whilst it's got similar user interface for asking it to do it's thing, so you need to actually specify "go down directories", I find that cscope is a very nice tool, whcih does everything that ctags does and a bit more.
ctags (well, exctags at least) can create tags for as many directory trees you want. Simply run
exctags -R dir1 dir2 ...
Then vim knows about all the symbols you need. For example, one of the directories could be /usr/include in addition to your own source directory.
Make sure to run vim path/to/file.c from the same directory you created the tags file in.

Resources