1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <sal/types.h>
23 #include <rtl/ustring.h>
24 #include <rtl/string.hxx>
25 #include <rtl_String_Utils_Const.h>
28 sal_uInt32
AStringLen( const sal_Char
*pAStr
)
30 sal_uInt32 nStrLen
= 0;
34 const sal_Char
*pTempStr
= pAStr
;
41 nStrLen
= (sal_uInt32
)( pTempStr
- pAStr
);
46 sal_Char
* cpystr( sal_Char
* dst
, const sal_Char
* src
)
48 const sal_Char
* psrc
= src
;
51 while( *pdst
++ = *psrc
++ );
55 sal_Char
* cpynstr( sal_Char
* dst
, const sal_Char
* src
, sal_uInt32 cnt
)
58 const sal_Char
* psrc
= src
;
63 if ( len
>= AStringLen(src
) )
65 return( cpystr( dst
, src
) );
68 // copy string by char
69 for( i
= 0; i
< len
; i
++ )
76 //------------------------------------------------------------------------
77 sal_Bool
cmpstr( const sal_Char
* str1
, const sal_Char
* str2
, sal_uInt32 len
)
79 const sal_Char
* pBuf1
= str1
;
80 const sal_Char
* pBuf2
= str2
;
83 while ( (*pBuf1
== *pBuf2
) && i
< len
)
91 //------------------------------------------------------------------------
92 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
, sal_uInt32 len
)
94 const sal_Unicode
* pBuf1
= str1
;
95 const sal_Unicode
* pBuf2
= str2
;
98 while ( (*pBuf1
== *pBuf2
) && i
< len
)
107 //-----------------------------------------------------------------------
108 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
)
110 const sal_Unicode
* pBuf1
= str1
;
111 const sal_Unicode
* pBuf2
= str2
;
112 sal_Bool res
= sal_True
;
114 while ( (*pBuf1
== *pBuf2
) && *pBuf1
!='\0' && *pBuf2
!= '\0')
119 if (*pBuf1
== '\0' && *pBuf2
== '\0')
126 sal_Char
* createName( sal_Char
* dst
, const sal_Char
* meth
, sal_uInt32 cnt
)
128 sal_Char
* pdst
= dst
;
130 sal_Char
* pstr
= nstr
;
131 rtl_str_valueOfInt32( pstr
, cnt
, 10 );
133 cpystr( pdst
, meth
);
134 cpystr( pdst
+ AStringLen(meth
), "_" );
138 cpystr(pdst
+ AStringLen(pdst
), "0" );
142 cpystr(pdst
+ AStringLen(pdst
), "0" );
145 cpystr( pdst
+ AStringLen(pdst
), nstr
);
149 //------------------------------------------------------------------------
151 static inline sal_Int32
ACharToUCharCompare( const sal_Unicode
*pUStr
,
152 const sal_Char
*pAStr
156 sal_Int32 nUChar
= (sal_Int32
)*pUStr
;
157 sal_Int32 nChar
= (sal_Int32
)((unsigned char)*pAStr
);
159 nCmp
= nUChar
- nChar
;
162 } // ACharToUCharCompare
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */