-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFabricPyString.cpp
More file actions
216 lines (169 loc) · 6.02 KB
/
Copy pathFabricPyString.cpp
File metadata and controls
216 lines (169 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//
// Copyright (c) 2014, Nile Hylton <[email protected]> All rights reserved.
//
#include <Fabric/EDK/EDK.h>
#include <pystring.h>
#include <string>
#include <vector>
using namespace Fabric::EDK;
IMPLEMENT_FABRIC_EDK_ENTRIES( FabricPyString )
#define MAX_32BIT_INT 2147483647
FABRIC_EXT_EXPORT KL::String FabricPyString_capitalize( const KL::String &str ) {
KL::String result;
result = pystring::capitalize( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_center( const KL::String &str, const KL::Integer width ) {
KL::String result;
result = pystring::center( str.c_str(), width );
return result;
}
FABRIC_EXT_EXPORT KL::Integer FabricPyString_count( const KL::String &str, const KL::String &substr ) {
KL::Integer result;
result = pystring::count( str.c_str(), substr.c_str(), 0, MAX_32BIT_INT );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_endswith( const KL::String &str, const KL::String &suffix ) {
KL::Boolean result;
result = pystring::endswith( str.c_str(), suffix.c_str(), 0, MAX_32BIT_INT );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_expandtabs( const KL::String &str ) {
KL::String result;
result = pystring::expandtabs( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Integer FabricPyString_find( const KL::String &str, const KL::String &substr ) {
KL::Integer result;
result = pystring::find( str.c_str(), substr.c_str(), 0, MAX_32BIT_INT );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_isalpha( const KL::String &str ) {
KL::Boolean result;
result = pystring::isalpha( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_isdigit( const KL::String &str ) {
KL::Boolean result;
result = pystring::isdigit( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_islower( const KL::String &str ) {
KL::Boolean result;
result = pystring::islower( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_isspace( const KL::String &str ) {
KL::Boolean result;
result = pystring::isspace( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_istitle( const KL::String &str ) {
KL::Boolean result;
result = pystring::istitle( str.c_str() );
return result;
}
//FABRIC_EXT_EXPORT KL::String FabricPyString_join( const KL::String &str, const std::vector< KL::String > &seq ) {
// KL::String result;
// result = pystring::join( str.c_str(), seq );
// return result;
//}
FABRIC_EXT_EXPORT KL::String FabricPyString_ljust( const KL::String &str, const KL::Integer width ) {
KL::String result;
result = pystring::ljust( str.c_str(), width );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_lower( const KL::String &str ) {
KL::String result;
result = pystring::lower( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_lstrip( const KL::String &str, const KL::String &chars ) {
KL::String result;
result = pystring::lstrip( str.c_str(), chars.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_mul( const KL::String &str, const KL::Integer n ) {
KL::String result;
result = pystring::mul( str.c_str(), n );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_replace( const KL::String &str,
const KL::String &oldstr, const KL::String &newstr ) {
KL::String result;
result = pystring::replace( str.c_str(), oldstr.c_str(), newstr.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::Integer FabricPyString_rfind( const KL::String &str, const KL::String &sub ) {
KL::Integer result;
result = pystring::rfind( str.c_str(), sub.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_rjust( const KL::String &str, const KL::Integer width ) {
KL::String result;
result = pystring::rjust( str.c_str(), width );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_rstrip( const KL::String &str, const KL::String &chars ) {
KL::String result;
result = pystring::rstrip( str.c_str(), chars.c_str() );
return result;
}
FABRIC_EXT_EXPORT void FabricPyString_split( KL::VariableArray< KL::String > &kl,
const KL::String &str, const KL::String &sep="" ) {
std::vector<std::string> stdResult;
pystring::split( str.c_str(), stdResult, sep.c_str() );
std::string line;
for( unsigned int i = 0; i < stdResult.size(); i++ )
{
line = stdResult[i];
kl.push_back( line );
}
}
FABRIC_EXT_EXPORT void FabricPyString_splitlines( KL::VariableArray< KL::String > &kl,
const KL::String &str, const KL::Boolean keepends ) {
std::vector<std::string> stdResult;
pystring::splitlines( str.c_str(), stdResult, keepends );
std::string line;
for( unsigned int i = 0; i < stdResult.size(); i++ )
{
line = stdResult[i];
kl.push_back( line );
}
}
FABRIC_EXT_EXPORT KL::Boolean FabricPyString_startswith( const KL::String &str, const KL::String &prefix ) {
KL::Boolean result;
result = pystring::startswith( str.c_str(), prefix.c_str(), 0, MAX_32BIT_INT );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_strip( const KL::String &str, const KL::String &chars ) {
KL::String result;
result = pystring::strip( str.c_str(), chars.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_swapcase( const KL::String &str ) {
KL::String result;
result = pystring::swapcase( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_title( const KL::String &str ) {
KL::String result;
result = pystring::title( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_upper( const KL::String &str ) {
KL::String result;
result = pystring::upper( str.c_str() );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_zfill( const KL::String &str, const KL::Integer width ) {
KL::String result;
result = pystring::zfill( str.c_str(), width );
return result;
}
FABRIC_EXT_EXPORT KL::String FabricPyString_slice( const KL::String &str,
const KL::Integer start=0, const KL::Integer end=MAX_32BIT_INT ) {
KL::String result;
result = pystring::slice( str.c_str(), start, end );
return result;
}