X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FMainHelper.h;fp=lib%2FcpBaseQtApplication%2FMainHelper.h;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=d850b256cac238e978b4466167ef5d5dad74e493;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/MainHelper.h b/lib/cpBaseQtApplication/MainHelper.h deleted file mode 100644 index d850b25..0000000 --- a/lib/cpBaseQtApplication/MainHelper.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef __cpBaseQtApplication__MainHelper__h__ -#define __cpBaseQtApplication__MainHelper__h__ - -#include -#include - -// ------------------------------------------------------------------------- -#define cpBaseQtApplication_Main( _window_class_ ) \ - int main( int argc, char* argv[] ) \ - { \ - QApplication a( argc, argv ); \ - _window_class_ w( argc, argv ); \ - w.show( ); \ - return( a.exec( ) ); \ - } - -// ------------------------------------------------------------------------- -#include - -#ifdef cpPlugins_OS_Windows - -# include -# include -# include -# include - -// ------------------------------------------------------------------------- -namespace cpBaseQtApplication -{ - /** - */ - class Win32CommandLineConverter - { - private: - std::unique_ptr< char*[ ] > argv_; - std::vector< std::unique_ptr< char[ ] > > storage_; - - public: - Win32CommandLineConverter( ) - { - LPWSTR cmd_line = GetCommandLineW( ); - int argc; - LPWSTR* w_argv = CommandLineToArgvW( cmd_line, &argc ); - argv_ = std::unique_ptr< char*[ ] >( new char*[ argc ] ); - storage_.reserve( argc ); - for( int i = 0; i < argc; ++i ) - { - storage_.push_back( ConvertWArg( w_argv[ i ] ) ); - argv_[ i ] = storage_.back( ).get( ); - - } // rof - LocalFree( w_argv ); - } - int argc( ) const - { - return( static_cast< int >(storage_.size( ) ) ); - } - char** argv( ) const - { - return( argv_.get( ) ); - } - static std::unique_ptr< char[ ] > ConvertWArg( LPWSTR w_arg ) - { - int size = WideCharToMultiByte( - CP_UTF8, 0, w_arg, -1, nullptr, 0, nullptr, nullptr - ); - std::unique_ptr< char[ ] > ret( new char[ size ] ); - WideCharToMultiByte( - CP_UTF8, 0, w_arg, -1, ret.get( ), size, nullptr, nullptr - ); - return( ret ); - } - }; - -} // ecapseman - -// ------------------------------------------------------------------------- -# define cpBaseQtApplication_MainComplement \ - int CALLBACK WinMain( HINSTANCE i, HINSTANCE p, LPSTR c, int s ) \ - { \ - cpBaseQtApplication::Win32CommandLineConverter cmd_line; \ - return( main( cmd_line.argc( ), cmd_line.argv( ) ) ); \ - } -#else // cpPlugins_OS_Windows -# define cpBaseQtApplication_MainComplement -#endif // cpPlugins_OS_Windows - -#endif // __cpBaseQtApplication__MainHelper__h__ - -// eof - $RCSfile$