Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Header file Formating.

Header file Formating.

Scheduled Pinned Locked Moved The Lounge
question
21 Posts 10 Posters 0 Views 1 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.
  • C Chris Maunder

    The alignment or the massive whitespace? I am very, very strict about aligning code because it allows you to scan types, modifiers and names and reduces the chance of a scanning drive-by error. A little bit of effort that has saved me enough times to make it gospel.

    cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

    P Offline
    P Offline
    Prakash Nadar
    wrote on last edited by
    #4

    Chris Maunder wrote:

    The alignment or the massive whitespace?

    too many whitespaceing. Some alignment is fine.

    1 Reply Last reply
    0
    • P Prakash Nadar

      Not a programming question, keep you guns down. I just hate this kind of formatting. class fooclass { void foo1; virtual void foo2; const int foo3; ....and 20 more apis }; :mad:

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #5

      Yeah, there should be a SPACE before the semi-colon.

      B G L 3 Replies Last reply
      0
      • P Prakash Nadar

        Not a programming question, keep you guns down. I just hate this kind of formatting. class fooclass { void foo1; virtual void foo2; const int foo3; ....and 20 more apis }; :mad:

        J Offline
        J Offline
        John M Drescher
        wrote on last edited by
        #6

        Here is what I do most of the time:

        class laImageMaskResult : public laResult
        {
        typedef laResult Superclass;
        Q_OBJECT
        public:
        laImageMaskResult();
        laImageMaskResult(const laImageMaskResult & other);
        virtual ~laImageMaskResult();
        laImageMaskResult& operator=(const laImageMaskResult & other);

        enum Type {
        	EMPTY\_MASK		= 0x0000,
        	SEGMENTED\_LUNG		= 0x0001,
        	AIRWAY\_SEEDS		= 0x0002,
        	DETCTED\_AIRWAYS		= 0x0004,
        	DETECTED\_FISSURES	= 0x0008,
        };
        
        Q\_DECLARE\_FLAGS(Types, Type);
        

        public:
        virtual bool SaveResult(QString strFolder,QString strFileName);
        virtual bool LoadResult(QString strFolder,QString strFileName);
        virtual bool LoadResult();
        virtual void setType(Types ty);
        virtual Types getType();
        public:
        laVTKLungImageMask* SetImageMask(laVTKLungImageMask* pMask);
        laVTKLungImageMask* GetImageMask();
        protected:
        laVTKLungImageMask* m_pImageMask;
        Types m_type;
        private:
        void copy(const laImageMaskResult & other);
        void destroy();
        };

        John

        P 1 Reply Last reply
        0
        • C Chris Maunder

          The alignment or the massive whitespace? I am very, very strict about aligning code because it allows you to scan types, modifiers and names and reduces the chance of a scanning drive-by error. A little bit of effort that has saved me enough times to make it gospel.

          cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #7

          Can you force visual studio to keep the extra aligning whitespace without loosing all the other autoformatting to add white space where it's missing?

          The latest nation. Procrastination.

          C 1 Reply Last reply
          0
          • P PIEBALDconsult

            Yeah, there should be a SPACE before the semi-colon.

            B Offline
            B Offline
            Big Daddy Farang
            wrote on last edited by
            #8

            I agree but I doubt there are many others.

            BDF People don't mind being mean; but they never want to be ridiculous. -- Moliere

            1 Reply Last reply
            0
            • D Dan Neely

              Can you force visual studio to keep the extra aligning whitespace without loosing all the other autoformatting to add white space where it's missing?

              The latest nation. Procrastination.

              C Offline
              C Offline
              Chris Maunder
              wrote on last edited by
              #9

              You can either stop it auto-formatting, or you can hit Ctrl-Z after it auto-formats.

              cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

              D 1 Reply Last reply
              0
              • J John M Drescher

                Here is what I do most of the time:

                class laImageMaskResult : public laResult
                {
                typedef laResult Superclass;
                Q_OBJECT
                public:
                laImageMaskResult();
                laImageMaskResult(const laImageMaskResult & other);
                virtual ~laImageMaskResult();
                laImageMaskResult& operator=(const laImageMaskResult & other);

                enum Type {
                	EMPTY\_MASK		= 0x0000,
                	SEGMENTED\_LUNG		= 0x0001,
                	AIRWAY\_SEEDS		= 0x0002,
                	DETCTED\_AIRWAYS		= 0x0004,
                	DETECTED\_FISSURES	= 0x0008,
                };
                
                Q\_DECLARE\_FLAGS(Types, Type);
                

                public:
                virtual bool SaveResult(QString strFolder,QString strFileName);
                virtual bool LoadResult(QString strFolder,QString strFileName);
                virtual bool LoadResult();
                virtual void setType(Types ty);
                virtual Types getType();
                public:
                laVTKLungImageMask* SetImageMask(laVTKLungImageMask* pMask);
                laVTKLungImageMask* GetImageMask();
                protected:
                laVTKLungImageMask* m_pImageMask;
                Types m_type;
                private:
                void copy(const laImageMaskResult & other);
                void destroy();
                };

                John

                P Offline
                P Offline
                Prakash Nadar
                wrote on last edited by
                #10

                That makes sense, I do the same... but another developer does what I mentioned in my original post. btw, You use QT rite?

                D J 2 Replies Last reply
                0
                • C Chris Maunder

                  You can either stop it auto-formatting, or you can hit Ctrl-Z after it auto-formats.

                  cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #11

                  99% of the time I want the autoformatting on. I was hoping I could do something like:

                  #I Know What I`m Doing //disable autoformat

                  Code with manually aligned whitespace

                  #Mommy Knows Best //enable autoformat

                  Code without any special whitespace

                  :rolleyes:

                  The latest nation. Procrastination.

                  modified on Wednesday, September 2, 2009 9:07 AM

                  B 1 Reply Last reply
                  0
                  • P Prakash Nadar

                    That makes sense, I do the same... but another developer does what I mentioned in my original post. btw, You use QT rite?

                    D Offline
                    D Offline
                    Dan Neely
                    wrote on last edited by
                    #12

                    Cobol poisoning?

                    The latest nation. Procrastination.

                    1 Reply Last reply
                    0
                    • D Dan Neely

                      99% of the time I want the autoformatting on. I was hoping I could do something like:

                      #I Know What I`m Doing //disable autoformat

                      Code with manually aligned whitespace

                      #Mommy Knows Best //enable autoformat

                      Code without any special whitespace

                      :rolleyes:

                      The latest nation. Procrastination.

                      modified on Wednesday, September 2, 2009 9:07 AM

                      B Offline
                      B Offline
                      Big Daddy Farang
                      wrote on last edited by
                      #13

                      Wouldn't "Mommy Knows Best" enable autoformat?

                      BDF People don't mind being mean; but they never want to be ridiculous. -- Moliere

                      D 1 Reply Last reply
                      0
                      • P Prakash Nadar

                        That makes sense, I do the same... but another developer does what I mentioned in my original post. btw, You use QT rite?

                        J Offline
                        J Offline
                        John M Drescher
                        wrote on last edited by
                        #14

                        Yes, that is Qt. Although that example is not one of the interesting ones that uses signals and slots.. I would have included one as an example but the first two I looked at were not following my general style.

                        John

                        1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          Yeah, there should be a SPACE before the semi-colon.

                          G Offline
                          G Offline
                          Gary R Wheeler
                          wrote on last edited by
                          #15

                          You've got to be fucking kidding.

                          Software Zen: delete this;
                          Fold With Us![^]

                          1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            Yeah, there should be a SPACE before the semi-colon.

                            L Offline
                            L Offline
                            Luc Pattyn
                            wrote on last edited by
                            #16

                            are you sure? isn't it a newline and a whole bunch of spaces? :)

                            Luc Pattyn

                            :badger: :jig: :badger:

                            Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

                            :jig: :badger: :jig:

                            P 1 Reply Last reply
                            0
                            • L Luc Pattyn

                              are you sure? isn't it a newline and a whole bunch of spaces? :)

                              Luc Pattyn

                              :badger: :jig: :badger:

                              Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

                              :jig: :badger: :jig:

                              P Offline
                              P Offline
                              PIEBALDconsult
                              wrote on last edited by
                              #17

                              No, one SPACE will do; there are too many on the line already.

                              1 Reply Last reply
                              0
                              • C Chris Maunder

                                The alignment or the massive whitespace? I am very, very strict about aligning code because it allows you to scan types, modifiers and names and reduces the chance of a scanning drive-by error. A little bit of effort that has saved me enough times to make it gospel.

                                cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

                                A Offline
                                A Offline
                                Anna Jayne Metcalfe
                                wrote on last edited by
                                #18

                                Same here. Ditto (in C++ anyway) using const appropriately. Of course, when a guy formats his code well it's called Metrosexual Programming[^], right? :rolleyes:

                                Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                                C 1 Reply Last reply
                                0
                                • B Big Daddy Farang

                                  Wouldn't "Mommy Knows Best" enable autoformat?

                                  BDF People don't mind being mean; but they never want to be ridiculous. -- Moliere

                                  D Offline
                                  D Offline
                                  Dan Neely
                                  wrote on last edited by
                                  #19

                                  *whistles innocently* I don't know what you're talking about. :-\

                                  The latest nation. Procrastination.

                                  1 Reply Last reply
                                  0
                                  • A Anna Jayne Metcalfe

                                    Same here. Ditto (in C++ anyway) using const appropriately. Of course, when a guy formats his code well it's called Metrosexual Programming[^], right? :rolleyes:

                                    Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                                    C Offline
                                    C Offline
                                    Chris Maunder
                                    wrote on last edited by
                                    #20

                                    Anna-Jayne Metcalfe wrote:

                                    Metrosexual Programming

                                    Brilliant!

                                    cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

                                    A 1 Reply Last reply
                                    0
                                    • C Chris Maunder

                                      Anna-Jayne Metcalfe wrote:

                                      Metrosexual Programming

                                      Brilliant!

                                      cheers, Chris Maunder The Code Project Co-founder Microsoft C++ MVP

                                      A Offline
                                      A Offline
                                      Anna Jayne Metcalfe
                                      wrote on last edited by
                                      #21

                                      i thought you'd like that. :)

                                      Anna :rose: Having a bad bug day? Tech Blog | Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      • Login

                                      • Don't have an account? Register

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • World
                                      • Users
                                      • Groups