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 .
23 #include <sal/types.h>
25 #include <rtl/ustring.h>
26 #include <rtl/string.hxx>
27 #include <rtl_String_Utils_Const.h>
30 sal_uInt32
AStringLen( const sal_Char
*pAStr
)
32 sal_uInt32 nStrLen
= 0;
36 const sal_Char
*pTempStr
= pAStr
;
43 nStrLen
= (sal_uInt32
)( pTempStr
- pAStr
);
49 sal_Char
* cpystr( sal_Char
* dst
, const sal_Char
* src
)
51 const sal_Char
* psrc
= src
;
54 while( (*pdst
++ = *psrc
++) ) {}
59 sal_Char
* cpynstr( sal_Char
* dst
, const sal_Char
* src
, sal_uInt32 cnt
)
62 const sal_Char
* psrc
= src
;
67 if ( len
>= AStringLen(src
) )
69 return( cpystr( dst
, src
) );
72 // copy string by char
73 for( i
= 0; i
< len
; i
++ )
80 //------------------------------------------------------------------------
81 sal_Bool
cmpstr( const sal_Char
* str1
, const sal_Char
* str2
, sal_uInt32 len
)
83 const sal_Char
* pBuf1
= str1
;
84 const sal_Char
* pBuf2
= str2
;
87 while ( (*pBuf1
== *pBuf2
) && i
< len
)
95 //-----------------------------------------------------------------------
96 sal_Bool
cmpstr( const sal_Char
* str1
, const sal_Char
* str2
)
98 const sal_Char
* pBuf1
= str1
;
99 const sal_Char
* pBuf2
= str2
;
100 sal_Bool res
= sal_True
;
102 while ( (*pBuf1
== *pBuf2
) && *pBuf1
!='\0' && *pBuf2
!= '\0')
107 if (*pBuf1
== '\0' && *pBuf2
== '\0')
113 //------------------------------------------------------------------------
114 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
, sal_uInt32 len
)
116 const sal_Unicode
* pBuf1
= str1
;
117 const sal_Unicode
* pBuf2
= str2
;
120 while ( (*pBuf1
== *pBuf2
) && i
< len
)
129 //-----------------------------------------------------------------------
130 sal_Bool
cmpustr( const sal_Unicode
* str1
, const sal_Unicode
* str2
)
132 const sal_Unicode
* pBuf1
= str1
;
133 const sal_Unicode
* pBuf2
= str2
;
134 sal_Bool res
= sal_True
;
136 while ( (*pBuf1
== *pBuf2
) && *pBuf1
!='\0' && *pBuf2
!= '\0')
141 if (*pBuf1
== '\0' && *pBuf2
== '\0')
148 sal_Char
* createName( sal_Char
* dst
, const sal_Char
* meth
, sal_uInt32 cnt
)
150 sal_Char
* pdst
= dst
;
152 sal_Char
* pstr
= nstr
;
153 rtl_str_valueOfInt32( pstr
, cnt
, 10 );
155 cpystr( pdst
, meth
);
156 cpystr( pdst
+ AStringLen(meth
), "_" );
160 cpystr(pdst
+ AStringLen(pdst
), "0" );
164 cpystr(pdst
+ AStringLen(pdst
), "0" );
167 cpystr( pdst
+ AStringLen(pdst
), nstr
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */