1 /********************************************************************/
2 /*                                                                  */
3 /*  str_rtl.h     Primitive actions for the string type.            */
4 /*  Copyright (C) 1989 - 2015  Thomas Mertes                        */
5 /*                                                                  */
6 /*  This file is part of the Seed7 Runtime Library.                 */
7 /*                                                                  */
8 /*  The Seed7 Runtime Library is free software; you can             */
9 /*  redistribute it and/or modify it under the terms of the GNU     */
10 /*  Lesser General Public License as published by the Free Software */
11 /*  Foundation; either version 2.1 of the License, or (at your      */
12 /*  option) any later version.                                      */
13 /*                                                                  */
14 /*  The Seed7 Runtime Library is distributed in the hope that it    */
15 /*  will be useful, but WITHOUT ANY WARRANTY; without even the      */
16 /*  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
17 /*  PURPOSE.  See the GNU Lesser General Public License for more    */
18 /*  details.                                                        */
19 /*                                                                  */
20 /*  You should have received a copy of the GNU Lesser General       */
21 /*  Public License along with this program; if not, write to the    */
22 /*  Free Software Foundation, Inc., 51 Franklin Street,             */
23 /*  Fifth Floor, Boston, MA  02110-1301, USA.                       */
24 /*                                                                  */
25 /*  Module: Seed7 Runtime Library                                   */
26 /*  File: seed7/src/str_rtl.h                                       */
27 /*  Changes: 1991 - 1994, 2005, 2008 - 2015  Thomas Mertes          */
28 /*  Content: Primitive actions for the string type.                 */
29 /*                                                                  */
30 /********************************************************************/
31 
32 /**
33  *  Macro to compute the hashcode of a string.
34  *  A corresponding macro is inlined by the compiler. If this macro
35  *  is changed the code in the compiler must be changed as well.
36  */
37 #define hashCode(stri) (intType) ((stri)->size == 0 ? 0 : \
38                                      ((stri)->mem[0] << 5 ^ \
39                                       (stri)->mem[(stri)->size >> 1] << 3 ^ \
40                                       (stri)->mem[(stri)->size - 1] << 1 ^ \
41                                       (stri)->size))
42 
43 
44 void toLower (const strElemType *const stri, memSizeType length,
45     strElemType *const dest);
46 void toUpper (const strElemType *const stri, memSizeType length,
47     strElemType *const dest);
48 striType concatPath (const const_striType absolutePath,
49     const const_striType relativePath);
50 striType straightenAbsolutePath (const const_striType absolutePath);
51 void strAppend (striType *const destination, const_striType extension);
52 void strAppendN (striType *const destination,
53     const const_striType extensionArray[], memSizeType arraySize);
54 void strAppendTemp (striType *const destination, const striType extension);
55 striType strChChRepl (const const_striType mainStri,
56     const charType searched, const charType replacement);
57 intType strChIPos (const const_striType mainStri, const charType searched,
58     const intType fromIndex);
59 striType strChMult (const charType ch, const intType factor);
60 intType strChPos (const const_striType mainStri, const charType searched);
61 striType strChRepl (const const_striType mainStri,
62     const charType searched, const const_striType replacement);
63 /* rtlArrayType strChSplit (const const_striType mainStri,
64     const charType delimiter); */
65 striType strCLit (const const_striType stri);
66 intType strCompare (const const_striType stri1, const const_striType stri2);
67 striType strConcat (const const_striType stri1, const const_striType stri2);
68 striType strConcatChar (const const_striType stri1, const charType aChar);
69 striType strConcatCharTemp (striType stri1, const charType aChar);
70 striType strConcatN (const const_striType striArray[], memSizeType arraySize);
71 striType strConcatTemp (striType stri1, const const_striType stri2);
72 void strCopy (striType *const dest, const const_striType source);
73 striType strCreate (const const_striType source);
74 void strDestr (const const_striType old_string);
75 striType strEmpty (void);
76 boolType strGe (const const_striType stri1, const const_striType stri2);
77 boolType strGt (const const_striType stri1, const const_striType stri2);
78 intType strHashCode (const const_striType stri);
79 #if ALLOW_STRITYPE_SLICES
80 void strHeadSlice (const const_striType stri, const intType stop, striType slice);
81 #endif
82 striType strHead (const const_striType stri, const intType stop);
83 striType strHeadTemp (const striType stri, const intType stop);
84 intType strIPos (const const_striType mainStri, const const_striType searched,
85     const intType fromIndex);
86 boolType strLe (const const_striType stri1, const const_striType stri2);
87 striType strLit (const const_striType stri);
88 striType strLow (const const_striType stri);
89 striType strLowTemp (const striType stri);
90 striType strLpad (const const_striType stri, const intType padSize);
91 striType strLpadTemp (const striType stri, const intType padSize);
92 striType strLpad0 (const const_striType stri, const intType padSize);
93 striType strLpad0Temp (const striType stri, const intType padSize);
94 boolType strLt (const const_striType stri1, const const_striType stri2);
95 striType strLtrim (const const_striType stri);
96 striType strMult (const const_striType stri, const intType factor);
97 intType strPos (const const_striType mainStri, const const_striType searched);
98 void strPush (striType *const destination, const charType extension);
99 #if ALLOW_STRITYPE_SLICES
100 void strRangeSlice (const const_striType stri, intType start, intType stop, striType slice);
101 #endif
102 striType strRange (const const_striType stri, intType start, intType stop);
103 intType strRChIPos (const const_striType mainStri, const charType searched,
104     const intType fromIndex);
105 intType strRChPos (const const_striType mainStri, const charType searched);
106 striType strRepl (const const_striType mainStri,
107     const const_striType searched, const const_striType replace);
108 intType strRIPos (const const_striType mainStri, const const_striType searched,
109     const intType fromIndex);
110 striType strRpad (const const_striType stri, const intType padSize);
111 intType strRPos (const const_striType mainStri, const const_striType searched);
112 striType strRtrim (const const_striType stri);
113 /* rtlArrayType strSplit (const const_striType main_stri,
114     const const_striType delimiter); */
115 #if ALLOW_STRITYPE_SLICES
116 void strSubstrSlice (const const_striType stri, intType start, intType len, striType slice);
117 #endif
118 striType strSubstr (const const_striType stri, intType start, intType len);
119 #if ALLOW_STRITYPE_SLICES
120 void strTailSlice (const const_striType stri, intType start, striType slice);
121 #endif
122 striType strTail (const const_striType stri, intType start);
123 striType strTailTemp (const striType stri, intType start);
124 striType strToUtf8 (const const_striType stri);
125 striType strTrim (const const_striType stri);
126 striType strUp (const const_striType stri);
127 striType strUpTemp (const striType stri);
128 striType strUtf8ToStri (const const_striType utf8);
129 striType strZero (const intType factor);
130