C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tool to convert public mem var RWs to use accessor methods?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Todd A. Anderson
Guest





PostPosted: Fri Jun 27, 2003 12:22 am    Post subject: Tool to convert public mem var RWs to use accessor methods? Reply with quote



I've inherited two "C++" code bases that I have to tie together
and both of them make frequest use of public member variables
in spite of all the information saying this limits flexibility. Well,
their lack of foresight has bit me of course! I'd like to start off
by converting all their public member variable accesses to the
use of accessor methods. Then, I can reimplement selected
accessor methods to provide the necessary glue between the
code bases.

The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?

thanks,

Todd


Back to top
Suzanne Vogel
Guest





PostPosted: Sat Jun 28, 2003 11:20 am    Post subject: Re: Tool to convert public mem var RWs to use accessor metho Reply with quote



Sounds like a job for regular expressions, e.g., in C++ or Perl.

Todd A. Anderson wrote:
Quote:
I've inherited two "C++" code bases that I have to tie together
and both of them make frequest use of public member variables
in spite of all the information saying this limits flexibility. Well,
their lack of foresight has bit me of course! I'd like to start off
by converting all their public member variable accesses to the
use of accessor methods. Then, I can reimplement selected
accessor methods to provide the necessary glue between the
code bases.

The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?

thanks,

Todd




Back to top
Jerry Coffin
Guest





PostPosted: Sun Jun 29, 2003 2:42 am    Post subject: Re: Tool to convert public mem var RWs to use accessor metho Reply with quote



In article <bdg2ov$4qf$1 (AT) news01 (DOT) intel.com>, [email]drtodd (AT) aaahawk (DOT) com[/email] says...

[ ... ]

Quote:
The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?

I don't know of anything that does it entirely automatically, but right
now operator overloading just became one of your best friends.

Instead of attempting to find every place every variable is used, look
only for where they're declared, which is usually a LOT easier. Convert
each from its current type to an instance of a class that overloads
operator=(T const &) and operator T (where T is the original type).
These are your new "accessor" functions -- operator T converts your type
to the original type just before its value gets assigned, and operator=
gets called (of course) to assign some value to your object.

IMO, even if this didn't save a tremendous amount of work, it would
still be the way to go -- using accessor and mutator functions is almost
always quite ugly.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.