blob: 739cf3d9ebe2b640fd173e3d59a06c0abb279456 [file] [log] [blame]
Gregory P. Smith60d241f2007-10-16 06:31:30 +00001/* NOTE: this API is -ONLY- for use with single byte character strings. */
2/* Do not use it with Unicode. */
3
4#include "bytes_methods.h"
5
6static PyObject*
7stringlib_isspace(PyObject *self)
8{
9 return _Py_bytes_isspace(STRINGLIB_STR(self), STRINGLIB_LEN(self));
10}
11
12static PyObject*
13stringlib_isalpha(PyObject *self)
14{
15 return _Py_bytes_isalpha(STRINGLIB_STR(self), STRINGLIB_LEN(self));
16}
17
18static PyObject*
19stringlib_isalnum(PyObject *self)
20{
21 return _Py_bytes_isalnum(STRINGLIB_STR(self), STRINGLIB_LEN(self));
22}
23
24static PyObject*
25stringlib_isdigit(PyObject *self)
26{
27 return _Py_bytes_isdigit(STRINGLIB_STR(self), STRINGLIB_LEN(self));
28}
29
30static PyObject*
31stringlib_islower(PyObject *self)
32{
33 return _Py_bytes_islower(STRINGLIB_STR(self), STRINGLIB_LEN(self));
34}
35
36static PyObject*
37stringlib_isupper(PyObject *self)
38{
39 return _Py_bytes_isupper(STRINGLIB_STR(self), STRINGLIB_LEN(self));
40}
41
42static PyObject*
43stringlib_istitle(PyObject *self)
44{
45 return _Py_bytes_istitle(STRINGLIB_STR(self), STRINGLIB_LEN(self));
46}
47
48
49/* functions that return a new object partially translated by ctype funcs: */
50
51static PyObject*
52stringlib_lower(PyObject *self)
53{
54 PyObject* newobj;
55 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
56 if (!newobj)
57 return NULL;
58 _Py_bytes_lower(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
59 STRINGLIB_LEN(self));
60 return newobj;
61}
62
63static PyObject*
64stringlib_upper(PyObject *self)
65{
66 PyObject* newobj;
67 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
68 if (!newobj)
69 return NULL;
70 _Py_bytes_upper(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
71 STRINGLIB_LEN(self));
72 return newobj;
73}
74
75static PyObject*
76stringlib_title(PyObject *self)
77{
78 PyObject* newobj;
79 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
80 if (!newobj)
81 return NULL;
82 _Py_bytes_title(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
83 STRINGLIB_LEN(self));
84 return newobj;
85}
86
87static PyObject*
88stringlib_capitalize(PyObject *self)
89{
90 PyObject* newobj;
91 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
92 if (!newobj)
93 return NULL;
94 _Py_bytes_capitalize(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
95 STRINGLIB_LEN(self));
96 return newobj;
97}
98
99static PyObject*
100stringlib_swapcase(PyObject *self)
101{
102 PyObject* newobj;
103 newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
104 if (!newobj)
105 return NULL;
106 _Py_bytes_swapcase(STRINGLIB_STR(newobj), STRINGLIB_STR(self),
107 STRINGLIB_LEN(self));
108 return newobj;
109}