-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice.h
71 lines (58 loc) · 1.36 KB
/
service.h
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
#ifndef __MDXtoHTML_SERVICE__
#define __MDXtoHTML_SERVICE__
#include <string>
#include <iostream>
#include <strstream>
#include <fstream>
#include "Utils.h"
using namespace std;
/**
*
* Âûòàñêèåì ïàðàìåòðû è îòêðûâàåì ôàéëû äëÿ ðàáîòû.
* Êëþ÷è:
* -i -- âõîäíîé ôàéë. Îáÿçàòåëüíûé ïàðàìåòð.
* -o -- âûõîäíîé ôàéë. Íåîáÿçàòåëüíûé ïàðàìåòð. Ïî óìîë÷àíèþ êîìïèëèðóåì â out.html
*/
bool readConsoleParams( int argc, char* argv[], ifstream &input_file, ofstream &output_file )
{
string inputFile, outputFile;
bool dInputFile = false;
bool dOutputFile = false;
#ifdef __DBGOUTPUT__
MACRO_MESSAGE("---Command line:---\n");
//stringstream ss;
#endif
for ( int i=1; i < argc; ++i )
{
#ifdef __DBGOUTPUT__
//ss<<i<<":"<<argv[i]<<endl;
#endif
if ( strcmp( argv[i], "-i" ) == 0 && argc > i + 1 )
{
inputFile = argv[i+1];
dInputFile = true;
}
if ( strcmp( argv[i], "-o" ) == 0 && argc > i + 1 )
{
outputFile = argv[i+1];
dOutputFile = true;
}
}
#ifdef __DBG__
//MACRO_MESSAGE(ss.string());
#endif
if ( !dInputFile )
{
MACRO_ERROR_RET("Error: not defined input file.", false);
}
if ( !dOutputFile )
outputFile = "out.html";
#ifdef __DBGOUTPUT__
MACRO_MESSAGE("In: " + inputFile + "\n" );
MACRO_MESSAGE("Out: "+ outputFile + "\n---------\n");
#endif
input_file = ifstream(inputFile);
output_file = ofstream(outputFile);
return true;
}
#endif