Ruby: include/ruby/internal/core/rstring.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Enumerations | Functions
rstring.h File Reference

Defines struct RString. More...

`#include "ruby/internal/config.h"`
`#include "ruby/internal/arithmetic/long.h"`
`#include "ruby/internal/attr/artificial.h"`
`#include "ruby/internal/attr/pure.h"`
`#include "ruby/internal/cast.h"`
`#include "ruby/internal/core/rbasic.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/fl_type.h"`
`#include "ruby/internal/value_type.h"`
`#include "ruby/internal/warning_push.h"`
`#include "ruby/assert.h"`

Go to the source code of this file.

## Data Structures
struct | RString

## Macros
#define | RSTRING(obj) RBIMPL_CAST((struct RString *)(obj))
#define | RSTRING_NOEMBED RSTRING_NOEMBED
#define | RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK
#define | RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT
#define | RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX
#define | RSTRING_FSTR RSTRING_FSTR
#define | StringValue(v) rb_string_value(&(v))
#define | StringValuePtr(v) rb_string_value_ptr(&(v))
#define | StringValueCStr(v) rb_string_value_cstr(&(v))
#define | SafeStringValue(v) StringValue(v)
#define | ExportStringValue(v)
#define | Check_SafeStr(v) rb_check_safe_str(RBIMPL_CAST((VALUE)(v)))
#define | RSTRING_GETMEM(str, ptrvar, lenvar)

## Enumerations
enum | ruby_rstring_flags { RSTRING_NOEMBED = RUBY_FL_USER1 , RSTRING_EMBED_LEN_MASK , RSTRING_FSTR = RUBY_FL_USER17 }
enum | ruby_rstring_consts { RSTRING_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 2 , RSTRING_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(char) - 1 }

## Functions
VALUE | rb_str_to_str (VALUE)
VALUE | rb_string_value (volatile VALUE *)
char * | rb_string_value_ptr (volatile VALUE *)
char * | rb_string_value_cstr (volatile VALUE *)
VALUE | rb_str_export (VALUE)
VALUE | rb_str_export_locale (VALUE)
| RBIMPL_ATTR_ERROR (("rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead")) void rb_check_safe_str(VALUE)

## Detailed Description

Defines struct RString.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file rstring.h.

## Macro Definition Documentation

## ◆ Check_SafeStr

#define Check_SafeStr | ( |  | v | ) | rb_check_safe_str(RBIMPL_CAST((VALUE)(v)))

Definition at line 98 of file rstring.h.

## ◆ ExportStringValue

#define ExportStringValue | ( |  | v | ) |

Value:
do { \
StringValue(v); \
(v) = rb_str_export(v); \
} while (0)
rb_str_export
VALUE rb_str_export(VALUE)
Definition: string.c:1193

Definition at line 54 of file rstring.h.

## ◆ RSTRING

#define RSTRING | ( |  | obj | ) | RBIMPL_CAST((struct RString *)(obj))

Definition at line 35 of file rstring.h.

## ◆ RSTRING_EMBED_LEN_MASK

#define RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK

Definition at line 37 of file rstring.h.

## ◆ RSTRING_EMBED_LEN_MAX

#define RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX

Definition at line 39 of file rstring.h.

## ◆ RSTRING_EMBED_LEN_SHIFT

#define RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT

Definition at line 38 of file rstring.h.

## ◆ RSTRING_FSTR

#define RSTRING_FSTR RSTRING_FSTR

Definition at line 40 of file rstring.h.

## ◆ RSTRING_GETMEM

#define RSTRING_GETMEM | ( |  | str,
|  |  | ptrvar,
|  |  | lenvar
| ) |  |

Value:
((ptrvar) = RSTRING_PTR(str), \
(lenvar) = RSTRING_LEN(str))
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19

Definition at line 211 of file rstring.h.

## ◆ RSTRING_NOEMBED

#define RSTRING_NOEMBED RSTRING_NOEMBED

Definition at line 36 of file rstring.h.

## ◆ SafeStringValue

#define SafeStringValue | ( |  | v | ) | StringValue(v)

Definition at line 53 of file rstring.h.

## ◆ StringValue

#define StringValue | ( |  | v | ) | rb_string_value(&(v))

Definition at line 50 of file rstring.h.

## ◆ StringValueCStr

#define StringValueCStr | ( |  | v | ) | rb_string_value_cstr(&(v))

Definition at line 52 of file rstring.h.

## ◆ StringValuePtr

#define StringValuePtr | ( |  | v | ) | rb_string_value_ptr(&(v))

Definition at line 51 of file rstring.h.

## Enumeration Type Documentation

## ◆ ruby_rstring_consts

enum ruby_rstring_consts

Enumerator
RSTRING_EMBED_LEN_SHIFT |
RSTRING_EMBED_LEN_MAX |

Definition at line 68 of file rstring.h.

## ◆ ruby_rstring_flags

enum ruby_rstring_flags

Enumerator
RSTRING_NOEMBED |
RSTRING_EMBED_LEN_MASK |
RSTRING_FSTR |

Definition at line 59 of file rstring.h.

## Function Documentation

## ◆ rb_str_export()

VALUE rb_str_export | ( | VALUE | str | ) |

Definition at line 1193 of file string.c.

References rb_default_external_encoding(), rb_str_conv_enc(), str, and STR_ENC_GET.

## ◆ rb_str_export_locale()

VALUE rb_str_export_locale | ( | VALUE | str | ) |

Definition at line 1199 of file string.c.

References rb_locale_encoding(), rb_str_conv_enc(), str, and STR_ENC_GET.

## ◆ rb_str_to_str()

VALUE rb_str_to_str | ( | VALUE | str | ) |

Definition at line 1471 of file string.c.

References rb_convert_type_with_id(), str, and T_STRING.

Referenced by rb_string_value().

## ◆ rb_string_value()

VALUE rb_string_value | ( | volatile VALUE * | ptr | ) |

Definition at line 2323 of file string.c.

References ptr, rb_str_to_str(), and T_STRING.

Referenced by rb_string_value_cstr(), and rb_string_value_ptr().

## ◆ rb_string_value_cstr()

char * rb_string_value_cstr | ( | volatile VALUE * | ptr | ) |

Definition at line 2439 of file string.c.

References ptr, rb_eArgError, rb_raise(), rb_string_value(), and str.

Referenced by rb_fiddle_value_to_generic().

## ◆ rb_string_value_ptr()

char * rb_string_value_ptr | ( | volatile VALUE * | ptr | ) |

Definition at line 2334 of file string.c.

References ptr, rb_string_value(), RSTRING_PTR, and str.

## ◆ RBIMPL_ATTR_ERROR()

RBIMPL_ATTR_ERROR | ( | ("rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead") |  | ) |