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
061ebc34
Kaydet (Commit)
061ebc34
authored
Agu 14, 2011
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add a getToken wrapper for extracting a single token painlessly
üst
90fe8dad
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
17 deletions
+85
-17
string.hxx
comphelper/inc/comphelper/string.hxx
+28
-0
test_string.cxx
comphelper/qa/string/test_string.cxx
+30
-0
HDriver.cxx
connectivity/source/drivers/hsqldb/HDriver.cxx
+8
-6
export.cxx
l10ntools/source/export.cxx
+18
-11
makefile.mk
l10ntools/source/makefile.mk
+1
-0
No files found.
comphelper/inc/comphelper/string.hxx
Dosyayı görüntüle @
061ebc34
...
...
@@ -134,6 +134,34 @@ COMPHELPER_DLLPUBLIC rtl::OString replace(const rtl::OString &rIn,
COMPHELPER_DLLPUBLIC
rtl
::
OUString
replace
(
const
rtl
::
OUString
&
rIn
,
const
rtl
::
OUString
&
rSearch
,
const
rtl
::
OUString
&
rReplace
);
/** Returns a token in the OString
@param token the number of the token to return
@param cTok the character which seperate the tokens.
@return the token if token is negative or doesn't exist an empty token
is returned
*/
COMPHELPER_DLLPUBLIC
inline
rtl
::
OString
getToken
(
const
rtl
::
OString
&
rIn
,
sal_Int32
nToken
,
sal_Char
cTok
)
SAL_THROW
(())
{
sal_Int32
nIndex
=
0
;
return
rIn
.
getToken
(
nToken
,
cTok
,
nIndex
);
}
/** Returns a token in the OUString
@param token the number of the token to return
@param cTok the character which seperate the tokens.
@return the token if token is negative or doesn't exist an empty token
is returned
*/
COMPHELPER_DLLPUBLIC
inline
rtl
::
OUString
getToken
(
const
rtl
::
OUString
&
rIn
,
sal_Int32
nToken
,
sal_Unicode
cTok
)
SAL_THROW
(())
{
sal_Int32
nIndex
=
0
;
return
rIn
.
getToken
(
nToken
,
cTok
,
nIndex
);
}
/** Convert a sequence of strings to a single comma separated string.
Note that no escaping of commas or anything fancy is done.
...
...
comphelper/qa/string/test_string.cxx
Dosyayı görüntüle @
061ebc34
...
...
@@ -44,12 +44,14 @@ public:
void
test
();
void
testNatural
();
void
testReplace
();
void
testToken
();
void
testDecimalStringToNumber
();
CPPUNIT_TEST_SUITE
(
TestString
);
CPPUNIT_TEST
(
test
);
CPPUNIT_TEST
(
testNatural
);
CPPUNIT_TEST
(
testReplace
);
CPPUNIT_TEST
(
testToken
);
CPPUNIT_TEST
(
testDecimalStringToNumber
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -311,11 +313,39 @@ void TestString::testReplace()
CPPUNIT_ASSERT
(
aOut
.
isEmpty
());
aIn
=
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa foo aaa foo bbb"
));
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"foo"
)),
rtl
::
OString
(
RTL_CONSTASCII_STRINGPARAM
(
"bar"
)));
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"aaa bar aaa bar bbb"
)));
aOut
=
::
comphelper
::
string
::
replace
(
aIn
,
rtl
::
OString
(
' '
),
rtl
::
OString
());
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"aaafooaaafoobbb"
)));
}
void
TestString
::
testToken
()
{
::
rtl
::
OString
aIn
(
RTL_CONSTASCII_STRINGPARAM
(
"10.11.12"
));
::
rtl
::
OString
aOut
;
aOut
=
::
comphelper
::
string
::
getToken
(
aIn
,
-
1
,
'.'
);
CPPUNIT_ASSERT
(
aOut
.
isEmpty
());
aOut
=
::
comphelper
::
string
::
getToken
(
aIn
,
0
,
'.'
);
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"10"
)));
aOut
=
::
comphelper
::
string
::
getToken
(
aIn
,
1
,
'.'
);
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"11"
)));
aOut
=
::
comphelper
::
string
::
getToken
(
aIn
,
2
,
'.'
);
CPPUNIT_ASSERT
(
aOut
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"12"
)));
aOut
=
::
comphelper
::
string
::
getToken
(
aIn
,
3
,
'.'
);
CPPUNIT_ASSERT
(
aOut
.
isEmpty
());
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
TestString
);
...
...
connectivity/source/drivers/hsqldb/HDriver.cxx
Dosyayı görüntüle @
061ebc34
...
...
@@ -53,6 +53,7 @@
#include <osl/process.h>
#include <connectivity/dbexception.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/string.hxx>
#include <unotools/confignode.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include "resource/hsqldb_res.hrc"
...
...
@@ -278,7 +279,7 @@ namespace connectivity
if
(
pStream
.
get
()
)
{
ByteString
sLine
;
Byte
String
sVersionString
;
rtl
::
O
String
sVersionString
;
while
(
pStream
->
ReadLine
(
sLine
)
)
{
if
(
sLine
.
Len
()
==
0
)
...
...
@@ -292,18 +293,19 @@ namespace connectivity
else
{
if
(
sIniKey
.
Equals
(
"version"
)
&&
(
sVersionString
.
Len
()
==
0
)
&&
(
sVersionString
.
isEmpty
()
)
)
{
sVersionString
=
sValue
;
}
}
}
if
(
sVersionString
.
Len
()
)
if
(
!
sVersionString
.
isEmpty
()
)
{
const
sal_Int32
nMajor
=
sVersionString
.
GetToken
(
0
,
'.'
).
ToInt32
();
const
sal_Int32
nMinor
=
sVersionString
.
GetToken
(
1
,
'.'
).
ToInt32
();
const
sal_Int32
nMicro
=
sVersionString
.
GetToken
(
2
,
'.'
).
ToInt32
();
using
comphelper
::
string
::
getToken
;
const
sal_Int32
nMajor
=
getToken
(
sVersionString
,
0
,
'.'
).
toInt32
();
const
sal_Int32
nMinor
=
getToken
(
sVersionString
,
1
,
'.'
).
toInt32
();
const
sal_Int32
nMicro
=
getToken
(
sVersionString
,
2
,
'.'
).
toInt32
();
if
(
nMajor
>
1
||
(
nMajor
==
1
&&
nMinor
>
8
)
||
(
nMajor
==
1
&&
nMinor
==
8
&&
nMicro
>
0
)
)
...
...
l10ntools/source/export.cxx
Dosyayı görüntüle @
061ebc34
...
...
@@ -36,6 +36,7 @@
#include <iostream>
#include <vector>
#include <rtl/strbuf.hxx>
#include <comphelper/string.hxx>
extern
"C"
{
int
yyerror
(
const
char
*
);
}
extern
"C"
{
int
YYWarning
(
const
char
*
);
}
...
...
@@ -1032,23 +1033,29 @@ int Export::Execute( int nToken, const char * pToken )
bDontWriteOutput
=
sal_True
;
}
break
;
case
APPFONTMAPPING
:
{
case
APPFONTMAPPING
:
{
using
comphelper
::
string
::
replace
;
using
comphelper
::
string
::
getToken
;
bDontWriteOutput
=
sal_False
;
// this is a AppfontMapping, so look if its a definition
// of field size
ByteString
sKey
=
sToken
.
GetToken
(
0
,
'='
);
sKey
.
EraseAllChars
(
' '
);
sKey
.
EraseAllChars
(
'\t'
);
ByteString
sMapping
=
sToken
.
GetToken
(
1
,
'='
);
sMapping
=
sMapping
.
GetToken
(
1
,
'('
);
sMapping
=
sMapping
.
GetToken
(
0
,
')'
);
sMapping
.
EraseAllChars
(
' '
);
sMapping
.
EraseAllChars
(
'\t'
);
if
(
sKey
.
ToUpperAscii
()
==
"SIZE"
)
{
pResData
->
nWidth
=
(
sal_uInt16
)
sMapping
.
GetToken
(
0
,
','
).
ToInt32
();
}
else
if
(
sKey
==
"POSSIZE"
)
{
pResData
->
nWidth
=
(
sal_uInt16
)
sMapping
.
GetToken
(
2
,
','
).
ToInt32
();
rtl
::
OString
sMapping
=
sToken
.
GetToken
(
1
,
'='
);
sMapping
=
getToken
(
sMapping
,
1
,
'('
);
sMapping
=
getToken
(
sMapping
,
0
,
')'
);
sMapping
=
replace
(
sMapping
,
rtl
::
OString
(
' '
),
rtl
::
OString
());
sMapping
=
replace
(
sMapping
,
rtl
::
OString
(
'\t'
),
rtl
::
OString
());
if
(
sKey
.
ToUpperAscii
()
==
"SIZE"
)
{
pResData
->
nWidth
=
(
sal_uInt16
)
getToken
(
sMapping
,
0
,
','
).
toInt32
();
}
else
if
(
sKey
==
"POSSIZE"
)
{
pResData
->
nWidth
=
(
sal_uInt16
)
getToken
(
sMapping
,
2
,
','
).
toInt32
();
}
}
break
;
...
...
l10ntools/source/makefile.mk
Dosyayı görüntüle @
061ebc34
...
...
@@ -77,6 +77,7 @@ APP1TARGET= transex3
APP1OBJS
=
$(OBJ)$/
src_yy_wrapper.obj
APP1STDLIBS
+=
\
$(TOOLSLIB)
\
$(COMPHELPERLIB)
\
$(SALLIB)
APP1LIBS
+=
$(LB)$/$(TARGET)
.lib
APP1DEPN
=
$(OBJ)$/
src_yy_wrapper.obj
$(LB)$/$(TARGET)
.lib
...
...
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