update dev300-m58
[ooovba.git] / testshl2 / workben / getopt / test_getopt.cxx
blob6968e39b56ec95d3d44ed4835197cbfbf7901f15
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: test_getopt.cxx,v $
10 * $Revision: 1.5 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_testshl2.hxx"
34 #include <stdio.h>
35 #include <stdlib.h>
37 #ifdef SOLARIS
38 #include <sys/time.h>
39 #endif
41 #ifdef WNT
42 // #define UNDER_WINDOWS_DEBUGGING
43 // Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
44 #ifdef UNDER_WINDOWS_DEBUGGING
45 #include <tools/presys.h>
46 #include <windows.h>
47 #include <tools/postsys.h>
49 #define VCL_NEED_BASETSD
51 #endif /* UNDER_WINDOWS_DEBUGGING */
52 #endif /* WNT */
54 #include <iostream>
55 #include <vector>
56 #include <rtl/string.hxx>
58 #include "filehelper.hxx"
59 #include "getopt.hxx"
61 // #include <osl/time.h>
63 using namespace std;
65 // -----------------------------------------------------------------------------
67 /**
68 * display usage screen
71 void usage()
73 fprintf( stdout,
74 "USAGE: testshl shlname [-boom][-verbose][-log][-his][-msg]\n" );
75 exit(0);
78 // ----------------------------------- Main -----------------------------------
79 #if (defined UNX) || (defined OS2)
80 int main( int argc, char* argv[] )
81 #else
82 int _cdecl main( int argc, char* argv[] )
83 #endif
85 (void) argc;
86 static char const* optionSet[] = {
87 "-boom, stop near error position, exception only",
88 "-mode=s, the output mode, emacs, xml, old. Default is -mode old",
89 "-logPath=s, destination path for logging",
90 "-tc=s@, name(s) of testcase(s) to generate",
91 "-h:s, display help or help on option",
92 "-help:s, see -h",
93 NULL
96 GetOpt opt( argv, optionSet );
98 // someone indicates that he needs help
99 if ( opt.hasOpt( "-h" ) || opt.hasOpt( "-help" ) )
101 opt.showUsage();
102 // exit(0);
105 // get path for logging stuff..
106 rtl::OString logPth;
107 // ...if available
108 if ( opt.hasOpt( "-logPth" ))
110 logPth = opt.getOpt( "-logPth" );
113 rtl::OString param;
114 if ( ! opt.getParams().empty() ) {
115 param = opt.getFirstParam();
117 std::cout << "all non '-' Parameter values" << std::endl;
119 vector<rtl::OString>& aVec = opt.getParams();
120 for(vector<rtl::OString>::const_iterator it = aVec.begin();
121 it != aVec.end();
122 ++it)
124 std::cout << (*it).getStr() << std::endl;
128 if ( opt.hasOpt("-tc"))
130 std::cout << "Parameter -tc" << std::endl;
131 vector<rtl::OString>& aVec = opt.getOptVec( "-tc" );
133 for(vector<rtl::OString>::const_iterator it = aVec.begin();
134 it != aVec.end();
135 ++it)
137 std::cout << (*it).getStr() << std::endl;
141 return 0;