1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cmdline.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "cmdline.hxx"
39 char C_sUseText
[] = "Use: xml2cmp.exe \n"
40 " [-func funcFile] \n"
41 " [-html htmlFile] \n"
42 " [-types typeFile] \n"
43 " [-idlpath idlPath] \n"
49 " [-idlpath idlPath] \n"
50 " tagname [tagname ...]";
53 char C_sCmdFunc
[] = "-func";
54 char C_sCmdHtml
[] = "-html";
55 char C_sCmdType
[] = "-types";
56 char C_sCmdIndex
[] = "-ix";
57 char C_sCmdIdlPath
[] = "-idlpath";
61 bool GetParameter( Simstr
& o_rMemory
, int & io_nCountArg
, int argc
, char * argv
[] );
64 CommandLine::CommandLine( int argc
,
68 bool bDisplayUse
= false;
70 /* Check command line: */
73 else if ( argc
== 2 && ! isalnum(argv
[1][0]) )
75 else if ( strcmp( argv
[1], C_sCmdIndex
) == 0 && argc
< 5 )
80 std::cout
<< C_sUseText
<< std::endl
;
85 if ( strcmp( argv
[1], C_sCmdIndex
) == 0 )
87 ParseIndexCommand(argc
,argv
);
91 ParseSingleFileCommand(argc
,argv
);
94 if ( sXmlSourceFile
.l() == 0
95 && sXmlSourceDirectory
.l() == 0 )
99 else if ( sXmlSourceFile
.l() > 0
100 && sXmlSourceDirectory
.l() > 0 )
104 else if ( sIndexFile
.l() > 0
105 && ( sXmlSourceDirectory
.l() == 0
106 || aTagsInIndex
.size() == 0
115 CommandLine::~CommandLine()
121 CommandLine::ErrorText() const
123 static char cOut
[] = "Error: Command line was incorrect. Probably there was a flag without\n"
124 " the corresponding parameter. Or there was no XML-sourcefile specified.\n";
129 GetParameter( Simstr
& o_pMemory
,
135 if( io_pCountArg
< argc
)
137 o_pMemory
= argv
[io_pCountArg
];
145 CommandLine::ParseIndexCommand( int argc
,
149 bIsOk
= GetParameter(
155 bIsOk
= GetParameter(
160 if (bIsOk
&& strcmp( argv
[nCountArg
+1], C_sCmdIdlPath
) == 0 )
161 bIsOk
= GetParameter(
167 sIndexFile
= sOutputDirectory
;
168 #if defined(WNT) || defined(OS2)
169 sIndexFile
+= "\\xmlindex.html";
171 sIndexFile
+= "/xmlindex.html";
174 for ( ++nCountArg
; nCountArg
< argc
; ++nCountArg
)
176 Simstr
sElementName(argv
[nCountArg
]);
177 aTagsInIndex
.push_back( sElementName
);
183 CommandLine::ParseSingleFileCommand( int argc
,
186 for ( int nCountArg
= 1; nCountArg
< argc
&& bIsOk
; ++nCountArg
)
188 if ( strcmp( argv
[nCountArg
], C_sCmdFunc
) == 0 )
190 bIsOk
= GetParameter(
196 else if ( strcmp( argv
[nCountArg
], C_sCmdHtml
) == 0 )
198 bIsOk
= GetParameter(
204 else if ( strcmp( argv
[nCountArg
], C_sCmdType
) == 0 )
206 bIsOk
= GetParameter(
212 else if ( strcmp( argv
[nCountArg
], C_sCmdIdlPath
) == 0 )
214 bIsOk
= GetParameter(
222 sXmlSourceFile
= argv
[nCountArg
];