|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Mifconv main. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mifconv.h" |
|
20 #include "mifconv_exception.h" |
|
21 #include "mifconv_argumentmanager.h" |
|
22 #include "mifconv_convertermanager.h" |
|
23 #include "mifconv_util.h" |
|
24 |
|
25 int main( int argc, char *argv[] ) |
|
26 { |
|
27 cout << endl << "Mifconv v" << MifConvVersion << " - " << MifConvDate << endl; |
|
28 // Instantiate the argument manager and mif creator: |
|
29 MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance(); |
|
30 MifConvConverterManager* converterMgr = MifConvConverterManager::Instance(); |
|
31 |
|
32 try { |
|
33 // Read arguments to string vector: |
|
34 MifConvStringList strList; |
|
35 for( int i = 1; i < argc; ++i ) |
|
36 { |
|
37 strList.push_back(MifConvString(argv[i])); |
|
38 } |
|
39 |
|
40 // Initialize arguments: |
|
41 argMgr->Init(strList); |
|
42 |
|
43 // Initialize converters: |
|
44 converterMgr->Init(); |
|
45 |
|
46 // Run converters for source files: |
|
47 converterMgr->ProcessIcons(); |
|
48 |
|
49 // Cleanup temp files etc: |
|
50 converterMgr->Cleanup(); |
|
51 } |
|
52 catch( MifConvException& e ) { |
|
53 // In case of error, print exception to stderr, cleanup temp files and exit: |
|
54 std::stringstream strForInt; |
|
55 strForInt << e.Line(); |
|
56 |
|
57 MifConvUtil::DebugLog(e.File() + MifConvString(":") + strForInt.str() + MifConvString(":") + e.String()); |
|
58 cerr << e.String() << endl; |
|
59 converterMgr->Cleanup(true); |
|
60 converterMgr->Reset(); |
|
61 argMgr->Reset(); |
|
62 exit(MIFCONV_ERROR); |
|
63 } |
|
64 catch(...) |
|
65 { |
|
66 // Unknown error: |
|
67 MifConvUtil::DebugLog("MifConv: Unknown error"); |
|
68 cerr << "MifConv: Unknown error" << endl; |
|
69 converterMgr->Cleanup(true); |
|
70 converterMgr->Reset(); |
|
71 argMgr->Reset(); |
|
72 exit(MIFCONV_ERROR); |
|
73 } |
|
74 |
|
75 converterMgr->Reset(); |
|
76 argMgr->Reset(); |
|
77 return MIFCONV_NO_ERROR; |
|
78 } |