I'm looking for a line counting tool like Project Line Counter by Oz Solomon: Project Line Counter. This add-in worked perfectly for me with VS 2005 and 2008. But, unfortunately, Oz has no time to develop it further or to adapt it to VS 2010.
Do you know some great line counting tool for C++ code that perferably (but not necessarily) meets the following requirements:
distinguish between commented lines, blank lines, code only lines etc.
possibility to restrict to certain files/folders (or even VS projects)
list file names
no cost
integrable in VS 2010
Thanks in advance,
Flinsch.
Source Monitor is not integrated with VS2010, but it gives a very detailed source code metric reports:
I'm using Project Line Counter in Visual Studio 2010 SP1 on Windows 7 64-bit. (It also works without SP1.) You need PLC 221 http://www.wndtabs.com/downloads/PLC221.zip plus a modified registry file you can get from my website: http://www.onemanmmo.com/index.php?cmd=newsitem&comment=news.1.41.0
I know this doesn't meet all of your requirements but I like cloc. It's a simple to use command line tool. Example use / output...
C:\src>cloc --no3 gstreamer
9021 text files.
6495 unique files.
26138 files ignored.
http://cloc.sourceforge.net v 1.09 T=258.0 s (16.7 files/s, 5527.7 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
C 1633 142010 131712 617327
C/C++ Header 1588 50625 75916 216335
Bourne Shell 52 6830 6060 43742
C++ 73 3937 3928 29514
XML 262 1500 1117 26552
m4 117 3209 2064 23008
make 456 2335 950 8661
HTML 37 92 8 6695
Python 14 1437 934 4446
Teamcenter def 27 30 0 3141
Perl 6 396 251 2338
yacc 2 257 114 2021
Assembly 16 312 356 1782
Objective C 5 277 159 1001
XSLT 10 134 42 853
Lisp 4 91 119 393
IDL 2 40 0 353
lex 2 41 11 190
CSS 2 9 1 153
Bourne Again Shell 4 37 50 146
Tcl/Tk 1 10 27 46
sed 2 0 0 16
D 1 0 0 15
--------------------------------------------------------------------------------
SUM: 4316 213609 223819 988728
--------------------------------------------------------------------------------
This is a project based on Project Line Counter by Oz Solomon, and it improves it in some regards but the line-counting algorithms seems to be the same:
http://www.codeproject.com/KB/macros/LineCounterAddin.aspx
It has an update for VS 2010 made by it's users (see the comments):
http://shiz.wussie.nl/LineCounterAddIn2010.zip
"Kloc" can be used to calculate lines of code. Its a independent tool it cannot be integrated with VS. All you have to do is specify the files and folders and it will calculate the loc for u.
Maybe you can use the integrated macro __LINE__, that returns a current line in code to see how VS makes line counting.
Related
WYS*WYGWYS*WYSWYSG
When compressed above string using LZW algorithm it gave an output codes as below.
87 89 83 42 256 71 256 258 262 262 71
So you can see size of output codes bigger than that of the string.now I need to know How should I store it in a file?
Thank you.
I'm looking for some information about how to write from a file to a link list
Let's say that I have a file.txt that look like this:
Jen Red
12 25
14 18
58 19
0 0
Marie Blue
25 56
0 0
Nancy Purple
556 621
111 2
1 141
114 2
0 0
I would like to write this into a linked List
We first start to write the name and color. After that we need to input some data but each person have different numbers of input. We terminated the link list by 0 0 and we repeated the process for a different person.
Where can a look for more infos about this ?
I would like to write this into a linked list
How? Is each person its own node, or is each person its own linked list?
What exactly are you trying to do with the information? How you plan to process the information can affect which data structure best fits your app.
We terminated the link list by 0 0 and we repeated the process for a different person.
That's just a while loop.
Where can a look for more infos about this ?
Here is documentation on std::list. Here's a specific kind of list, std::queue.
I want to write some data on an already existing file. It is a file that contains about 8-10 lines of header(# comments) and then thousands of lines of data values. What i want is to keep the header same but add the updated data values to the file. It is quite possible that after the update I have less number of lines of data values.
So basically i want to erase everything after the last # comment in the header and then start writing the new values from there onwards. Is that possible?
Here is an example:
Original File
#Program
#Date
#Hello
0 23 23 54
1 12 4 2
2 253 786 9887
3 3 23 54
4 1 4 4
5 23 6 81
Updated File
#Program
#Date
#Hello
0 2 23 54
2 253 786 9887
5 23 6 81
The code i am editing is using fopen to read the file and fprintf to write to it. I would prefer if the answers are along these lines so that i don't have to change those two.
The simplest way I came up with is open the Original File, read and copy the header in to memory such as a string header. Then overwrite the whole file by writing the header, then the new data
Write a function that reads the headers from the file and store them into a class/variable/struct.
Write a function that writes the headers to the file
Write a function that writes the desired values to the file
Execute all three functions in that order. The fact that it is the same file that you overwrite is irrelevant, just be sure to close it before writing back to it
How can i test a c++ program with given input test cases?
For example an input like this
23 45 78 45 12 67 23 76 56 34
34 65 78 45 74 3 98 34 23 97
I want to be able to input these numbers from a text file into a program at run-time and test expected output. I cannot input thousands of numbers by hand in a console so are there any softwares that allow these kind of testing?
This is already being used in InterviewStreet, they use given test cases and match the expected output to test a program.
--Edit--
Is there any way i can pass values from a text file into stdin ?
You could write a little bash script to run all of your tests. An individual test would look something like this:
#!/bin/bash
testprog < input1.txt > output1.txt
diff expected_output1.txt output1.txt
# examine the return code of diff to see if the files are different?
How can I extract unique numbers from a long list of numbers (arranged linewise). I need a regular expression to do that.
I am using a log program called baretailpro which enables searching through a log data and display per regex.
Example Input:
123
321
123
432
343
343
432
811
932
432
...list extends upto n number linewise
Example Output:
123
321
432
343
811
932
...list extends upto n numbers linewise
Rgds,
Anita
If it really has to be a regex, and if baretailpro supports lookahead regexes, then you can search for
^(\d+)$\r?\n?(?=.*^\1$)
and replace all with nothing (empty string). You need to set the option for the dot to match all characters including newlines; if you don't have that option, use ^(\d+)$\r?\n?(?=[\s\S]*^\1$) instead.
The problem with this is that this regex will remove all the occurences of duplicate numbers except the last one. If you want to keep the first one, your regex engine must support lookbehind and also infinite repetition inside lookbehind. Hardly any regex engine does besides .NET and JGSoft. But if you can use it, then this one will be better:
(?<=^\1$.*)^(\d+)$\r?\n?
normally, you don't use regex to find unique items. you use tools like uniq (in *nix/windows) or sort -u to find unique strings. Or you can use a programming language with arrays/dictionary/hashes support, eg Perl/Python. If its possible for baretail log analyser to output data to a plain text/csv file, you can then use these tools to get your unique strings.
example assuming you exported your data to text file
$ cat file
123
321
123
432
343
343
432
811
932
432
$ sort -u file
123
321
343
432
811
932
I am on windows and not having Excel or Db software so, I did it like this:
Installed unxUtil port for Win32 (3.6MB or download and use only ones you want)
pasted the file containing linewise nos to the folder contain utils i.e. wbin
Used instructions on www.ibm.com/developerworks/linux/library/l-tiptex6.html
Or
The ones specified by Mr. ghostdog74 above.
NB: On windows used commands as forwarding output to text/output file.(as redirect to file)
eg: > result.txt
And its all done.
File is sorted
rgds,
Sunita
[anita's jumbo colleague]