code formatting question

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

code formatting question

Postby gbrandt » Sat Feb 27, 2010 4:55 pm

I have set up Builder 2010 to follow my code formatting standards except in a few cases. I don't know if I can change Builder to follow my standard on these, perhaps you can help:

I place doxygen comments after member names in classes:

Code: Select all
private:
   SomeClass *aclass;            //!< a class
   int some int;                 //!< an int


after auto formatting I get:

Code: Select all
private:
   SomeClass *aclass; //!< a class
   int some int; //!< an int


but would like the comment to remain untouched.


I also indent my macros

Code: Select all
#ifdef X
   #define Y
#else
  #define Z
#endif


but builder always reformats to

Code: Select all
#ifdef X
#define Y
#else
#define Z
#endif


and finally I format my classes and case statements such that there are three levels of indentation:

Code: Select all
class x
{
   public:
      int y;

   private:
      int z;
}

switch( x )
{
   case 1:
      dosomething();
      break;

   case 2:
      dosomethingelse();
      break;
}

and builder reformats this to (if indent case labels is set to none)

Code: Select all
class x
{
   public:
   int y;

   private:
   int z;
}

switch( x )
{
   case 1:
   dosomething();
   break;

   case 2:
   dosomethingelse();
   break;
}

and builder reformats this to (if indent case labels is set to decrease one indent)

Code: Select all
class x
{
public:
   int y;

private:
   int z;
}

switch( x )
{
case 1:
   dosomething();
   break;

case 2:
   dosomethingelse();
   break;
}


Is there anyway to keep my formatting?

Thanks,
Gregor
Last edited by gbrandt on Tue Mar 02, 2010 12:30 pm, edited 1 time in total.
gbrandt
Top Poster
Top Poster
 
Posts: 41
Joined: Thu Feb 11, 2010 12:45 pm

Re: code formatting question

Postby arisme » Mon Mar 01, 2010 4:10 pm

gbrandt wrote:Is there anyway to keep my formatting?

In my C++Builder 2007, all your sample code remains as originally written.

Apart from a couple of minor adjustments to the default Auto Completion templates, I do not ask the IDE to format anything.

gbrandt wrote:I have set up Builder to follow my code formatting standards except in a few cases.

I do not know what formatting settings you may have created, but they seem to be responsible for the results in your code samples.

You may find writing code easier with IDE formatting at default settings. This may leave you with a few cases where you want something special, and have to arrange manually - but at least whatever your layout, it should remain as written.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: code formatting question

Postby gambit47 » Tue Mar 02, 2010 1:19 am

arisme wrote:In my C++Builder 2007, all your sample code remains as originally written.


It sounds like Gregor was referring to the new Code Formatting feature that was introduced in CB2010.
Remy Lebeau (TeamB)
http://www.lebeausoftware.org
User avatar
gambit47
BCBJ Author
BCBJ Author
 
Posts: 472
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: code formatting question

Postby gbrandt » Tue Mar 02, 2010 12:32 pm

gambit47 wrote:It sounds like Gregor was referring to the new Code Formatting feature that was introduced in CB2010.


Correct. I have updated my original question to fix that. For now I am living with the 'funkiness' of the code formatter. It makes the code I am working on now much easier to read.
gbrandt
Top Poster
Top Poster
 
Posts: 41
Joined: Thu Feb 11, 2010 12:45 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 4 guests

cron