/Include/bytes_methods.h

http://unladen-swallow.googlecode.com/ · C++ Header · 84 lines · 65 code · 12 blank · 7 comment · 0 complexity · 78af81393aa1da38e850d03b3a677cd3 MD5 · raw file

  1. #ifndef Py_BYTES_CTYPE_H
  2. #define Py_BYTES_CTYPE_H
  3. /*
  4. * The internal implementation behind PyString (bytes) and PyBytes (buffer)
  5. * methods of the given names, they operate on ASCII byte strings.
  6. */
  7. extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
  8. extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
  9. extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
  10. extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
  11. extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
  12. extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
  13. extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
  14. /* These store their len sized answer in the given preallocated *result arg. */
  15. extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
  16. extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
  17. extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
  18. extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
  19. extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
  20. /* Shared __doc__ strings. */
  21. extern const char _Py_isspace__doc__[];
  22. extern const char _Py_isalpha__doc__[];
  23. extern const char _Py_isalnum__doc__[];
  24. extern const char _Py_isdigit__doc__[];
  25. extern const char _Py_islower__doc__[];
  26. extern const char _Py_isupper__doc__[];
  27. extern const char _Py_istitle__doc__[];
  28. extern const char _Py_lower__doc__[];
  29. extern const char _Py_upper__doc__[];
  30. extern const char _Py_title__doc__[];
  31. extern const char _Py_capitalize__doc__[];
  32. extern const char _Py_swapcase__doc__[];
  33. #define FLAG_LOWER 0x01
  34. #define FLAG_UPPER 0x02
  35. #define FLAG_ALPHA (FLAG_LOWER|FLAG_UPPER)
  36. #define FLAG_DIGIT 0x04
  37. #define FLAG_ALNUM (FLAG_ALPHA|FLAG_DIGIT)
  38. #define FLAG_SPACE 0x08
  39. #define FLAG_XDIGIT 0x10
  40. extern const unsigned int _Py_ctype_table[256];
  41. #define ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_LOWER)
  42. #define ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_UPPER)
  43. #define ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALPHA)
  44. #define ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_DIGIT)
  45. #define ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_XDIGIT)
  46. #define ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALNUM)
  47. #define ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_SPACE)
  48. #undef islower
  49. #define islower(c) undefined_islower(c)
  50. #undef isupper
  51. #define isupper(c) undefined_isupper(c)
  52. #undef isalpha
  53. #define isalpha(c) undefined_isalpha(c)
  54. #undef isdigit
  55. #define isdigit(c) undefined_isdigit(c)
  56. #undef isxdigit
  57. #define isxdigit(c) undefined_isxdigit(c)
  58. #undef isalnum
  59. #define isalnum(c) undefined_isalnum(c)
  60. #undef isspace
  61. #define isspace(c) undefined_isspace(c)
  62. extern const unsigned char _Py_ctype_tolower[256];
  63. extern const unsigned char _Py_ctype_toupper[256];
  64. #define TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
  65. #define TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
  66. #undef tolower
  67. #define tolower(c) undefined_tolower(c)
  68. #undef toupper
  69. #define toupper(c) undefined_toupper(c)
  70. /* this is needed because some docs are shared from the .o, not static */
  71. #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
  72. #endif /* !Py_BYTES_CTYPE_H */