Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Line Count in my Qt Project.

Line Count in my Qt Project.

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 10 Posters 18.4k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Pradeep P NP Offline
    Pradeep P NP Offline
    Pradeep P N
    wrote on last edited by
    #16

    Thanks All for the help.
    Moving to solved.

    Pradeep Nimbalkar.
    Upvote the answer(s) that helped you to solve the issue...
    Keep code clean.

    1 Reply Last reply
    2
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #17

      find and grep...find and grep

      If you meet the AI on the road, kill it.

      aha_1980A 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        find and grep...find and grep

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #18

        @Kent-Dorfman would you like to elaborate a bit more?

        Qt has to stay free or it will die.

        1 Reply Last reply
        2
        • W Offline
          W Offline
          wrosecrans
          wrote on last edited by
          #19
          find . -iname \*.h -o -iname \*.cpp -exec grep \\\; {} \; | wc -l
          

          Would find all the .h and .cpp find in the current directory, and count the number of lines with a semicolon. For the most things, that's probably a pretty useful count of code LOC, and requires no extra tools to be installed.

          Pradeep P NP 1 Reply Last reply
          1
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #20

            Is this for some kind of line-counting match?

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0
            • W wrosecrans
              find . -iname \*.h -o -iname \*.cpp -exec grep \\\; {} \; | wc -l
              

              Would find all the .h and .cpp find in the current directory, and count the number of lines with a semicolon. For the most things, that's probably a pretty useful count of code LOC, and requires no extra tools to be installed.

              Pradeep P NP Offline
              Pradeep P NP Offline
              Pradeep P N
              wrote on last edited by
              #21

              @wrosecrans
              This don't do the folder search recursive right. ?

              Pradeep Nimbalkar.
              Upvote the answer(s) that helped you to solve the issue...
              Keep code clean.

              aha_1980A 1 Reply Last reply
              1
              • Pradeep P NP Pradeep P N

                @wrosecrans
                This don't do the folder search recursive right. ?

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #22

                @Pradeep-P-N

                I have not tested this code, but find is recursive so it should work.

                Regards

                Qt has to stay free or it will die.

                1 Reply Last reply
                1
                • Kent-DorfmanK Offline
                  Kent-DorfmanK Offline
                  Kent-Dorfman
                  wrote on last edited by Kent-Dorfman
                  #23

                  yes, the default behaviour of find "in unix" is recursive. grep is a pattern matcher. I use

                  find . -type f -iname \*.h -o -iname \*.hpp -o \
                  -iname \*.c -o -iname \*.cc -o -iname \*.cxx \
                  -o -iname \*.cpp | \
                  xargs -n 1 egrep -v "^[ \t]*$" | wc -l
                  

                  prints total of all target file lines (found recursively). ignores blank lines

                  If you meet the AI on the road, kill it.

                  Pradeep P NP 1 Reply Last reply
                  0
                  • Kent-DorfmanK Kent-Dorfman

                    yes, the default behaviour of find "in unix" is recursive. grep is a pattern matcher. I use

                    find . -type f -iname \*.h -o -iname \*.hpp -o \
                    -iname \*.c -o -iname \*.cc -o -iname \*.cxx \
                    -o -iname \*.cpp | \
                    xargs -n 1 egrep -v "^[ \t]*$" | wc -l
                    

                    prints total of all target file lines (found recursively). ignores blank lines

                    Pradeep P NP Offline
                    Pradeep P NP Offline
                    Pradeep P N
                    wrote on last edited by
                    #24

                    Hi @Kent-Dorfman
                    Cool, Linux commands are always awesome.
                    I just Added *.qml to the command so i can include qml also for the line count.

                    find . -type f -iname \*.h -o -iname \*.hpp -o -iname \*.qml -o \
                    -iname \*.c -o -iname \*.cc -o -iname \*.cxx \
                    -o -iname \*.cpp | \
                    xargs -n 1 egrep -v "^[ \t]*$" | wc -l
                    

                    Thanks a lot again
                    @mrjj @Eddy @jsulm @J-Hilk @Kent-Dorfman @aha_1980 @wrosecrans .

                    Have a great day.

                    Pradeep Nimbalkar.
                    Upvote the answer(s) that helped you to solve the issue...
                    Keep code clean.

                    1 Reply Last reply
                    5
                    • D Offline
                      D Offline
                      Dr. Abel
                      wrote on last edited by
                      #25

                      This tool will help you.
                      cloc-1.74.

                      It is collected in PyMake project.
                      github https://github.com/AbelTian/PyMake.git (fetch)
                      github https://github.com/AbelTian/PyMake.git (push)
                      origin https://gitee.com/drabel/PyMake (fetch)
                      origin https://gitee.com/drabel/PyMake (push)

                      In demo/ dir.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved