Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
0fcd1180
Kaydet (Commit)
0fcd1180
authored
Ock 09, 2003
tarafından
Lars Langhans
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
testshl2 code
üst
3c3feccb
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
3650 additions
and
0 deletions
+3650
-0
build.lst
testshl2/prj/build.lst
+8
-0
d.lst
testshl2/prj/d.lst
+31
-0
autoregisterhelper.cxx
testshl2/source/autoregisterhelper.cxx
+93
-0
codegen.pl
testshl2/source/codegen/codegen.pl
+355
-0
dynamicregister.cxx
testshl2/source/dynamicregister.cxx
+29
-0
file.cxx
testshl2/source/file.cxx
+44
-0
filehelper.cxx
testshl2/source/filehelper.cxx
+168
-0
getopt.cxx
testshl2/source/getopt.cxx
+917
-0
makefile.mk
testshl2/source/makefile.mk
+122
-0
testshl.cxx
testshl2/source/testshl.cxx
+242
-0
versioner.cxx
testshl2/source/versioner.cxx
+41
-0
versionhelper.cxx
testshl2/source/versionhelper.cxx
+39
-0
makefile.mk
testshl2/util/makefile.mk
+75
-0
makefile.mk
testshl2/workben/dlltest/makefile.mk
+162
-0
onefunc.cxx
testshl2/workben/dlltest/onefunc.cxx
+21
-0
onefuncstarter.cxx
testshl2/workben/dlltest/onefuncstarter.cxx
+115
-0
registerfunc.h
testshl2/workben/dlltest/registerfunc.h
+14
-0
makefile.mk
testshl2/workben/examples/makefile.mk
+101
-0
testshl_test.cxx
testshl2/workben/examples/testshl_test.cxx
+314
-0
makefile.mk
testshl2/workben/getopt/makefile.mk
+97
-0
test_getopt.cxx
testshl2/workben/getopt/test_getopt.cxx
+173
-0
makefile.mk
testshl2/workben/makefile.mk
+114
-0
singleton.cxx
testshl2/workben/singleton.cxx
+19
-0
test_autoptr.cxx
testshl2/workben/test_autoptr.cxx
+70
-0
test_filter.cxx
testshl2/workben/test_filter.cxx
+200
-0
test_ostringstream.cxx
testshl2/workben/test_ostringstream.cxx
+86
-0
No files found.
testshl2/prj/build.lst
0 → 100644
Dosyayı görüntüle @
0fcd1180
ts testshl2 : sal NULL
ts testshl2 usr1 - all ts_mkout NULL
ts testshl2\source\cppunit nmake - all ts_tss NULL
ts testshl2\source\result nmake - all ts_tsr ts_tss NULL
ts testshl2\source nmake - all ts_tst ts_tsr ts_tss NULL
ts testshl2\util nmake - all ts_tstu ts_tst ts_tsr ts_tss NULL
ts testshl2\inc get - all ts_tsti NULL
testshl2/prj/d.lst
0 → 100644
Dosyayı görüntüle @
0fcd1180
mkdir: %_DEST%\inc%_EXT%\cppunit
mkdir: %_DEST%\inc%_EXT%\cppunit\portability
mkdir: %_DEST%\inc%_EXT%\cppunit\autoregister
mkdir: %_DEST%\inc%_EXT%\cppunit\extensions
..\inc\cppunit\*.h %_DEST%\inc%_EXT%\cppunit\*.h
..\inc\cppunit\*.hxx %_DEST%\inc%_EXT%\cppunit\*.hxx
..\inc\cppunit\portability\*.h %_DEST%\inc%_EXT%\cppunit\portability\*.h
..\inc\cppunit\extensions\*.h %_DEST%\inc%_EXT%\cppunit\extensions\*.h
..\inc\cppunit\autoregister\htestresult.h %_DEST%\inc%_EXT%\cppunit\autoregister\htestresult.h
..\inc\cppunit\autoregister\treswrapper.h %_DEST%\inc%_EXT%\cppunit\autoregister\treswrapper.h
..\inc\cppunit\autoregister\testfunc.h %_DEST%\inc%_EXT%\cppunit\autoregister\testfunc.h
..\inc\cppunit\autoregister\registertestfunction.h %_DEST%\inc%_EXT%\cppunit\autoregister\registertestfunction.h
..\inc\cppunit\autoregister\callbackstructure.h %_DEST%\inc%_EXT%\cppunit\autoregister\callbackstructure.h
..\inc\cppunit\autoregister\callbackfunc_fktptr.h %_DEST%\inc%_EXT%\cppunit\autoregister\callbackfunc_fktptr.h
# ..\src\result\inc\cppunit\*.h %_DEST%\inc%_EXT%\cppunit\*.h
# ..\src\result\inc\cppunit\result\*.h %_DEST%\inc%_EXT%\cppunit\result\*.h
# ..\%__SRC%\lib\tstutil.lib %_DEST%\lib%_EXT%\tstutil.lib
# ..\%__SRC%\bin\testshl.exe %_DEST%\bin%_EXT%\testshl.exe
..\%__SRC%\bin\testshl2.exe %_DEST%\bin%_EXT%\testshl2.exe
..\%__SRC%\bin\testshl2 %_DEST%\bin%_EXT%\testshl2
mkdir: %_DEST%\inc%_EXT%\testshl
..\inc\*.hxx %_DEST%\inc%_EXT%\testshl\*.hxx
..\inc\*.h %_DEST%\inc%_EXT%\testshl\*.h
..\%__SRC%\lib\cppunit.lib %_DEST%\lib%_EXT%\cppunit.lib
..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
testshl2/source/autoregisterhelper.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdio.h>
#include <stdlib.h>
#include "autoregisterhelper.hxx"
#include <rtl/ustring.hxx>
#include <cppunit/autoregister/registerfunc.h>
#include <cppunit/autoregister/callbackstructure.h>
#include <cppunit/result/callbackfunc.h>
#include <cppunit/autoregister/testfunc.h>
#include "filehelper.hxx"
FunctionList
m_Functions
;
// osl::Mutex m_Mutex;
void
SAL_CALL
registerFunc
(
FktPtr
_pFunc
,
const
char
*
_sFuncName
)
{
// printf("Function register call for func(%s) successful.\n", _sFuncName);
m_Functions
.
push_back
(
_pFunc
);
}
// -----------------------------------------------------------------------------
AutomaticRegisterHelper
::
AutomaticRegisterHelper
(
rtl
::
OUString
const
&
_sDLLName
,
GetOpt
&
_aOptions
/*, JobList * _pJobList*/
)
:
DynamicLibraryHelper
(
_sDLLName
,
_aOptions
)
{
// try to get the entry pointer
FktRegAllPtr
pFunc
=
(
FktRegAllPtr
)
m_pModule
->
getSymbol
(
rtl
::
OUString
::
createFromAscii
(
"registerAllTestFunction"
)
);
if
(
pFunc
)
{
// FktRegFuncPtr pRegisterFunc = &DynamicLibraryHelper::registerFunc;
// pFunc(pRegisterFunc);
// osl::Guard aGuard(m_Mutex);
FktRegFuncPtr
pRegisterFunc
=
&
registerFunc
;
CallbackStructure
aCallback
;
aCallback
.
aRegisterFunction
=
pRegisterFunc
;
aCallback
.
aCallbackDispatch
=
&
CallbackDispatch
;
if
(
_aOptions
.
hasOpt
(
"-forward"
))
{
aCallback
.
psForward
=
_aOptions
.
getOpt
(
"-forward"
).
getStr
();
}
// aCallback.pJobList = _pJobList;
//# aCallback.aStartTest = &TestResult_startTest;
//# aCallback.aAddFailure = &TestResult_addFailure;
//# aCallback.aAddError = &TestResult_addError;
//# aCallback.aEndTest = &TestResult_endTest;
//# aCallback.aShouldStop = &TestResult_shouldStop;
//# aCallback.aAddInfo = &TestResult_addInfo;
//# aCallback.aEnterNode = &TestResult_enterNode;
//# aCallback.aLeaveNode = &TestResult_leaveNode;
aCallback
.
nBits
=
FileHelper
::
createFlags
(
_aOptions
);
pFunc
(
&
aCallback
);
if
(
aCallback
.
nMagic
==
aCallback
.
nMagic2
)
{
// ok internal simple test done.
m_aFunctionList
=
m_Functions
;
}
else
{
// ERROR, the function seams not to be what we thing it's to be.
fprintf
(
stderr
,
"error: Internal test failed. Value Magic2 != Magic
\n
"
);
exit
(
-
1
);
}
}
else
{
fprintf
(
stderr
,
"warning: Function 'registerAllTestFunction' not found.
\n
"
);
}
}
void
AutomaticRegisterHelper
::
CallAll
(
hTestResult
_hResult
)
{
for
(
FunctionList
::
const_iterator
it
=
m_aFunctionList
.
begin
();
it
!=
m_aFunctionList
.
end
();
++
it
)
{
FktPtr
pFunc
=
*
it
;
if
(
pFunc
)
{
(
pFunc
)(
_hResult
);
}
}
}
testshl2/source/codegen/codegen.pl
0 → 100644
Dosyayı görüntüle @
0fcd1180
#!/usr/bin/perl
# @lines
# push(@lines, $line) append
# pop(@lines) remove last
# shift(@lines) remove at first
# unshift(@lines, $line) insert at first
# $lines[-1] get last
# foreach $line (@lines)
# $a eq $b compares strings
# $a == $b compares digits
# split operator
# ($vorname, $nachname, $email) = split (/\s+/, $person);
my
$sCurrentPackage
=
""
;
my
$sCurrentClass
=
""
;
my
@sMethodNames
;
my
@sClassNameStack
;
my
@sFilenameStack
;
my
$sCurrentFilename
;
my
$bShowDemo
=
1
;
# ------------------------------------------------------------------------------
sub
createFilename
{
my
$sPackageName
=
shift
;
my
$sFilename
=
"$sPackageName.cxx"
;
while
(
-
e
$sFilename
)
{
$nCount
++
;
$sFilename
=
"$sPackageName"
.
"_$nCount"
;
}
push
(
@sFilenameStack
,
$sFilename
);
$sCurrentFilename
=
$sFilename
.
".cxx"
;
return
$sFilename
;
}
# ------------------------------------------------------------------------------
sub
generateNewPackage
{
my
$sPackageName
=
shift
;
my
$sFilename
=
createFilename
(
$sPackageName
);
open
(
CPPFILE
,
">$sFilename"
)
||
die
"can't create cxx source file"
;
print
CPPFILE
"// autogenerated file with codegen.pl\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
"#include <cppunit/simpleheader.hxx>\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
"namespace $sPackageName\n"
;
print
CPPFILE
"{\n"
;
}
# ------------------------------------------------------------------------------
sub
generateNewClass
{
my
$sClassName
=
shift
;
print
CPPFILE
"\n"
;
print
CPPFILE
"class $sClassName : public CppUnit::TestFixture\n"
;
print
CPPFILE
"{\n"
;
}
# ------------------------------------------------------------------------------
sub
closeMethods
{
# due to the fact, that this is a function based code, not object based
# we have to do some hacks, to prevent us from creating wrong code
if
(
$sCurrentClass
=~
/^$/
||
$sCurrentPackage
=~
/^$/
)
{
return
;
}
# here we create the methods
# first the setUp() and tearDown()
print
CPPFILE
" // initialise your test code values here.\n"
;
print
CPPFILE
" void setUp()\n"
;
print
CPPFILE
" {\n"
;
print
CPPFILE
" }\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
" void tearDown()\n"
;
print
CPPFILE
" {\n"
;
print
CPPFILE
" }\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
" // insert your test code here.\n"
;
if
(
$#sMethodNames
>
0
)
{
# all found methods
foreach
$sMethod
(
@sMethodNames
)
{
print
CPPFILE
" void $sMethod()\n"
;
print
CPPFILE
" {\n"
;
if
(
$bShowDemo
==
1
)
{
print
CPPFILE
" // this is demonstration code\n"
;
print
CPPFILE
" // CPPUNIT_ASSERT_MESSAGE(\"a message\", 1 == 1);\n"
;
$bShowDemo
=
0
;
}
print
CPPFILE
" CPPUNIT_ASSERT_STUB();\n"
;
print
CPPFILE
" }\n"
;
print
CPPFILE
"\n"
;
}
}
else
{
# if no methods found, create at least one
print
CPPFILE
" // this is only demonstration code\n"
;
print
CPPFILE
" void EmptyMethod()\n"
;
print
CPPFILE
" {\n"
;
print
CPPFILE
" // CPPUNIT_ASSERT_MESSAGE(\"a message\", 1 == 1);\n"
;
print
CPPFILE
" CPPUNIT_ASSERT_STUB();\n"
;
print
CPPFILE
" }\n"
;
print
CPPFILE
"\n"
;
}
# create the autoregister code
print
CPPFILE
" // Change the following lines only, if you add, remove or rename \n"
;
print
CPPFILE
" // member functions of the current class, \n"
;
print
CPPFILE
" // because these macros are need by auto register mechanism.\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
" CPPUNIT_TEST_SUITE($sCurrentClass);\n"
;
push
(
@sClassNameStack
,
$sCurrentClass
);
my
$nCount
=
0
;
if
(
$#sMethodNames
>
0
)
{
foreach
$sMethod
(
@sMethodNames
)
{
print
CPPFILE
" CPPUNIT_TEST($sMethod);\n"
;
$nCount
++
;
}
# empty the method list
my
$i
;
for
(
$i
=
0
;
$i
<
$nCount
;
$i
++
)
{
pop
(
@sMethodNames
);
}
}
else
{
print
CPPFILE
" CPPUNIT_TEST(EmptyMethod);\n"
;
}
print
CPPFILE
" CPPUNIT_TEST_SUITE_END();\n"
;
}
# ------------------------------------------------------------------------------
sub
closeClass
{
# my $sClassName = shift;
if
(
$sCurrentClass
=~
/^$/
)
{
return
;
}
print
CPPFILE
"}; // class $sCurrentClass\n"
;
print
CPPFILE
"\n"
;
$sCurrentClass
=
""
;
}
# ------------------------------------------------------------------------------
sub
closePackage
{
# my $sPackageName = shift;
if
(
$sCurrentPackage
=~
/^$/
)
{
return
;
}
# create the autoregister code
print
CPPFILE
"// -----------------------------------------------------------------------------\n"
;
my
$nCount
=
0
;
foreach
$sClassName
(
@sClassNameStack
)
{
print
CPPFILE
"CPPUNIT_TEST_SUITE_NAMED_REGISTRATION($sCurrentPackage"
.
"::"
.
"$sClassName, \"$sCurrentPackage\");\n"
;
$nCount
++
;
}
# empty the method list
my
$i
;
for
(
$i
=
0
;
$i
<
$nCount
;
$i
++
)
{
pop
(
@sClassNameStack
);
}
print
CPPFILE
"} // namespace $sCurrentPackage\n"
;
print
CPPFILE
"\n"
;
print
CPPFILE
"
// -----------------------------------------------------------------------------
// this macro creates an empty function, which will called by the RegisterAllFunctions()
// to let the user the possibility to also register some functions by hand.
NOADDITIONAL;
"
;
print
CPPFILE
"\n"
;
close
(
CPPFILE
);
push
(
@sPackageStack
,
$sCurrentPackage
);
$sCurrentPackage
=
""
;
}
# ------------------------------------------------------------------------------
# sub generateCppSource
# {
# my $sPackageName = shift;
# my $sClassName = shift;
# my $sMethodName = shift;
#
#
# open(CPPFILE, ">$sFilename") || die "can't create cxx source file";
# print CPPFILE "// autogenerated file\n";
# close(CPPFILE);
# }
# ------------------------------------------------------------------------------
sub
walkThroughJobFile
{
my
$filename
=
shift
;
open
(
FILE
,
$filename
)
||
die
"can't open $filename\n"
;
while
(
$line
=
<
FILE
>
)
{
chomp
(
$line
);
# DOS Hack grrrr...
while
(
$line
=~
/ $/
)
{
$line
=
substr
(
$line
,
0
,
-
1
);
}
if
(
$line
=~
/^\#/
||
$line
=~
/^$/
)
{
# remark or empty line
}
else
{
if
(
$line
=~
/^\w+/
)
# must start with a word character
{
# print "$line\n";
my
(
$sPackageName
,
$sClassName
,
$sMethodName
);
(
$sPackageName
,
$sClassName
,
$sMethodName
)
=
split
(
/\./
,
$line
);
if
(
$sClassName
=~
/^$/
)
{
print
"error: in $line, no class name exist.\n"
;
}
# test if it also works without methods
# elsif ($sMethodName =~ /^$/)
# {
# print "error: in $line, no method name exist.\n";
# }
else
{
if
(
$sMethodName
=~
/^$/
)
{
print
"warning: in $line, no method name exist, create only on pseudo member function.\n"
;
}
print
"$sPackageName :: $sClassName :: $sMethodName\n"
;
if
(
$sCurrentPackage
ne
$sPackageName
)
{
closeMethods
();
closeClass
();
closePackage
();
$sCurrentPackage
=
$sPackageName
;
generateNewPackage
(
$sPackageName
);
}
if
(
$sCurrentClass
ne
$sClassName
)
{
closeMethods
();
closeClass
();
$sCurrentClass
=
$sClassName
;
generateNewClass
(
$sClassName
);
}
push
(
@sMethodNames
,
$sMethodName
);
}
}
}
}
closeMethods
();
closeClass
();
closePackage
();
close
(
FILE
);
# generate makefile
generateMakefileEntry
(
"test"
);
}
# ------------------------------------------------------------------------------
sub
generateMakefileEntry
{
my
$sTargetName
=
shift
;
my
$nNumber
;
$nNumber
=
1
;
open
(
MAKEFILE
,
">makefile.add"
)
||
die
"can't open makefile.add"
;
print
MAKEFILE
"SHL"
.
$nNumber
.
"OBJS= "
;
foreach
$sFilename
(
@sFilenameStack
)
{
print
MAKEFILE
" \\\n"
;
print
MAKEFILE
" \$(SLO)\$/$sFilename.obj"
;
}
print
MAKEFILE
"\n\n"
;
# targetname
print
MAKEFILE
"SHL"
.
$nNumber
.
"TARGET= $sTargetName\n"
;
# additional libraries
print
MAKEFILE
"SHL"
.
$nNumber
.
"STDLIBS=\\\n"
;
print
MAKEFILE
" \$(SALLIB) \n"
;
# link static cppunit library
print
MAKEFILE
".IF \"\$(GUI)\" == \"WNT\"\n"
;
print
MAKEFILE
"SHL"
.
$nNumber
.
"STDLIBS+= \$(SOLARLIBDIR)\$/cppunit.lib\n"
;
print
MAKEFILE
".ENDIF\n"
;
print
MAKEFILE
".IF \"\$(GUI)\" == \"UNX\"\n"
;
print
MAKEFILE
"SHL"
.
$nNumber
.
"STDLIBS+=\$(SOLARLIBDIR)\$/libcppunit\$(DLLPOSTFIX).a\n"
;
print
MAKEFILE
".ENDIF\n"
;
print
MAKEFILE
"\n"
;
print
MAKEFILE
"SHL"
.
$nNumber
.
"IMPLIB= i\$(SHL"
.
$nNumber
.
"TARGET)\n"
;
print
MAKEFILE
"SHL"
.
$nNumber
.
"DEF= \$(MISC)\$/\$(SHL"
.
$nNumber
.
"TARGET).def\n"
;
print
MAKEFILE
"\n"
;
# DEF name
print
MAKEFILE
"DEF"
.
$nNumber
.
"NAME =\$(SHL"
.
$nNumber
.
"TARGET)\n"
;
print
MAKEFILE
"DEF"
.
$nNumber
.
"EXPORTFILE= export.exp\n"
;
close
(
MAKEFILE
);
if
(
!
-
e
"export.exp"
)
{
open
(
EXPORTEXP
,
">export.exp"
)
||
die
"can't create export.exp"
;
print
EXPORTEXP
"registerAllTestFunction\n"
;
close
(
EXPORTEXP
);
}
}
# -------------------------------- main function --------------------------------
sub
main
{
if
(
$#ARGV
<
0
)
{
usage
();
}
my
$jobfile
=
$ARGV
[
0
];
print
"Test code generator\n"
;
walkThroughJobFile
(
$jobfile
);
}
# ------------------------------------------------------------------------------
main
();
testshl2/source/dynamicregister.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include "dynamicregister.hxx"
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
// #include <osl/mutex.hxx>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include "filehelper.hxx"
// -----------------------------------------------------------------------------
DynamicLibraryHelper
::
DynamicLibraryHelper
(
rtl
::
OUString
const
&
_sDLLName
,
GetOpt
&
_aOptions
)
:
m_pModule
(
new
::
osl
::
Module
()),
m_suDLLName
(
_sDLLName
),
m_aOptions
(
_aOptions
)
{
// create and load the module (shared library)
if
(
!
m_pModule
->
load
(
FileHelper
::
convertPath
(
_sDLLName
)
))
{
rtl
::
OString
sDLLName
=
rtl
::
OUStringToOString
(
_sDLLName
,
RTL_TEXTENCODING_ASCII_US
);
fprintf
(
stderr
,
"warning: Can't load module '%s'.
\n
"
,
sDLLName
.
getStr
());
}
}
DynamicLibraryHelper
::~
DynamicLibraryHelper
()
{
delete
m_pModule
;
}
testshl2/source/file.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
// -----------------------------------------------------------------------------
// taken from setup2
std
::
string
getTempPath
()
{
std
::
string
sTempDir
;
char
*
pTmp
=
getenv
(
"TEMP"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"temp"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"TMP"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"tmp"
);
if
(
pTmp
&&
strlen
(
pTmp
)
>=
2
)
{
sTempDir
=
std
::
string
(
pTmp
);
}
else
{
#ifdef UNX
int
nLen
;
pTmp
=
P_tmpdir
;
nLen
=
strlen
(
pTmp
);
if
(
pTmp
[
nLen
-
1
]
==
'/'
)
{
char
cBuf
[
256
];
char
*
pBuf
=
cBuf
;
strncpy
(
pBuf
,
pTmp
,
nLen
-
1
);
pBuf
[
nLen
-
1
]
=
'\0'
;
sTempDir
=
std
::
string
(
pBuf
);
}
else
{
sTempDir
=
std
::
string
(
pTmp
);
}
#else
fprintf
(
stderr
,
"error: No temp dir found.
\n
"
);
#endif
}
return
sTempDir
;
}
testshl2/source/filehelper.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "filehelper.hxx"
#include "getopt.hxx"
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _SAL_TRES_H_
#include <rtl/tres.h>
#endif
namespace
FileHelper
{
// -----------------------------------------------------------------------------
// taken from setup2
std
::
string
getTempPath
()
{
std
::
string
sTempDir
;
char
*
pTmp
=
getenv
(
"TEMP"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"temp"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"TMP"
);
if
(
pTmp
==
NULL
)
pTmp
=
getenv
(
"tmp"
);
if
(
pTmp
&&
strlen
(
pTmp
)
>=
2
)
{
sTempDir
=
std
::
string
(
pTmp
);
}
else
{
#ifdef UNX
int
nLen
;
pTmp
=
P_tmpdir
;
nLen
=
strlen
(
pTmp
);
if
(
pTmp
[
nLen
-
1
]
==
'/'
)
{
char
cBuf
[
256
];
char
*
pBuf
=
cBuf
;
strncpy
(
pBuf
,
pTmp
,
nLen
-
1
);
pBuf
[
nLen
-
1
]
=
'\0'
;
sTempDir
=
std
::
string
(
pBuf
);
}
else
{
sTempDir
=
std
::
string
(
pTmp
);
}
#else
fprintf
(
stderr
,
"error: No temp dir found.
\n
"
);
#endif
}
return
sTempDir
;
}
// -----------------------------------------------------------------------------
rtl
::
OUString
convertPath
(
rtl
::
OUString
const
&
_suSysPath
)
{
// PRE: String should contain a filename, relativ or absolut
rtl
::
OUString
fURL
;
if
(
_suSysPath
.
indexOf
(
rtl
::
OUString
::
createFromAscii
(
".."
))
!=
-
1
)
{
// filepath contains '..' so it's a relative path make it absolut.
rtl
::
OUString
curDirPth
;
osl_getProcessWorkingDir
(
&
curDirPth
.
pData
);
osl
::
FileBase
::
getAbsoluteFileURL
(
curDirPth
,
_suSysPath
,
fURL
);
}
else
{
osl
::
FileBase
::
getFileURLFromSystemPath
(
_suSysPath
,
fURL
);
}
return
fURL
;
}
// -----------------------------------------------------------------------------
rtl
::
OUString
convertPath
(
rtl
::
OString
const
&
sysPth
)
{
rtl
::
OUString
sysPath
(
rtl
::
OUString
::
createFromAscii
(
sysPth
.
getStr
()
)
);
return
convertPath
(
sysPath
);
}
/**
* create bitmap of comandline parameters
*/
//# CmdLineBits createFlags( vector< sal_Char* > const& cmdln )
//# {
//# CmdLineBits retflags = rtl_tres_Flag_OK;
//#
//# vector< sal_Char* >::const_iterator iter = cmdln.begin();
//# while( iter != cmdln.end() )
//# {
//# fprintf( stderr, "%s\n", *iter );
//# if ( *iter[0] == '-' )
//# {
//# rtl::OString item( *iter );
//# if ( item == "-boom" ) // stop near error position, exception only
//# retflags |= rtl_tres_Flag_BOOM;
//#
//# if ( item == "-verbose" )
//# retflags |= rtl_tres_Flag_VERBOSE;
//#
//# if ( item == "-skip" )
//# retflags |= rtl_tres_Flag_SKIP;
//#
//# if ( item == "-log" )
//# retflags |= rtl_tres_Flag_LOG;
//#
//# if ( item == "-his" )
//# retflags |= rtl_tres_Flag_HIS;
//#
//# if ( item == "-time" )
//# retflags |= rtl_tres_Flag_TIME;
//#
//# if ( item == "-msg" )
//# retflags |= rtl_tres_Flag_MSG;
//# }
//# iter++;
//# }
//#
//# return retflags;
//# }
//#
//# CmdLineBits createFlags(int argc, char* argv[])
//# {
//# vector< sal_Char* > cmdln;
//# sal_Int32 i;
//#
//# /* collect comandline */
//# for ( i = 1; i < argc; i++ )
//# cmdln.push_back( argv[i] );
//#
//# return createFlags(cmdln);
//# }
CmdLineBits
createFlags
(
GetOpt
&
_aOptions
)
{
CmdLineBits
retflags
=
rtl_tres_Flag_OK
;
if
(
_aOptions
.
hasOpt
(
"-boom"
))
// stop near error position, exception only
{
retflags
|=
rtl_tres_Flag_BOOM
;
}
return
retflags
;
}
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
//# void usage()
//# {
//# fprintf( stdout,
//# "USAGE: testshl shlname [-boom][-verbose][-log][-his][-msg]\n" );
//# exit(0);
//# }
}
// namespace FileHelper
testshl2/source/getopt.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
/*************************************************************************
#*
#* $RCSfile: getopt.cxx,v $
#*
#* class classname(s)
#*
#* Description perl-like commandline processor
#* (see description in headerfile)
#*
#* Creation Date Stefan Zimmermann 09/15/2000
#* last change $Author: lla $ $Date: 2003-01-09 11:06:02 $
#* $Revision: 1.1 $
#*
#* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
#*
#*************************************************************************
Source Code Control System - Header
$Header: /zpool/svn/migration/cvs_rep_09_09_08/code/testshl2/source/getopt.cxx,v 1.1 2003-01-09 11:06:02 lla Exp $
Source Code Control System - Update
*************************************************************************/
#ifndef __QADEV_REGSCAN_GETOPT_HXX__
#include "getopt.hxx"
#endif
#include "filehelper.hxx"
//----------------------------------------------------------------------------
// OptDsc
//----------------------------------------------------------------------------
//> createOptDsc
void
OptDsc
::
createOptDsc
(
const
rtl
::
OString
&
opt
)
{
// analyze type of option
// in case of flag indicate and set name and hint
if
(
(
opt
.
indexOf
(
"="
)
==
-
1
)
&&
(
opt
.
indexOf
(
":"
)
==
-
1
)
)
{
m_type
=
OT_BOOL
;
// extract options dokumentation if any
sal_Int32
index
=
opt
.
indexOf
(
","
);
if
(
index
==
-
1
)
{
m_name
=
opt
;
}
else
{
m_name
=
opt
.
copy
(
0
,
index
);
m_hint
=
(
opt
.
copy
(
index
+
1
)
).
trim
();
}
return
;
}
vector
<
rtl
::
OString
>
optLine
;
// ':' indicates that option has optional parameter(s)
if
(
opt
.
indexOf
(
":"
)
!=
-
1
)
{
m_type
|=
OT_OPTIONAL
;
// create optionline tokenvector
split
(
opt
,
":,"
,
optLine
);
}
else
{
// create optionline tokenvector
split
(
opt
,
"=,"
,
optLine
);
}
// extract name of option
m_name
=
optLine
[
0
];
// parameter(s) of string type
if
(
optLine
[
1
].
indexOf
(
"s"
)
!=
-
1
)
{
m_type
|=
OT_STRING
;
m_legend
+=
"arg"
;
}
// parameter(s) of numeric type
if
(
optLine
[
1
].
indexOf
(
"n"
)
!=
-
1
)
{
m_type
|=
OT_NUMBER
;
m_legend
+=
"arg"
;
}
// multiple parameters allowed
if
(
optLine
[
1
].
indexOf
(
"@"
)
!=
-
1
)
{
m_type
|=
OT_MULTI
;
m_legend
+=
"#1,[arg#n]"
;
}
else
{
m_type
|=
OT_SINGLE
;
}
// extract options dokumentation if any
m_hint
=
optLine
[
optLine
.
size
()
-
1
].
trim
();
}
///< createOptDsc
//> split
void
OptDsc
::
split
(
const
rtl
::
OString
&
opt
,
const
rtl
::
OString
&
cSet
,
vector
<
rtl
::
OString
>&
optLine
)
{
const
sal_Int32
cSetLen
=
cSet
.
getLength
();
const
sal_Char
*
pcSet
=
cSet
.
getStr
();
sal_Int32
index
=
0
;
sal_Int32
oldIndex
=
0
;
sal_Int32
i
;
for
(
i
=
0
;
i
<
cSetLen
;
i
++
)
{
index
=
opt
.
indexOf
(
pcSet
[
i
]
);
if
(
index
!=
-
1
)
{
optLine
.
push_back
(
opt
.
copy
(
oldIndex
,
index
-
oldIndex
)
);
oldIndex
=
index
+
1
;
}
}
optLine
.
push_back
(
opt
.
copy
(
oldIndex
)
);
}
///< split
//----------------------------------------------------------------------------
// GetOpt
//----------------------------------------------------------------------------
//> ~GetOpt
GetOpt
::~
GetOpt
()
{
vector
<
OptDsc
*
>::
iterator
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
delete
(
*
iter
);
(
*
iter
)
=
0
;
iter
++
;
}
m_optionset
.
clear
();
}
///< ~GetOpt
/**
* private
* initialization of GetOpt class means to fill the vector members
* representing the commandline and optionset
* @param char* cmdLine[] = comandline
* @param char* optSet[] = optionset
*
* @return void
*/
//> initialize
void
GetOpt
::
initialize
(
char
*
cmdLine
[],
char
*
optSet
[]
)
{
while
(
*
cmdLine
)
{
m_cmdline
.
push_back
(
rtl
::
OString
(
*
cmdLine
)
);
*
cmdLine
++
;
}
// insert an empty OString, to mark the end.
m_cmdline
.
push_back
(
rtl
::
OString
());
while
(
*
optSet
&&
(
rtl
::
OString
(
optSet
[
0
]
).
indexOf
(
"-"
)
!=
-
1
)
)
{
m_optionset
.
push_back
(
new
OptDsc
(
*
optSet
)
);
*
optSet
++
;
}
}
///< initialize
/**
* public
* returns a pointer to an object of type optiondescription (OptDsc)
*
* @param rtl::OString& opt = name of option
*
* @return OptDsc* = pointer to requested optiondescription
* or NULL if not found
*/
//> getOptDsc
OptDsc
*
GetOpt
::
getOptDsc
(
rtl
::
OString
&
opt
)
{
vector
<
OptDsc
*
>::
iterator
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
if
(
(
*
iter
)
->
getName
()
==
opt
)
{
return
(
*
iter
);
}
iter
++
;
}
return
NULL
;
}
///< getOptDsc
/**
* public
* check if option is already present in optionhash
* @param const rtl::OString& opt = name of option
* @return sal_Bool
*/
//> hasOpt
sal_Bool
GetOpt
::
hasOpt
(
const
rtl
::
OString
&
opt
)
const
{
if
(
m_opthash
.
find
(
opt
)
!=
m_opthash
.
end
()
)
{
return
sal_True
;
}
return
sal_False
;
}
///< hasOpt
/**
* private
* handles the initialized comandline vector
* and fill the optionhash with evaluated options
* @param none
* @return void
*/
//> createCmdLineOptions
void
GetOpt
::
createCmdLineOptions
()
{
// get iterator of comandline vector
vector
<
rtl
::
OString
>::
iterator
iter
=
m_cmdline
.
begin
();
int
nSize
=
m_cmdline
.
size
();
// process the whole vector
while
(
iter
!=
m_cmdline
.
end
()
)
{
// extract first comandlineparameter as program name
if
(
(
*
iter
)
==
m_cmdline
.
front
()
)
{
m_prgname
=
(
*
iter
);
iter
++
;
continue
;
}
// extract following comandline parameter(s) as program parameter(s)
if
(
(
(
*
iter
)
!=
m_cmdline
.
front
()
)
&&
/* not first parameter */
(
(
*
iter
).
indexOf
(
"-"
)
==
-
1
)
/* start without '-' */
)
{
if
((
*
iter
).
getLength
()
>
0
)
/* is not empty */
m_param
.
push_back
(
*
iter
);
iter
++
;
continue
;
}
// option occured
if
(
(
*
iter
).
indexOf
(
"-"
)
!=
-
1
)
{
// ignore invalid options
if
(
!
evaluateOpt
(
iter
)
)
{
iter
++
;
// check if wrong option has got a parameter
// and skip that, too
if
(
(
iter
+
1
)
!=
m_cmdline
.
end
()
)
{
if
(
(
*
(
iter
+
1
)).
indexOf
(
"-"
)
==
-
1
)
{
iter
++
;
}
}
continue
;
}
rtl
::
OString
opt
(
(
*
iter
)
);
vector
<
rtl
::
OString
>
optValues
;
// option is no flag
if
(
!
getOptDsc
(
opt
)
->
isFlag
()
)
{
// but has optional parameters
if
(
getOptDsc
(
opt
)
->
isOptional
()
)
{
// no parameters present
if
(
!
hasParam
(
iter
)
)
{
m_opthash
[
opt
]
=
optValues
;
optValues
.
clear
();
iter
++
;
continue
;
}
}
iter
++
;
// more than one option parameters occured
if
(
(
*
iter
).
indexOf
(
","
)
!=
-
1
)
{
tokenize
(
(
*
iter
),
","
,
optValues
);
}
else
{
optValues
.
push_back
(
(
*
iter
)
);
}
}
// create key/value pair in optionhash and clear value vector
m_opthash
[
opt
]
=
optValues
;
optValues
.
clear
();
}
iter
++
;
}
}
///< createCmdLineOptions
/**
* public
* check if option has parameter(s)
* @param vector< rtl::OString >::iterator iter = iterator of
* comandline vector
*
* @return sal_Bool
*/
//> hasParam
sal_Bool
GetOpt
::
hasParam
(
vector
<
rtl
::
OString
>::
iterator
iter
)
{
if
(
iter
+
1
==
m_cmdline
.
end
()
)
{
return
sal_False
;
}
if
(
(
*
(
iter
+
1
)).
indexOf
(
"-"
)
==
0
)
{
return
sal_False
;
}
if
(
(
*
(
iter
+
1
))
==
""
)
{
return
sal_False
;
}
return
sal_True
;
}
///< hasParam
/**
* public
* option evaluation in general means to verify if the option occur is
* a member of optionset say an admitted option, if so does it appear with
* the right or tolerable usage
*
* @param vector< rtl::OString >::iterator iter = iterator of
* comandline vector
*
* @return sal_Bool
*/
//> evaluateOpt
sal_Bool
GetOpt
::
evaluateOpt
(
vector
<
rtl
::
OString
>::
iterator
iter
)
{
// option is no member of optionset
if
(
!
exist
(
(
*
iter
)
)
)
{
cout
<<
"Unknown option "
<<
(
*
iter
).
getStr
()
<<
" occurred !"
<<
endl
;
return
sal_False
;
}
// option is a flag
if
(
getOptDsc
(
(
*
iter
)
)
->
isFlag
()
)
{
return
sal_True
;
}
// parameter not optional
if
(
!
getOptDsc
(
(
*
iter
)
)
->
isOptional
()
)
{
// verify that next vectoritem is present and no option
if
(
(
*
(
iter
+
1
)
).
getLength
()
&&
(
(
*
(
iter
+
1
)
).
indexOf
(
"-"
)
!=
0
)
)
{
// if we are waiting for one single parameter
if
(
getOptDsc
(
*
iter
)
->
isSingle
()
)
{
// but find multiple parameters
if
(
(
*
(
iter
+
1
)
).
indexOf
(
","
)
!=
-
1
)
{
cout
<<
"Wrong use of option "
<<
(
*
iter
).
getStr
()
<<
" too many parameters !"
<<
endl
;
return
sal_False
;
}
return
sal_True
;
}
return
sal_True
;
}
cout
<<
"Wrong use of option "
<<
(
*
iter
).
getStr
()
<<
" parameter missing !"
<<
endl
;
return
sal_False
;
}
// parameter optional
if
(
getOptDsc
(
*
iter
)
->
isSingle
()
)
{
if
(
hasParam
(
iter
)
)
{
if
(
(
*
(
iter
+
1
)
).
indexOf
(
","
)
!=
-
1
)
{
cout
<<
"Wrong use of option "
<<
(
*
iter
).
getStr
()
<<
" too many parameters !"
<<
endl
;
return
sal_False
;
}
}
}
return
sal_True
;
}
///< evaluateOpt
//> createOpt
void
GetOpt
::
createOpt
(
rtl
::
OString
&
optDscStr
)
{
m_optionset
.
push_back
(
new
OptDsc
(
optDscStr
)
);
}
///< createOpt
/**
* public
* conditional addition of an option to optionhash
* overriding options, already present in optionhash, is not permitted
*
* @param rtl::OString& optStr = optionstring which is to break in a
* key/value pair and to add to optionhash
*
* @return void
*/
//> addOpt
void
GetOpt
::
addOpt
(
rtl
::
OString
&
optStr
,
sal_Bool
eval
)
{
vector
<
rtl
::
OString
>
optTok
;
tokenize
(
optStr
,
"="
,
optTok
);
// prevent override of commandline options
// by options from ini file
if
(
hasOpt
(
optTok
[
0
]
)
)
{
return
;
}
// evaluate rigth usage of option
if
(
eval
)
{
if
(
!
evaluateOpt
(
optTok
.
begin
()
)
)
{
return
;
}
}
vector
<
rtl
::
OString
>
optValues
;
if
(
optTok
.
size
()
>
1
)
{
rtl
::
OString
oValStr
(
optTok
[
1
]
);
// found a variable
if
(
oValStr
.
indexOf
(
","
)
==
-
1
)
{
optValues
.
push_back
(
oValStr
);
}
else
{
tokenize
(
oValStr
,
","
,
optValues
);
}
}
m_opthash
[
optTok
[
0
]
]
=
optValues
;
optValues
.
clear
();
return
;
}
///< addOpt
/**
* public
* verify the existance of an option in optionset
* @param rtl::OString& opt = option name
* @return sal_Bool
*/
//> exist
sal_Bool
GetOpt
::
exist
(
rtl
::
OString
&
opt
)
{
if
(
getOptDsc
(
opt
)
)
{
return
sal_True
;
}
return
sal_False
;
}
///< exist
/**
* public
* verify the existance of variables inside options
* @param none
* @return sal_Bool
*/
//> hasVars
sal_Bool
GetOpt
::
hasVars
()
{
if
(
m_varvec
.
size
()
)
{
return
sal_True
;
}
return
sal_False
;
}
///< hasVars
/**
* public
* proceeds a buffer representing the content of an ini file and adds the
* options to optionhash. The optionstrings in the file are allowed to contain
* variables indicated by delimiters described with varDelim
*
* @param rtl::OString iOpts = raw filecontent
* @param const rtl::OString& varDelim = delimiter indicating a variable
*
* @return void
*/
//> str2Opt
void
GetOpt
::
str2Opt
(
rtl
::
OString
iOpts
)
{
// tokenize filecontent by '\n' to create a vector of lines
vector
<
rtl
::
OString
>
iniLines
;
tokenize
(
iOpts
,
"
\n
"
,
iniLines
);
sal_uInt32
tCnt
=
iniLines
.
size
();
// process all lines
sal_uInt32
i
;
for
(
i
=
1
;
i
<
tCnt
;
i
++
)
{
rtl
::
OString
optLine
(
iniLines
[
i
]
);
// ignore comments
if
(
!
(
optLine
.
indexOf
(
"#"
)
==
0
)
)
{
// filter valid options after trim
if
(
(
optLine
.
indexOf
(
"-"
)
==
0
)
)
{
// line contains a variable
if
(
(
optLine
.
indexOf
(
m_vardelim
)
!=
-
1
)
)
{
// push to var vector for later process
m_varvec
.
push_back
(
optLine
);
continue
;
}
addOpt
(
optLine
);
}
}
}
}
///< str2opt
void
GetOpt
::
replVars
()
{
// process vector of lines containing variables
vector
<
rtl
::
OString
>::
iterator
iter
=
m_varvec
.
begin
();
while
(
iter
!=
m_varvec
.
end
()
)
{
sal_uInt32
index
=
0
;
while
(
(
index
=
(
*
iter
).
indexOf
(
m_vardelim
)
)
!=
-
1
)
{
vector
<
rtl
::
OString
>
varLineTok
;
rtl
::
OString
varKey
(
"-"
);
tokenize
(
*
iter
,
m_vardelim
,
varLineTok
);
varKey
+=
varLineTok
[
1
];
vector
<
rtl
::
OString
>
keyValues
=
getOptVec
(
varKey
);
if
(
keyValues
.
size
()
>
1
)
{
rtl
::
OString
rplStr
;
vector
<
rtl
::
OString
>::
iterator
kvi
=
keyValues
.
begin
();
while
(
kvi
!=
keyValues
.
end
()
)
{
rplStr
+=
(
*
kvi
);
kvi
++
;
if
(
kvi
!=
keyValues
.
end
()
)
{
rplStr
+=
","
;
}
}
(
*
iter
)
=
(
*
iter
).
replaceAt
(
index
,
varKey
.
getLength
()
+
1
,
rplStr
);
}
else
{
if
(
*
(
keyValues
[
0
]))
{
(
*
iter
)
=
(
*
iter
).
replaceAt
(
index
,
varKey
.
getLength
()
+
1
,
keyValues
[
0
]
);
}
}
}
addOpt
(
(
*
iter
)
);
iter
++
;
}
}
/**
* public
* displays a formatted usagescreen
* @param none
* @return void
*/
//> showUsage
void
GetOpt
::
showUsage
()
{
sFormat
frm
;
frm
.
fCol
=
getMaxNameLength
()
+
2
;
frm
.
sCol
=
frm
.
fCol
+
getMaxLegendLength
()
+
2
;
frm
.
len
=
79
;
vector
<
rtl
::
OString
>
nameVec
;
vector
<
rtl
::
OString
>
paramVec
;
tokenize
(
getName
(),
"/
\\
"
,
nameVec
);
if
(
m_param
.
empty
()
)
{
if
(
hasOpt
(
"-db"
)
)
{
tokenize
(
getOpt
(
"-db"
),
"/
\\
"
,
paramVec
);
}
else
{
paramVec
.
push_back
(
rtl
::
OString
(
"not available"
)
);
}
}
else
{
tokenize
(
getFirstParam
(),
"/
\\
"
,
paramVec
);
}
cout
<<
"
\n\n\n\n\n
Usage: prgname param [options]
\n\n
PRGNAME = [path]"
;
if
(
nameVec
.
end
()
)
{
cout
<<
(
*
(
nameVec
.
end
()
-
1
)).
getStr
();
}
cout
<<
"
\n
PARAM = [path]"
;
if
(
paramVec
.
end
()
)
{
cout
<<
(
*
(
paramVec
.
end
()
-
1
)).
getStr
()
<<
endl
;
}
cout
<<
"
\n
OPTIONS = ["
<<
flush
;
vector
<
OptDsc
*
>::
iterator
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
cout
<<
(
*
iter
)
->
getName
().
getStr
()
<<
","
<<
flush
;
iter
++
;
}
cout
<<
"]
\n\n
OPTIONS:
\n
"
<<
flush
;
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
cout
<<
optDsc2Str
(
*
iter
,
frm
).
getStr
()
<<
endl
<<
flush
;
iter
++
;
}
}
///< showUsage
/**
* public
* displays the actual option/parameter status
* @param none
* @return void
*/
//> printStatus
void
GetOpt
::
printStatus
(
void
)
{
sal_uInt32
maxlen
=
getMaxNameLength
();
optHashMap
::
iterator
iter
=
m_opthash
.
begin
();
cout
<<
endl
;
while
(
iter
!=
m_opthash
.
end
()
)
{
rtl
::
OString
option
(
(
*
iter
).
first
);
cout
.
setf
(
ios
::
left
);
cout
.
width
(
maxlen
+
1
);
cout
<<
option
.
getStr
()
<<
"= "
;
if
(
!
getOptDsc
(
option
)
->
isFlag
()
)
{
if
(
!
getOptVec
(
option
).
empty
()
)
{
sal_uInt32
j
;
for
(
j
=
0
;
j
<
(
*
iter
).
second
.
size
();
j
++
)
{
cout
<<
((
(
*
iter
).
second
)[
j
]).
getStr
()
<<
" "
;
}
cout
<<
endl
;
}
else
{
cout
<<
"FALSE
\n
"
;
}
}
else
{
cout
<<
"TRUE
\n
"
;
}
iter
++
;
}
}
/**
* private
* converts an object of type optiondescription (OptDsc) to a formatted
* displayable string for usagescreen needs
* @param OptDsc* optDsc = pointer to option description
* @param sFormat frm = format structur
*
* @return const rtl::OString = formatted string for display purposes
*/
//> optDsc2Str >>> to be replaced by intelliget algorythm <<<
const
rtl
::
OString
GetOpt
::
optDsc2Str
(
OptDsc
*
optDsc
,
sFormat
frm
)
{
sal_Char
*
buf
=
new
sal_Char
[
frm
.
len
+
1
];
sal_Char
*
pBuf
=
buf
;
sal_uInt32
i
;
for
(
i
=
0
;
i
<
frm
.
len
;
i
++
)
{
*
pBuf
++
=
' '
;
}
*
pBuf
=
'\0'
;
rtl
::
OStringBuffer
strBuf
(
buf
);
rtl
::
OString
oStr
=
strBuf
.
makeStringAndClear
();
oStr
=
oStr
.
replaceAt
(
0
,
optDsc
->
getName
().
getLength
(),
optDsc
->
getName
()
);
if
(
optDsc
->
isOptional
()
)
{
oStr
=
oStr
.
replaceAt
(
frm
.
fCol
-
1
,
1
,
"["
);
}
oStr
=
oStr
.
replaceAt
(
frm
.
fCol
,
optDsc
->
getLegend
().
getLength
(),
optDsc
->
getLegend
()
);
if
(
optDsc
->
isOptional
()
)
{
oStr
=
oStr
.
replaceAt
(
frm
.
fCol
+
optDsc
->
getLegend
().
getLength
()
,
1
,
"]"
);
}
if
(
(
frm
.
sCol
+
optDsc
->
getHint
().
getLength
()
)
>=
frm
.
len
)
{
oStr
=
oStr
.
replaceAt
(
frm
.
sCol
,
frm
.
len
-
frm
.
sCol
,
optDsc
->
getHint
()
);
}
else
{
oStr
=
oStr
.
replaceAt
(
frm
.
sCol
,
optDsc
->
getHint
().
getLength
(),
optDsc
->
getHint
()
);
}
delete
(
buf
);
return
oStr
;
}
///< optDsc2Str
/**
* private
* returns the maximum length of all optionnames for format purposes
* @param none
* @return sal_uInt32 length of longest optionname
*/
//> getMaxNameLength
sal_uInt32
GetOpt
::
getMaxNameLength
()
{
sal_Int32
len
=
0
;
vector
<
OptDsc
*
>::
iterator
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
if
(
len
<
(
*
iter
)
->
getName
().
getLength
()
){
len
=
(
*
iter
)
->
getName
().
getLength
();
}
iter
++
;
}
return
len
;
}
///< getMaxNameLength
/**
* private
* returns the maximum length of all option legends for format purposes
* @param none
* @return sal_uInt32 length of longest optionlegend
*/
//> getMaxLegendLength
sal_uInt32
GetOpt
::
getMaxLegendLength
()
{
sal_Int32
len
=
0
;
vector
<
OptDsc
*
>::
iterator
iter
=
m_optionset
.
begin
();
while
(
iter
!=
m_optionset
.
end
()
)
{
if
(
len
<
(
*
iter
)
->
getLegend
().
getLength
()
){
len
=
(
*
iter
)
->
getLegend
().
getLength
();
}
iter
++
;
}
return
len
;
}
///< getMaxLegendLength
/**
* public
* reads the filecontent and pass it to str2opt to add valid options
* to optionhash
* @param rtl::OString iniPth = full qualified filename
* @return ::osl::FileBase::RC = to indicate errors
*/
//> getIniOptions
::
osl
::
FileBase
::
RC
GetOpt
::
getIniOptions
(
rtl
::
OString
iniPth
)
{
::
osl
::
FileStatus
fState
(
FileStatusMask_All
);
::
osl
::
DirectoryItem
dItem
;
rtl
::
OUString
nrmPath
(
FileHelper
::
convertPath
(
iniPth
)
);
::
osl
::
DirectoryItem
::
get
(
nrmPath
,
dItem
);
dItem
.
getFileStatus
(
fState
);
rtl
::
OUString
fName
(
fState
.
getFileURL
()
);
::
osl
::
File
iniFile
(
fName
);
const
sal_uInt32
filesize
=
(
sal_uInt32
)
fState
.
getFileSize
();
char
*
buf
=
new
char
[
filesize
+
1
];
::
osl
::
FileBase
::
RC
ret
;
sal_uInt64
bytesread
;
if
(
(
ret
=
iniFile
.
open
(
OpenFlag_Read
)
)
!=
::
osl
::
FileBase
::
E_None
)
{
return
ret
;
}
ret
=
iniFile
.
read
(
buf
,
filesize
,
bytesread
);
buf
[
filesize
]
=
'\0'
;
str2Opt
(
buf
);
delete
[]
buf
;
return
ret
;
}
///< getIniOptions
/**
* private
* tokenize a string in dependance of a character set and stores the tokens
* to a token vector
* @param const rtl::OString& opt = optionstring to tokenize
* @param const rtl::OString& cSet = characterset of delimiters
* @param vector< rtl::OString >& optLine = vector of tokens
* @param sal_Bool strip = indicates if CR,LF and TAB should be stripped off
* the token
* @return void
*/
//> tokenize
void
GetOpt
::
tokenize
(
const
rtl
::
OString
&
opt
,
const
rtl
::
OString
&
cSet
,
vector
<
rtl
::
OString
>&
optLine
,
sal_Bool
strip
)
{
const
sal_Char
*
pText
;
// pointer f. text,
const
sal_Char
*
pcSet
;
// charset and
vector
<
const
sal_Char
*
>
delimVec
;
// vector of delimiters
// parametercheck for opt ...
if
(
!
opt
.
getLength
()
)
{
return
;
}
// ... and charSet
if
(
!
cSet
.
getLength
()
)
{
return
;
}
// pointer to begin of textinstance
pText
=
opt
.
getStr
();
// text
while
(
*
pText
)
{
// charset-pointer to begin of charset
pcSet
=
cSet
.
getStr
();
// charset
while
(
*
pcSet
)
{
// delimiter found
if
(
(
(
*
pText
==
*
pcSet
)
)
&&
(
pText
!=
opt
)
)
{
delimVec
.
push_back
(
pText
);
// increment counter
}
pcSet
++
;
}
// increment pointer
pText
++
;
}
// save endpointer
delimVec
.
push_back
(
opt
+
opt
.
getLength
()
);
sal_Char
*
pToken
;
// ptr to token chars
const
sal_Char
*
pBegin
;
// ptr to begin of current,
const
sal_Char
*
pEnd
=
opt
;
// and begin of prev. token
sal_uInt32
i
=
0
;
while
(
pEnd
<
delimVec
[
delimVec
.
size
()
-
1
]
)
{
pBegin
=
pEnd
;
if
(
pBegin
>
opt
.
getStr
()
)
{
pBegin
+=
1
;
}
pEnd
=
delimVec
[
i
];
// initialize size
sal_uInt32
nSize
=
pEnd
-
pBegin
;
// allocate memory
// allocate memory for token
sal_Char
*
cToken
=
new
sal_Char
[
nSize
+
1
];
// get address of allocated memory
pToken
=
cToken
;
// copy token from text
sal_uInt32
j
;
for
(
j
=
0
;
j
<
nSize
;
++
j
)
{
*
pToken
++
=
*
pBegin
++
;
}
// append string end
*
pToken
=
'\0'
;
rtl
::
OString
oTok
(
cToken
);
if
(
strip
)
{
// strip off CR,LF and TAB
oTok
=
oTok
.
replace
(
0x0a
,
0x20
);
oTok
=
oTok
.
replace
(
0x0d
,
0x20
);
oTok
=
oTok
.
replace
(
0x09
,
0x20
);
oTok
=
oTok
.
trim
();
}
if
(
oTok
!=
""
)
{
// push to vector
optLine
.
push_back
(
oTok
);
}
// free memory where cToken points to
delete
[]
cToken
;
i
++
;
}
return
;
}
///< tokenize
// -----------------------------------------------------------------------------
rtl
::
OString
&
GetOpt
::
getOpt
(
const
rtl
::
OString
&
opt
)
{
if
(
m_opthash
.
find
(
opt
)
!=
m_opthash
.
end
())
{
if
(
m_opthash
[
opt
].
begin
())
{
return
*
(
m_opthash
[
opt
].
begin
()
);
}
rtl
::
OString
aStr
;
aStr
=
"GetOpt( "
;
aStr
+=
opt
;
aStr
+=
" ): Value not found."
;
throw
ValueNotFoundException
(
aStr
.
getStr
());
}
else
throw
ValueNotFoundException
(
opt
);
}
// -----------------------------------------------------------------------------
Exception
::
Exception
()
:
m_sAsciiMessage
()
{
}
//---------------------------------------------------------------------
Exception
::
Exception
(
char
const
*
sAsciiMessage
)
:
m_sAsciiMessage
(
sAsciiMessage
)
{
}
//---------------------------------------------------------------------
Exception
::
Exception
(
rtl
::
OString
const
&
sAsciiMessage
)
:
m_sAsciiMessage
(
sAsciiMessage
)
{
}
//---------------------------------------------------------------------
rtl
::
OUString
Exception
::
message
()
const
{
return
rtl
::
OStringToOUString
(
m_sAsciiMessage
,
RTL_TEXTENCODING_ASCII_US
);
}
//---------------------------------------------------------------------
char
const
*
Exception
::
what
()
const
{
return
m_sAsciiMessage
.
getLength
()
?
m_sAsciiMessage
.
getStr
()
:
"FAILURE in REGSCAN: No description available"
;
}
// -----------------------------------------------------------------------------
static
const
char
c_sValueNotFoundException
[]
=
"GetOpt: Value not Found Exception: "
;
//---------------------------------------------------------------------
ValueNotFoundException
::
ValueNotFoundException
()
:
Exception
(
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
c_sValueNotFoundException
))
)
{
}
//---------------------------------------------------------------------
ValueNotFoundException
::
ValueNotFoundException
(
char
const
*
sException
)
:
Exception
(
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
c_sValueNotFoundException
))
+=
sException
)
{
}
testshl2/source/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:02 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
PRJNAME
=
testshl2
TARGET
=
testshl2
TARGETTYPE
=
CUI
ENABLE_EXCEPTIONS
=
TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# ------------------------------------------------------------------
COMMON_OBJFILES
=
\
$(OBJ)$/
getopt.obj
\
$(OBJ)$/
filehelper.obj
\
$(OBJ)$/
dynamicregister.obj
TESTSHL_OBJFILES
=
\
$(OBJ)$/
autoregisterhelper.obj
\
$(OBJ)$/
testshl.obj
VERSIONER_OBJFILES
=
\
$(OBJ)$/
versionhelper.obj
\
$(OBJ)$/
versioner.obj
# for right dependencies
# OBJFILES= $(COMMON_OBJFILES) $(TESTSHL_OBJFILES) $(VERSIONER_OBJFILES)
# ------------------------------------------------------------------
APP1TARGET
=
$(TARGET)
APP1OBJS
=
$(COMMON_OBJFILES)
$(TESTSHL_OBJFILES)
APP1STDLIBS
=
$(SALLIB)
APP1DEPN
=
\
$(LB)$/
cppunit_no_regallfkt.lib
\
$(SLB)$/
testresult.lib
APP1LIBS
=
\
$(LB)$/
cppunit_no_regallfkt.lib
\
$(SLB)$/
testresult.lib
#
# ------------------------------------------------------------------
APP2TARGET
=
versioner
APP2OBJS
=
$(COMMON_OBJFILES)
$(VERSIONER_OBJFILES)
APP2STDLIBS
=
$(SALLIB)
APP2DEPN
=
APP2LIBS
=
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/source/testshl.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
/*************************************************************************
*
* $RCSfile: testshl.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* 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., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifdef SOLARIS
#include <sys/time.h>
#endif
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif
/* UNDER_WINDOWS_DEBUGGING */
#endif
/* WNT */
#include <iostream>
#include <vector>
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
// #include <rtl/tres.h>
#include "autoregisterhelper.hxx"
// #include "cmdlinebits.hxx"
#include "log.hxx"
#include "filehelper.hxx"
#include "getopt.hxx"
#include "cppunit/result/outputter.hxx"
#include "cppunit/joblist.hxx"
// #include <osl/time.h>
using
namespace
std
;
#include "cppunit/result/testshlTestResult.h"
#include "cppunit/result/emacsTestResult.hxx"
Log
initLog
(
GetOpt
&
_aOptions
)
{
rtl
::
OString
logPath
;
if
(
_aOptions
.
hasOpt
(
"-logPath"
))
{
logPath
=
_aOptions
.
getOpt
(
"-logPath"
);
}
else
{
logPath
=
FileHelper
::
getTempPath
().
c_str
();
}
rtl
::
OString
sLogFile
(
logPath
);
sLogFile
+=
"/testshl2.log"
;
Log
log
(
FileHelper
::
convertPath
(
sLogFile
)
);
if
(
log
.
open
()
!=
osl
::
FileBase
::
E_None
)
{
cerr
<<
"could not open LogFile: "
<<
log
.
getName
().
getStr
()
<<
endl
;
exit
(
1
);
}
return
log
;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
static
char
*
optionSet
[]
=
{
"-boom, stop near error position, exception only"
,
"-mode=s, the output mode, emacs, xml, old. Default is -mode old"
,
"-logPath=s, destination path for logging"
,
"-noerrors, shows all tests, but not it's errors."
,
"-onlyerrors, shows only the failed test functions"
,
"-tc=s@, name(s) of testcase(s) to generate"
,
"-jobonly=s, job control file, these jobs should only executed."
,
"-jobfilter=s, use a filter for just some tests."
,
"-onlyshowjobs, show only all jobs, do no tests."
,
"-forward=s, this string will forwarded to the test libraries."
,
"-h:s, display help or help on option"
,
"-help:s, see -h"
,
NULL
};
GetOpt
opt
(
argv
,
optionSet
);
// someone indicates that he needs help
if
(
opt
.
hasOpt
(
"-h"
)
||
opt
.
hasOpt
(
"-help"
)
)
{
opt
.
showUsage
();
exit
(
0
);
}
// get path for logging stuff..
rtl
::
OString
logPth
;
// ...if available
if
(
opt
.
hasOpt
(
"-logPth"
))
{
logPth
=
opt
.
getOpt
(
"-logPth"
);
}
if
(
opt
.
getParams
().
empty
())
{
std
::
cerr
<<
"error: At least on library should given."
<<
std
::
endl
;
opt
.
showUsage
();
exit
(
0
);
}
/* show usage screen if too less parameters */
// if ( argc < 2 )
// usage();
#ifdef UNDER_WINDOWS_DEBUGGING
DebugBreak
();
#endif
// ---
//# CmdLineBits nCmdlinebitflags = createFlags( argc, argv );
//# rtl::OUString suLibraryName = rtl::OUString::createFromAscii(argv[1]);
rtl
::
OUString
suLibraryName
=
rtl
::
OStringToOUString
(
opt
.
getFirstParam
(),
RTL_TEXTENCODING_ASCII_US
);
// Log aLog = initLog(opt);
AutomaticRegisterHelper
aHelper
(
suLibraryName
,
opt
/*, &aJobs*/
);
// create and open log
CppUnit
::
TestResult
*
pResult
;
if
(
opt
.
hasOpt
(
"-mode"
))
{
if
(
opt
.
getOpt
(
"-mode"
).
equals
(
"emacs"
)
==
sal_True
)
{
pResult
=
new
CppUnit
::
emacsTestResult
(
opt
);
}
}
else
{
pResult
=
new
CppUnit
::
testshlTestResult
(
opt
);
}
aHelper
.
CallAll
(
pResult
);
Outputter
aOutput
(
cout
);
pResult
->
print
(
aOutput
);
// aLog << *pResult;
// cout << (*pResult);
// cout << "Done." << std::endl;
delete
pResult
;
return
0
;
}
// all functions, which exist in the library
// all functions + the given, no one twice
// only the given functions
// Signals info
// We can only say which function has thrown a signal, and what signal was thrown,
// but not really where the signal was thrown. You have to debug this function by hand.
// Exception info
// Due to the fact that exceptions will caught, on exceptions the ASSERTION text is given.
// but we know also the real thrown exception
// PARAMETER:
// - BaselibTest.txt anders benennen.
// - in eigenes Verzeichnis setzen.
// - log file, nicht nur cout.
// - emacs mode
// - test runner in perl.
// - Version/Buildno. im Datum
// - xml
// Remove rtl_tres_state from SAL!
testshl2/source/versioner.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdio.h>
#include <stdlib.h>
#include "versionhelper.hxx"
#include <rtl/ustring.hxx>
#include <iostream>
/**
* display usage screen
*/
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
static
char
*
optionSet
[]
=
{
"-h:s, display help or help on option"
,
"-help:s, see -h"
,
NULL
};
GetOpt
opt
(
argv
,
optionSet
);
// someone indicates that he needs help
if
(
opt
.
hasOpt
(
"-h"
)
||
opt
.
hasOpt
(
"-help"
)
)
{
opt
.
showUsage
();
exit
(
0
);
}
rtl
::
OUString
suLibraryName
=
rtl
::
OStringToOUString
(
opt
.
getFirstParam
(),
RTL_TEXTENCODING_ASCII_US
);
VersionHelper
aHelper
(
suLibraryName
,
opt
);
std
::
cout
<<
aHelper
<<
std
::
endl
;
return
0
;
}
testshl2/source/versionhelper.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdlib.h>
#include "versionhelper.hxx"
#include <rtl/ustring.hxx>
// -----------------------------------------------------------------------------
VersionHelper
::
VersionHelper
(
rtl
::
OUString
const
&
_sDLLName
,
GetOpt
&
_aOptions
)
:
DynamicLibraryHelper
(
_sDLLName
,
_aOptions
),
m_pInfo
(
NULL
)
{
// try to get the entry pointer
FktGetVersionInfoPtr
pFunc
=
(
FktGetVersionInfoPtr
)
m_pModule
->
getSymbol
(
rtl
::
OUString
::
createFromAscii
(
"GetVersionInfo"
)
);
if
(
pFunc
)
{
const
VersionInfo
*
pVersion
=
(
pFunc
)();
m_pInfo
=
pVersion
;
}
}
void
VersionHelper
::
print
(
std
::
ostream
&
stream
)
{
stream
<<
m_pInfo
->
aTime
<<
std
::
endl
;
stream
<<
m_pInfo
->
aDate
<<
std
::
endl
;
stream
<<
m_pInfo
->
aUpd
<<
std
::
endl
;
stream
<<
m_pInfo
->
aMinor
<<
std
::
endl
;
stream
<<
m_pInfo
->
aBuild
<<
std
::
endl
;
stream
<<
m_pInfo
->
aInpath
<<
std
::
endl
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
VersionHelper
&
_aVersion
)
{
_aVersion
.
print
(
stream
);
return
stream
;
}
testshl2/util/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:14 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
PRJNAME
=
testshl2
TARGET
=
testshl2
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/workben/dlltest/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:17 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
$/
..
PRJINC
=
PRJNAME
=
testshl2
TARGET
=
onefunc
TARGETTYPE
=
CUI
ENABLE_EXCEPTIONS
=
TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES
=
$(OBJ)$/
onefuncstarter.obj
SLOFILES
=
$(SLO)$/
onefunc.obj
# -------------------------------------------------------------------------------
LIB1TARGET
=
$(LB)$/$(TARGET)
_libfile.lib
LIB1OBJFILES
=
$(SLOFILES)
.IF
"$(GUI)"
==
"UNX"
LIB1ARCHIV
=
$(LB)$/
lib
$(TARGET)$(DLLPOSTFIX)
.a
.ENDIF
# ------------------------------------------------------------------
SHL2OBJS
=
$(SLOFILES)
SHL2TARGET
=
$(TARGET)
_DLL
SHL2STDLIBS
+=
\
$(SALLIB)
SHL2DEPN
=
SHL2IMPLIB
=
i
$(SHL2TARGET)
SHL2DEF
=
$(MISC)$/$(SHL2TARGET)
.def
DEF2NAME
=
$(SHL2TARGET)
DEF2EXPORTFILE
=
export.exp
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET
=
$(TARGET)
starter
APP1OBJS
=
$(OBJFILES)
APP1STDLIBS
=
$(SALLIB)
APP1DEPN
=
$(APP1OBJS)
$(LIB1TARGET)
APP1LIBS
=
$(LIB1TARGET)
#-------------------------- executable with LIBARCHIV --------------------------
APP2TARGET
=
$(TARGET)
starter2
APP2OBJS
=
$(OBJFILES)
APP2STDLIBS
=
$(SALLIB)
.IF
"$(GUI)"
==
"UNX"
APP2STDLIBS
+=
$(LB)$/
lib
$(TARGET)$(DLLPOSTFIX)
.a
.ENDIF
.IF
"$(GUI)"
==
"WNT"
APP2STDLIBS
+=
$(LIB1TARGET)
.ENDIF
APP2DEPN
=
$(APP1OBJS)
$(LIB1TARGET)
APP2LIBS
=
#----------------------- executable with dynamic library -----------------------
APP3TARGET
=
$(TARGET)
starter3
APP3OBJS
=
$(OBJFILES)
APP3STDLIBS
=
$(SALLIB)
.IF
"$(GUI)"
==
"WNT"
APP3STDLIBS
+=
i
$(SHL2TARGET)
.lib
.ENDIF
.IF
"$(GUI)"
==
"UNX"
APP3STDLIBS
+=
-l
$(SHL2TARGET)
.ENDIF
APP3DEPN
=
$(APP1OBJS)
$(LIB1TARGET)
APP3LIBS
=
# APP3DEF=
#----------------------- executable without any other files -----------------------
APP4TARGET
=
$(TARGET)
starter4
APP4OBJS
=
$(OBJFILES)
APP4STDLIBS
=
$(SALLIB)
APP4DEPN
=
$(APP1OBJS)
APP4LIBS
=
# APP3DEF=
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/workben/dlltest/onefunc.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdio.h>
#include <sal/types.h>
#include "registerfunc.h"
extern
"C"
void
SAL_CALL
firstfunc
()
{
printf
(
"first func called.
\n
"
);
}
extern
"C"
void
SAL_CALL
secondfunc
()
{
printf
(
"second func called.
\n
"
);
}
extern
"C"
void
SAL_CALL
registerAllTestFunction
(
FktRegFuncPtr
_pFunc
)
{
if
(
_pFunc
)
{
(
_pFunc
)(
&
firstfunc
,
"firstfunc"
);
(
_pFunc
)(
&
secondfunc
,
"secondfunc"
);
}
}
testshl2/workben/dlltest/onefuncstarter.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <vector>
#include <stdio.h>
#include "registerfunc.h"
#ifndef _OSL_MODULE_HXX_
#include <osl/module.hxx>
#endif
#ifndef _OSL_PROCESS_H_
#include <osl/process.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
typedef
std
::
vector
<
FktPtr
>
FunctionList
;
FunctionList
m_Functions
;
extern
"C"
bool
SAL_CALL
registerFunc
(
FktPtr
_pFunc
,
const
char
*
_sFuncName
)
{
printf
(
"Function register call for func(%s) successful.
\n
"
,
_sFuncName
);
m_Functions
.
push_back
(
_pFunc
);
// FktPtr pFunc = _pFunc;
// if (_pFunc)
// {
// (_pFunc)();
// }
return
true
;
}
void
callAll
()
{
for
(
FunctionList
::
const_iterator
it
=
m_Functions
.
begin
();
it
!=
m_Functions
.
end
();
++
it
)
{
FktPtr
pFunc
=
*
it
;
if
(
pFunc
)
{
(
pFunc
)();
}
}
}
// void test_link_at_compiletime()
// {
// FktRegFuncPtr pRegisterFunc = ®isterFunc;
// registerAll(pRegisterFunc);
// callAll();
// }
// -----------------------------------------------------------------------------
rtl
::
OUString
convertPath
(
rtl
::
OString
const
&
sysPth
)
{
// PRE: String should contain a filename, relativ or absolut
rtl
::
OUString
sysPath
(
rtl
::
OUString
::
createFromAscii
(
sysPth
.
getStr
()
)
);
rtl
::
OUString
fURL
;
if
(
sysPth
.
indexOf
(
".."
)
!=
-
1
)
{
// filepath contains '..' so it's a relative path make it absolut.
rtl
::
OUString
curDirPth
;
osl_getProcessWorkingDir
(
&
curDirPth
.
pData
);
osl
::
FileBase
::
getAbsoluteFileURL
(
curDirPth
,
sysPath
,
fURL
);
}
else
{
osl
::
FileBase
::
getFileURLFromSystemPath
(
sysPath
,
fURL
);
}
return
fURL
;
}
// -----------------------------------------------------------------------------
void
test_link_at_runtime
()
{
::
osl
::
Module
*
pModule
;
pModule
=
new
::
osl
::
Module
();
// create and load the module (shared library)
// pModule = new ::osl::Module();
#ifdef WNT
pModule
->
load
(
convertPath
(
rtl
::
OString
(
"onefunc_DLL.dll"
)
)
);
#endif
#ifdef UNX
pModule
->
load
(
convertPath
(
rtl
::
OString
(
"libonefunc_DLL.so"
)
)
);
#endif
// get entry pointer
FktRegAllPtr
pFunc
=
(
FktRegAllPtr
)
pModule
->
getSymbol
(
rtl
::
OUString
::
createFromAscii
(
"registerAllTestFunction"
)
);
if
(
pFunc
)
{
FktRegFuncPtr
pRegisterFunc
=
&
registerFunc
;
pFunc
(
pRegisterFunc
);
callAll
();
}
delete
pModule
;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
// test_link_at_compiletime();
test_link_at_runtime
();
return
0
;
}
testshl2/workben/dlltest/registerfunc.h
0 → 100644
Dosyayı görüntüle @
0fcd1180
#ifndef _register_h
#define _register_h
#include <sal/types.h>
typedef
void
(
*
FktPtr
)(
void
);
// register the given void* as a function pointer, true, if successful
extern
"C"
bool
SAL_CALL
registerFunc
(
FktPtr
aFunc
,
const
char
*
aFuncName
);
typedef
bool
(
*
FktRegFuncPtr
)(
FktPtr
aFunc
,
const
char
*
aFuncName
);
extern
"C"
void
SAL_CALL
registerAllTestFunction
(
FktRegFuncPtr
aFunc
);
typedef
void
(
*
FktRegAllPtr
)(
FktRegFuncPtr
aFunc
);
#endif
testshl2/workben/examples/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:19 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
$/
..
PRJINC
=
PRJNAME
=
testshl2
TARGET
=
demotest
TARGETTYPE
=
CUI
ENABLE_EXCEPTIONS
=
TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
SLOFILES
=
$(SLO)$/
testshl_test.obj
# ------------------------------------------------------------------
SHL2OBJS
=
$(SLOFILES)
SHL2TARGET
=
$(TARGET)
SHL2STDLIBS
=
\
$(SALLIB)
\
$(SOLARLIBDIR)$/
cppunit.lib
SHL2DEPN
=
SHL2IMPLIB
=
i
$(SHL2TARGET)
SHL2DEF
=
$(MISC)$/$(SHL2TARGET)
.def
DEF2NAME
=
$(SHL2TARGET)
DEF2EXPORTFILE
=
export.exp
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/workben/examples/testshl_test.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
/*************************************************************************
*
* $RCSfile: testshl_test.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* 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., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif
/* UNDER_WINDOWS_DEBUGGING */
#endif
/* WNT */
#include <vector>
#ifndef _SAL_TRES_H_
#include <rtl/tres.h>
#endif
#ifndef _TESTSHL_TSTMGR_H_
#include "tstmgr.h"
#endif
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
#include <osl/time.h>
using
namespace
std
;
/**
* create bitmap of comandline parameters
*/
sal_uInt32
createFlags
(
vector
<
sal_Char
*
>
const
&
cmdln
)
{
sal_uInt32
retflags
=
rtl_tres_Flag_OK
;
vector
<
sal_Char
*
>::
const_iterator
iter
=
cmdln
.
begin
();
while
(
iter
!=
cmdln
.
end
()
)
{
fprintf
(
stderr
,
"%s
\n
"
,
*
iter
);
if
(
*
iter
[
0
]
==
'-'
)
{
rtl
::
OString
item
(
*
iter
);
if
(
item
==
"-boom"
)
retflags
|=
rtl_tres_Flag_BOOM
;
if
(
item
==
"-verbose"
)
retflags
|=
rtl_tres_Flag_VERBOSE
;
if
(
item
==
"-skip"
)
retflags
|=
rtl_tres_Flag_SKIP
;
if
(
item
==
"-log"
)
retflags
|=
rtl_tres_Flag_LOG
;
if
(
item
==
"-his"
)
retflags
|=
rtl_tres_Flag_HIS
;
if
(
item
==
"-time"
)
retflags
|=
rtl_tres_Flag_TIME
;
if
(
item
==
"-msg"
)
retflags
|=
rtl_tres_Flag_MSG
;
}
iter
++
;
}
return
retflags
;
}
sal_uInt32
createFlags
(
int
argc
,
char
*
argv
[])
{
vector
<
sal_Char
*
>
cmdln
;
sal_Int32
i
;
/* collect comandline */
for
(
i
=
1
;
i
<
argc
;
i
++
)
cmdln
.
push_back
(
argv
[
i
]
);
return
createFlags
(
cmdln
);
}
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
void
usage
()
{
fprintf
(
stdout
,
"USAGE: testshl shlname scename [-boom][-verbose][-log][-his][-msg]
\n
"
);
exit
(
0
);
}
#include <fstream>
#include <cppunit/TestFixture.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestAssert.h>
#include <cppunit/TextTestResult.h>
namespace
CppunitTest
{
class
AStringTest
:
public
CppUnit
::
TestCase
{
rtl
::
OString
*
m_pStr
;
public
:
AStringTest
()
:
m_pStr
(
NULL
)
{}
void
setUp
()
{
m_pStr
=
new
rtl
::
OString
(
"test1"
);
// throw std::exception("initialization failed.");
}
void
tearDown
()
{
delete
m_pStr
;
}
void
testEquality
()
{
CPPUNIT_ASSERT
(
*
m_pStr
==
"test1"
);
CPPUNIT_ASSERT
(
(
*
m_pStr
).
equalsIgnoreAsciiCase
(
"Test1"
)
);
CPPUNIT_ASSERT
(
(
*
m_pStr
).
equalsIgnoreAsciiCase
(
"Test2"
)
);
CPPUNIT_ASSERT
(
*
m_pStr
==
"test1"
);
CPPUNIT_ASSERT
(
*
m_pStr
==
"must also fail"
);
}
void
testEquality2
()
{
rtl
::
OString
aStr
(
"test2"
);
CPPUNIT_ASSERT
(
aStr
==
"test2"
);
CPPUNIT_ASSERT_MESSAGE
(
"ein vergleichstest"
,
aStr
==
"test2"
);
CPPUNIT_ASSERT
(
aStr
==
"must also fail"
);
}
void
testThrow
()
{
throw
std
::
exception
(
"an own exception!"
);
CPPUNIT_ASSERT
(
*
m_pStr
==
"test2"
);
}
};
CppUnit
::
TestSuite
*
suite1
()
{
CppUnit
::
TestSuite
*
suite
=
new
CppUnit
::
TestSuite
(
"AStringTest"
);
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite
->
addTest
(
new
CppUnit
::
TestCaller
<
AStringTest
>
(
"throw test"
,
&
AStringTest
::
testThrow
));
// suite->addTest( new CppUnit::TestCaller<AStringTest>( "test op eq", &AStringTest::testEquality ));
// suite->addTest( new CppUnit::TestCaller<AStringTest>( "test op eq", &AStringTest::testEquality2 ));
return
suite
;
}
// -----------------------------------------------------------------------------
class
ASimpleTest
:
public
CppUnit
::
TestCase
{
public
:
void
testEqual
()
{
CPPUNIT_ASSERT
(
1
==
1
);
}
};
CppUnit
::
TestSuite
*
suite2
()
{
CppUnit
::
TestSuite
*
suite
=
new
CppUnit
::
TestSuite
(
"A simple test"
);
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite
->
addTest
(
new
CppUnit
::
TestCaller
<
ASimpleTest
>
(
"1 == 1"
,
&
ASimpleTest
::
testEqual
));
return
suite
;
}
// -----------------------------------------------------------------------------
CppUnit
::
TestSuite
*
suite
()
{
CppUnit
::
TestSuite
*
suite
=
new
CppUnit
::
TestSuite
(
"A simple test"
);
// CppUnit::TestSuite suite;
// CppUnit::TextTestResult result;
suite
->
addTest
(
suite1
()
);
// suite->addTest( suite2() );
return
suite
;
}
}
void
cppunitbased_test
()
{
{
// ofstream out("c:\\temp\\output.txt", ios::out);
CppUnit
::
TextTestResult
aResult
;
CppUnit
::
TestSuite
*
pSuite
=
CppunitTest
::
suite
();
int
nTests
=
pSuite
->
countTestCases
();
pSuite
->
run
(
&
aResult
);
// aResult.print(out);
cout
<<
aResult
;
delete
pSuite
;
}
exit
(
1
);
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
cppunitbased_test
();
tslTestManager
hMgr
=
0
;
/* show usage screen if too less parameters */
if
(
argc
<
3
)
usage
();
#ifdef UNDER_WINDOWS_DEBUGGING
DebugBreak
();
#endif
sal_uInt32
nCmdlinebitflags
=
createFlags
(
argc
,
argv
);
hMgr
=
tsl_TestManager_create
(
argv
,
argc
,
nCmdlinebitflags
);
tsl_TestManager_run
(
hMgr
);
tsl_TestManager_destroy
(
hMgr
);
return
0
;
}
testshl2/workben/getopt/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:20 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
$/
..
PRJINC
=
PRJNAME
=
testshl2
TARGET
=
test_getopt
TARGETTYPE
=
CUI
ENABLE_EXCEPTIONS
=
TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES
=
\
$(OBJ)$/
getopt.obj
\
$(OBJ)$/
filehelper.obj
\
$(OBJ)$/
test_getopt.obj
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET
=
$(TARGET)
APP1OBJS
=
$(OBJFILES)
APP1STDLIBS
=
$(SALLIB)
APP1DEPN
=
$(APP1OBJS)
APP1LIBS
=
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/workben/getopt/test_getopt.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
/*************************************************************************
*
* $RCSfile: test_getopt.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: lla $ $Date: 2003-01-09 11:06:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* 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., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#ifdef SOLARIS
#include <sys/time.h>
#endif
#ifdef WNT
// #define UNDER_WINDOWS_DEBUGGING
// Nice feature, to debug under windows, install msdev locally and use DebugBreak() to stop a new process at a point you want.
#ifdef UNDER_WINDOWS_DEBUGGING
#include <tools/presys.h>
#include <windows.h>
#include <tools/postsys.h>
#define VCL_NEED_BASETSD
#endif
/* UNDER_WINDOWS_DEBUGGING */
#endif
/* WNT */
#include <iostream>
#include <vector>
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx>
#endif
#include "filehelper.hxx"
#include "getopt.hxx"
// #include <osl/time.h>
using
namespace
std
;
// -----------------------------------------------------------------------------
/**
* display usage screen
*/
void
usage
()
{
fprintf
(
stdout
,
"USAGE: testshl shlname [-boom][-verbose][-log][-his][-msg]
\n
"
);
exit
(
0
);
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
static
char
*
optionSet
[]
=
{
"-boom, stop near error position, exception only"
,
"-mode=s, the output mode, emacs, xml, old. Default is -mode old"
,
"-logPath=s, destination path for logging"
,
"-tc=s@, name(s) of testcase(s) to generate"
,
"-h:s, display help or help on option"
,
"-help:s, see -h"
,
NULL
};
GetOpt
opt
(
argv
,
optionSet
);
// someone indicates that he needs help
if
(
opt
.
hasOpt
(
"-h"
)
||
opt
.
hasOpt
(
"-help"
)
)
{
opt
.
showUsage
();
// exit(0);
}
// get path for logging stuff..
rtl
::
OString
logPth
;
// ...if available
if
(
opt
.
hasOpt
(
"-logPth"
))
{
logPth
=
opt
.
getOpt
(
"-logPth"
);
}
rtl
::
OString
param
;
if
(
!
opt
.
getParams
().
empty
()
)
{
param
=
opt
.
getFirstParam
();
std
::
cout
<<
"all non '-' Parameter values"
<<
std
::
endl
;
vector
<
rtl
::
OString
>&
aVec
=
opt
.
getParams
();
for
(
vector
<
rtl
::
OString
>::
const_iterator
it
=
aVec
.
begin
();
it
!=
aVec
.
end
();
++
it
)
{
std
::
cout
<<
(
*
it
).
getStr
()
<<
std
::
endl
;
}
}
if
(
opt
.
hasOpt
(
"-tc"
))
{
std
::
cout
<<
"Parameter -tc"
<<
std
::
endl
;
vector
<
rtl
::
OString
>&
aVec
=
opt
.
getOptVec
(
"-tc"
);
for
(
vector
<
rtl
::
OString
>::
const_iterator
it
=
aVec
.
begin
();
it
!=
aVec
.
end
();
++
it
)
{
std
::
cout
<<
(
*
it
).
getStr
()
<<
std
::
endl
;
}
}
return
0
;
}
testshl2/workben/makefile.mk
0 → 100644
Dosyayı görüntüle @
0fcd1180
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: lla $ $Date: 2003-01-09 11:06:15 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# 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., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ
=
..
PRJINC
=
PRJNAME
=
testshl2
TARGET
=
test_autoptr
TARGETTYPE
=
CUI
ENABLE_EXCEPTIONS
=
TRUE
#USE_LDUMP2=TRUE
#LDUMP2=LDUMP3
# --- Settings -----------------------------------------------------
.INCLUDE
:
svpre.mk
.INCLUDE
:
settings.mk
.INCLUDE
:
sv.mk
# ------------------------------------------------------------------
#--------------------------------- Objectfiles ---------------------------------
OBJFILES
=
\
$(OBJ)$/
test_autoptr.obj
\
$(OBJ)$/
test_ostringstream.obj
#----------------------------- prog with *.lib file -----------------------------
APP1TARGET
=
$(TARGET)
APP1OBJS
=
$(OBJ)$/
test_autoptr.obj
APP1STDLIBS
=
$(SALLIB)
APP1DEPN
=
$(APP1OBJS)
APP1LIBS
=
#-------------------------------------------------------------------------------
APP2TARGET
=
test_ostringstream
APP2OBJS
=
$(OBJ)$/
test_ostringstream.obj
APP2STDLIBS
=
$(SALLIB)
APP2DEPN
=
$(APP1OBJS)
APP2LIBS
=
#-------------------------------------------------------------------------------
APP3TARGET
=
test_filter
APP3OBJS
=
$(OBJ)$/
test_filter.obj
APP3STDLIBS
=
$(SALLIB)
APP3DEPN
=
$(APP1OBJS)
APP3LIBS
=
# --- Targets ------------------------------------------------------
.INCLUDE
:
target.mk
testshl2/workben/singleton.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
class
OSingleton
{
public
:
static
OSingleton
*
GetSingleton
();
virtual
~
OSingleton
(){}
protected
:
OSingleton
(){}
static
OSingleton
*
m_pSingleton
;
};
OSingleton
*
OSingleton
::
m_pSingleton
=
NULL
;
OSingleton
*
OSingleton
::
GetSingleton
()
{
if
(
m_pSingleton
==
NULL
)
{
m_pSingleton
=
new
OSingleton
;
}
return
m_pSingleton
;
}
testshl2/workben/test_autoptr.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdlib.h>
#include <memory>
#include <iostream>
#include <stdio.h>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
class
AutoPtrTest
{
int
m_nValue
;
// NOCOPY
AutoPtrTest
(
AutoPtrTest
const
&
);
AutoPtrTest
&
operator
=
(
AutoPtrTest
const
&
);
public
:
AutoPtrTest
(
int
_nValue
=
1
)
:
m_nValue
(
_nValue
)
{
std
::
cout
<<
"build Value"
<<
std
::
endl
;
}
~
AutoPtrTest
()
{
std
::
cout
<<
"release Value"
<<
std
::
endl
;
m_nValue
=
0
;
}
// int operator int() const {return m_nValue;}
int
getValue
()
const
{
return
m_nValue
;}
};
std
::
auto_ptr
<
AutoPtrTest
>
getPtr
()
{
return
std
::
auto_ptr
<
AutoPtrTest
>
(
new
AutoPtrTest
(
2
));
}
// auto_ptr get() gibt den Pointer ohne das ownership
// auto_ptr release()gibt den Pointer und (!) das ownership
void
test_autoptr
()
{
AutoPtrTest
*
pValuePtr
;
std
::
cout
<<
"start test"
<<
std
::
endl
;
{
std
::
auto_ptr
<
AutoPtrTest
>
pValue
=
getPtr
();
std
::
cout
<<
"Value with getValue() "
<<
pValue
->
getValue
()
<<
std
::
endl
;
// std::cout << "Value operator int() " << *pValue << std::endl;
// ownership weiterreichen
pValuePtr
=
pValue
.
release
();
}
std
::
cout
<<
"ValuePtr with getValue() "
<<
pValuePtr
->
getValue
()
<<
std
::
endl
;
// ownership an neuen Pointer uebergeben
std
::
auto_ptr
<
AutoPtrTest
>
pValue2
(
pValuePtr
);
// AutoPtrTest *pStr = getPtr();
std
::
cout
<<
"end test"
<<
std
::
endl
;
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
test_autoptr
();
return
0
;
}
testshl2/workben/test_filter.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <vector>
#include <string>
#include <iostream>
#include <rtl/string.hxx>
typedef
std
::
vector
<
std
::
string
>
StringList
;
typedef
std
::
vector
<
rtl
::
OString
>
OStringList
;
void
split
(
const
rtl
::
OString
&
opt
,
const
rtl
::
OString
&
_sSeparator
,
OStringList
&
optLine
)
{
optLine
.
clear
();
// const sal_Int32 cSetLen = cSet.getLength();
sal_Int32
index
=
0
;
sal_Int32
oldIndex
=
0
;
// sal_Int32 i;
// sal_Int32 j = 0;
while
(
opt
.
getLength
()
>
0
)
{
// for ( i = 0; i < cSetLen; i++ )
// {
index
=
opt
.
indexOf
(
_sSeparator
,
oldIndex
);
if
(
index
!=
-
1
)
{
optLine
.
push_back
(
opt
.
copy
(
oldIndex
,
index
-
oldIndex
)
);
oldIndex
=
index
+
_sSeparator
.
getLength
();
}
// }
else
// if (index == -1)
{
optLine
.
push_back
(
opt
.
copy
(
oldIndex
)
);
break
;
}
}
}
///< split
// -----------------------------------------------------------------------------
StringList
splitNameAtDot
(
rtl
::
OString
const
&
_sName
)
{
StringList
aList
;
int
nIndex
=
0
;
int
nLastIndex
=
0
;
while
((
nIndex
=
_sName
.
indexOf
(
"."
))
!=
-
1
)
{
rtl
::
OString
nValue
;
}
return
aList
;
}
// -----------------------------------------------------------------------------
/*
bool checkFilter(JobList m_aJobFilter, std::string const& _sNodeName, std::string const& _sName)
{
std::string sFilter = m_aJobFilter.m_aJobList.begin();
StringList aFilter;
aFilter.push_back("rtl_OUString");
aFilter.push_back("ctors");
aFilter.push_back("*");
StringList aMyName;
aMyName.push_back("rtl_OUString");
aMyName.push_back("ctors");
aMyName.push_back("ctor_001");
}
*/
void
showList
(
OStringList
const
&
_sList
)
{
for
(
OStringList
::
const_iterator
it
=
_sList
.
begin
();
it
!=
_sList
.
end
();
++
it
)
{
rtl
::
OString
aStr
=
*
it
;
std
::
cout
<<
aStr
.
getStr
()
<<
std
::
endl
;
}
}
bool
match
(
OStringList
const
&
_aFilter
,
OStringList
const
&
_aName
)
{
OStringList
::
const_iterator
aFilterIter
=
_aFilter
.
begin
();
OStringList
::
const_iterator
aValueIter
=
_aName
.
begin
();
bool
bMatch
=
false
;
while
(
aFilterIter
!=
_aFilter
.
end
()
&&
aValueIter
!=
_aName
.
end
())
{
rtl
::
OString
sFilter
=
*
aFilterIter
;
rtl
::
OString
sName
=
*
aValueIter
;
if
(
sFilter
==
sName
)
{
bMatch
=
true
;
++
aFilterIter
;
++
aValueIter
;
}
else
if
(
sFilter
==
"*"
)
{
bMatch
=
true
;
break
;
}
else
{
// Filter does not match
bMatch
=
false
;
break
;
}
}
return
bMatch
;
}
// -----------------------------------------------------------------------------
void
test_normal_filter
()
{
OStringList
aFilter
;
split
(
"rtl_OUString.ctors.*"
,
"."
,
aFilter
);
showList
(
aFilter
);
OStringList
aName
;
split
(
"rtl_OUString.ctors.ctor_001"
,
"."
,
aName
);
showList
(
aName
);
if
(
match
(
aFilter
,
aName
))
{
std
::
cout
<<
"Name matches filter."
<<
std
::
endl
;
}
}
void
test_normal_filter_other_sep
()
{
OStringList
aFilter
;
split
(
"rtl_OUString::ctors::*"
,
"::"
,
aFilter
);
showList
(
aFilter
);
OStringList
aName
;
split
(
"rtl_OUString::ctors::ctor_001"
,
"::"
,
aName
);
showList
(
aName
);
if
(
match
(
aFilter
,
aName
))
{
std
::
cout
<<
"Name matches filter."
<<
std
::
endl
;
}
}
void
test_no_name
()
{
OStringList
aFilter
;
split
(
"rtl_OUString.*"
,
"."
,
aFilter
);
showList
(
aFilter
);
OStringList
aName
;
split
(
""
,
"."
,
aName
);
showList
(
aName
);
if
(
match
(
aFilter
,
aName
))
{
std
::
cout
<<
"Name matches filter."
<<
std
::
endl
;
}
}
void
test_name_longer_filter
()
{
OStringList
aFilter
;
split
(
"rtl_OUString.*"
,
"."
,
aFilter
);
showList
(
aFilter
);
OStringList
aName
;
split
(
"rtl_OUString.ctor.ctor_001"
,
"."
,
aName
);
showList
(
aName
);
if
(
match
(
aFilter
,
aName
))
{
std
::
cout
<<
"Name matches filter."
<<
std
::
endl
;
}
}
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
test_normal_filter
();
test_normal_filter_other_sep
();
test_no_name
();
test_name_longer_filter
();
// split("rtl_OUString.*", ".", aFilter);
// showList(aFilter);
// test_autoptr();
return
0
;
}
testshl2/workben/test_ostringstream.cxx
0 → 100644
Dosyayı görüntüle @
0fcd1180
#include <stdlib.h>
#include <memory>
#include <sstream>
#include <iostream>
#include <bitset>
#include <sal/types.h>
class
TestFactoryRegistry
{
public
:
void
checkFunc
(
char
*
foo
);
void
checkFunc2
(
char
*
foo
);
void
checkFunc3
(
char
*
foo
);
};
void
TestFactoryRegistry
::
checkFunc
(
char
*
foo
)
{
static
int
serialNumber
=
1
;
std
::
ostringstream
ost
;
//! could this be the problem?
ost
<<
"@Dummy@"
<<
serialNumber
++
;
std
::
cout
<<
ost
.
str
()
<<
std
::
endl
;
}
void
TestFactoryRegistry
::
checkFunc2
(
char
*
foo
)
{
static
int
serialNumber
=
1
;
std
::
ostringstream
ost
;
//! could this be the problem?
ost
<<
"@Dummy@"
<<
serialNumber
;
serialNumber
++
;
std
::
cout
<<
ost
.
str
()
<<
std
::
endl
;
}
void
TestFactoryRegistry
::
checkFunc3
(
char
*
foo
)
{
static
int
serialNumber
=
1
;
int
nValue
=
serialNumber
;
std
::
ostringstream
ost
;
//! could this be the problem?
ost
<<
"@Dummy@"
<<
nValue
;
serialNumber
++
;
std
::
cout
<<
ost
.
str
()
<<
std
::
endl
;
}
static
TestFactoryRegistry
a
;
static
TestFactoryRegistry
b
;
static
TestFactoryRegistry
c
;
// ----------------------------------- Main -----------------------------------
#if (defined UNX) || (defined OS2)
int
main
(
int
argc
,
char
*
argv
[]
)
#else
int
_cdecl
main
(
int
argc
,
char
*
argv
[]
)
#endif
{
std
::
ostringstream
ost
;
sal_Int32
nValue
=
1
;
// ost << "@Dummy@" << nValue;
// ost << "dec: " << 15 << std::hex << " hex: " << 15 << std::endl;
// std::cout << ost.str() << std::endl;
char
*
cFoo
=
NULL
;
a
.
checkFunc
(
cFoo
);
a
.
checkFunc2
(
cFoo
);
a
.
checkFunc3
(
cFoo
);
b
.
checkFunc
(
cFoo
);
b
.
checkFunc2
(
cFoo
);
b
.
checkFunc3
(
cFoo
);
c
.
checkFunc
(
cFoo
);
c
.
checkFunc2
(
cFoo
);
c
.
checkFunc3
(
cFoo
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment