Ruby: include/ruby/internal/encoding/string.h Source File

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

string.h
Go to the documentation of this file.
1#ifndef RUBY_INTERNAL_ENCODING_STRING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_INTERNAL_ENCODING_STRING_H
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/value.h"
26#include "ruby/internal/encoding/encoding.h"
27#include "ruby/internal/attr/nonnull.h"
28#include "ruby/internal/intern/string.h" /* rbimpl_strlen */
29
30 RBIMPL_SYMBOL_EXPORT_BEGIN()
31
32
48 VALUE rb_enc_str_new(const char *ptr, long len, rb_encoding *enc);
49
50 RBIMPL_ATTR_NONNULL((1))
67 VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc);
68
87 VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc);
88
106 VALUE rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc);
107
108 RBIMPL_ATTR_NONNULL((1))
122 VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc);
123
136long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc);
137
152char *rb_enc_nth(const char *head, const char *tail, long nth, rb_encoding *enc);
153
161 VALUE rb_obj_encoding(VALUE obj);
162
176 VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
177
196 VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
197
224 VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc);
225
234 VALUE rb_str_export_to_enc(VALUE obj, rb_encoding *enc);
235
246 VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
247
264 VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
265
275int rb_enc_str_coderange(VALUE str);
276
292long rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr);
293
304int rb_enc_str_asciionly_p(VALUE str);
305
306 RBIMPL_ATTR_NONNULL(())
319long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc);
320
322 RBIMPL_ATTR_NONNULL(())
323static inline VALUE
324rbimpl_enc_str_new_cstr(const char *str, rb_encoding *enc)
325{
326 long len = rbimpl_strlen(str);
327
328 return rb_enc_str_new_static(str, len, enc);
329}
330
331#define rb_enc_str_new(str, len, enc) \
332 ((RBIMPL_CONSTANT_P(str) && \
333 RBIMPL_CONSTANT_P(len) ? \
334 rb_enc_str_new_static: \
335 rb_enc_str_new) ((str), (len), (enc)))
336
337#define rb_enc_str_new_cstr(str, enc) \
338 ((RBIMPL_CONSTANT_P(str) ? \
339 rbimpl_enc_str_new_cstr : \
340 rb_enc_str_new_cstr) ((str), (enc)))
341
344 RBIMPL_SYMBOL_EXPORT_END()
345
346#endif /* RUBY_INTERNAL_ENCODING_STRING_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
encoding.h
Defines rb_encoding.
rb_str_conv_enc
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Encoding conversion main routine.
Definition string.c:1149
rb_enc_uint_chr
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
Encodes the passed code point into a series of bytes.
Definition numeric.c:3739
rb_enc_str_new_static
VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
Identical to rb_enc_str_new(), except it takes a C string literal.
Definition string.c:1015
rb_enc_nth
char * rb_enc_nth(const char *head, const char *tail, long nth, rb_encoding *enc)
Queries the n-th character.
Definition string.c:2757
rb_str_conv_enc_opts
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
Identical to rb_str_conv_enc(), except it additionally takes IO encoder options.
Definition string.c:1034
rb_enc_interned_str
VALUE rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc)
Identical to rb_enc_str_new(), except it returns a "f"string.
Definition string.c:12088
rb_memsearch
long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc)
Looks for the passed string in the passed buffer.
Definition re.c:252
rb_enc_strlen
long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc)
Counts the number of characters of the passed string, according to the passed encoding.
Definition string.c:2101
rb_enc_str_new_cstr
VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)
Identical to rb_enc_str_new(), except it assumes the passed pointer is a pointer to a C string.
Definition string.c:962
rb_str_export_to_enc
VALUE rb_str_export_to_enc(VALUE obj, rb_encoding *enc)
Identical to rb_str_export(), except it additionally takes an encoding.
Definition string.c:1254
rb_external_str_new_with_enc
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc)
Identical to rb_external_str_new(), except it additionally takes an encoding.
Definition string.c:1155
rb_enc_str_asciionly_p
int rb_enc_str_asciionly_p(VALUE str)
Queries if the passed string is "ASCII only".
Definition string.c:781
rb_obj_encoding
VALUE rb_obj_encoding(VALUE obj)
Identical to rb_enc_get_index(), except the return type.
Definition encoding.c:1147
rb_enc_interned_str_cstr
VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc)
Identical to rb_enc_str_new_cstr(), except it returns a "f"string.
Definition string.c:12099
rb_str_coderange_scan_restartable
long rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr)
Scans the passed string until it finds something odd.
Definition string.c:653
string.h
Public APIs related to rb_cString.
len
int len
Length of the buffer.
Definition io.h:8
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:66
OnigEncodingTypeST
Definition onigmo.h:160
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40