So I am creating a simple class like:
class file
{
public:
boost::filesystem::path path;
bool is_directory;
boost::uintmax_t target_size;
void get(boost::shared_ptr<boost::asio::ip::tcp::socket> socket, boost::shared_ptr<http_response> response);
void set()
};
and I see that if some automated procedure would provide me a dialog and create geters and setters for some of my variables (instead of me just leaving tham to be public or creating each manually ) my code API would look beter, and it would be easier for me to implement thread safty. Is there any command for doing such dirty work in VS2010 or in VA?
Select class variable and from context menu pick Refactor (VA X) -> Encapsulate Field. You can customise the format by modifying Refactor Encapsulate Field snippet. You can find more on customising snippets here.
The snippet I personally use yields Java-like accessors with doxygen documentation stubs:
//! \return
$end$$SymbolType$ get$GeneratedPropertyName$() const
{
return $SymbolName$;
}
//! \param $SymbolName$
void set$GeneratedPropertyName$($SymbolType$ $SymbolName$)
{
this->$SymbolName$ = $SymbolName$;
}
Of course it's not perfect, you'll still have to modify results from time to time (adjusting constness, pointers, references), but it case a lot of time.
Alternatively you can create your own custom snippet and run it from context menu Surround with (VA X), but you won't have access to $Symbol*$ variables.