pycore_bytesobject.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef Py_INTERNAL_BYTESOBJECT_H
  2. #define Py_INTERNAL_BYTESOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #ifndef Py_BUILD_CORE
  7. # error "this header requires Py_BUILD_CORE define"
  8. #endif
  9. /* Substring Search.
  10. Returns the index of the first occurrence of
  11. a substring ("needle") in a larger text ("haystack").
  12. If the needle is not found, return -1.
  13. If the needle is found, add offset to the index.
  14. */
  15. PyAPI_FUNC(Py_ssize_t)
  16. _PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
  17. const char *needle, Py_ssize_t len_needle,
  18. Py_ssize_t offset);
  19. /* Same as above, but search right-to-left */
  20. PyAPI_FUNC(Py_ssize_t)
  21. _PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
  22. const char *needle, Py_ssize_t len_needle,
  23. Py_ssize_t offset);
  24. /** Helper function to implement the repeat and inplace repeat methods on a buffer
  25. *
  26. * len_dest is assumed to be an integer multiple of len_src.
  27. * If src equals dest, then assume the operation is inplace.
  28. *
  29. * This method repeately doubles the number of bytes copied to reduce
  30. * the number of invocations of memcpy.
  31. */
  32. PyAPI_FUNC(void)
  33. _PyBytes_Repeat(char* dest, Py_ssize_t len_dest,
  34. const char* src, Py_ssize_t len_src);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* !Py_INTERNAL_BYTESOBJECT_H */