[Qgis-developer] namespace QgsLogger

Mateusz Loskot mateusz at loskot.net
Mon Aug 14 19:22:22 EDT 2006


Radim Blazek wrote:
> Hi,
> 
> I think that it would be useful to have defined namespace QgsLogger
> so that we could use
>  using namespace QgsLogger;
> and then debug() without QgsLogger:: prefix.
> Anybody knows how to define it? I tried to add
> namespace QgsLogger { } around QgsLogger class definition but it does
> not compile.

Just as side note, 'using' directives are not recommended
in shared header files because it causes
pollution of global namespace.
(See "Characteristics of a Good Long-Term Solution" under
http://www.gotw.ca/gotw/053.htm)

If you would like to write less than that, you can put namespace alias
in header where QgsLogger is defined:


namespace log = QgsLogger;
// or even shorter
namespace w = QgsLogger;

Then you will be able to use

log::debug();
or
w::debug();


Best regards
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Qgis-developer mailing list