-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.cpp
executable file
·103 lines (80 loc) · 2.64 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
Cambio: a simple program to convert or manipulate gamma spectrum data files.
Copyright (C) 2015 William Johnson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "Cambio_config.h"
#if( BUILD_CAMBIO_COMMAND_LINE )
#include "cambio/CommandLineUtil.h"
#endif
#ifdef _WIN32
#include "SpecUtils/StringAlgo.h"
#endif
#if( BUILD_CAMBIO_GUI )
#include "cambio/CambioApp.h"
#if( defined(Q_OS_MAC) )
#include <QtPlugin>
Q_IMPORT_PLUGIN(QMacStylePlugin)
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
#endif
#if( defined(Q_OS_WIN) )
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#endif
#endif
#if( !BUILD_CAMBIO_GUI && !BUILD_CAMBIO_COMMAND_LINE )
#error "You must have BUILD_CAMBIO_GUI and/or BUILD_CAMBIO_COMMAND_LINE enabled"
#endif
#ifdef _WIN32
void getUtf8Args( int &argc, wchar_t **wargv, char ** &argv );
#endif
#include <iostream>
#ifdef _WIN32
int wmain( int argc, wchar_t *wargv[] )
{
char **argv;
getUtf8Args( argc, wargv, argv );
#else
int main( int argc, char *argv[] )
{
#endif
#if( BUILD_CAMBIO_COMMAND_LINE )
#if( BUILD_CAMBIO_GUI )
if( CommandLineUtil::requested_command_line_from_gui( argc, argv ) )
return CommandLineUtil::run_command_util( argc, argv );
#else
return CommandLineUtil::run_command_util( argc, argv );
#endif
#endif
#if( BUILD_CAMBIO_GUI )
CambioApp a( argc, argv );
return a.exec();
#endif
}//int main(int argc, char *argv[])
#ifdef _WIN32
#include "SpecUtils/StringAlgo.h"
/** Get command line arguments encoded as UTF-8.
This function just leaks the memory
*/
void getUtf8Args( int &argc, wchar_t **argvw, char ** &argv )
{
argv = (char **)malloc(sizeof(char *)*argc);
for( int i = 0; i < argc; ++i)
{
//printf("Argument: %d: %ws\n", i, argvw[i]);
const std::string asutf8 = SpecUtils::convert_from_utf16_to_utf8( argvw[i] );
argv[i] = (char *)malloc( sizeof(char)*(asutf8.size()+1) );
strcpy( argv[i], asutf8.c_str() );
}//for( int i = 0; i < argc; ++i)
}//void processCustomArgs()
#endif //_WIN32