mruby/c VM Source Code release 4.0.0
Loading...
Searching...
No Matches
c_string.c File Reference

mruby/c String class More...

#include "mrubyc.h"
#include "_autogen_unicode_case.h"
#include "_autogen_class_string.h"
Include dependency graph for c_string.c:

Go to the source code of this file.

Data Structures

struct  tr_pattern

Functions

static int is_space (int ch)
mrbc_value mrbc_string_new (mrbc_vm *vm, const void *src, int len)
mrbc_value mrbc_string_new_alloc (mrbc_vm *vm, void *buf, int len)
void mrbc_string_delete (mrbc_value *str)
void mrbc_string_clear (mrbc_value *str)
mrbc_value mrbc_string_dup (mrbc_vm *vm, mrbc_value *s1)
mrbc_value mrbc_string_add (mrbc_vm *vm, const mrbc_value *s1, const mrbc_value *s2)
int mrbc_string_append (mrbc_value *s1, const mrbc_value *s2)
int mrbc_string_append_cbuf (mrbc_value *s1, const void *s2, int len2)
int mrbc_string_index (const mrbc_value *src, const mrbc_value *pattern, int offset)
int mrbc_string_strip (mrbc_value *src, int mode)
int mrbc_string_chomp (mrbc_value *src)
int mrbc_string_upcase (mrbc_value *str)
int mrbc_string_downcase (mrbc_value *str)
static int string_slice_parse (mrbc_vm *vm, mrbc_value v[], int argc, int target_len, int *pos, int *len)
static void tr_free_pattern (struct tr_pattern *pat)
static struct tr_patterntr_parse_pattern (mrbc_vm *vm, const mrbc_value *v_pattern, int flag_reverse_enable)
static int tr_find_character (const struct tr_pattern *pat, int ch)
static int tr_get_character (const struct tr_pattern *pat, int n_th)
static int tr_main (mrbc_vm *vm, mrbc_value v[], int argc)

Detailed Description

mruby/c String class

Copyright (C) 2015-      Kyushu Institute of Technology.
Copyright (C) 2015-2026  Shimane IT Open-Innovation Center.
Copyright (C) 2026-      Shimane Institute for Industrial Technology.

This file is distributed under BSD 3-Clause License.

Definition in file c_string.c.

Function Documentation

◆ is_space()

int is_space ( int ch)
static

white space character test

Parameters
chcharacter code.
Returns
result.

Definition at line 44 of file c_string.c.

Here is the caller graph for this function:

◆ mrbc_string_add()

mrbc_value mrbc_string_add ( mrbc_vm * vm,
const mrbc_value * s1,
const mrbc_value * s2 )

add string (s1 + s2)

Parameters
vmpointer to VM.
s1pointer to target value 1
s2pointer to target value 2
Returns
new string as s1 + s2

Definition at line 164 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_append()

int mrbc_string_append ( mrbc_value * s1,
const mrbc_value * s2 )

append string (s1 += s2)

Parameters
s1pointer to target value 1
s2pointer to target value 2
Returns
mrbc_error_code

Definition at line 184 of file c_string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_string_append_cbuf()

int mrbc_string_append_cbuf ( mrbc_value * s1,
const void * s2,
int len2 )

append c buffer (s1 += s2)

Parameters
s1pointer to target value 1
s2pointer to buffer
len2buffer size
Returns
mrbc_error_code

Definition at line 212 of file c_string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_string_chomp()

int mrbc_string_chomp ( mrbc_value * src)

remove the CR,LF in myself

Parameters
srcpointer to target value
Returns
0 when not removed.

Definition at line 304 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_clear()

void mrbc_string_clear ( mrbc_value * str)

clear content

Definition at line 118 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_delete()

void mrbc_string_delete ( mrbc_value * str)

destructor

Parameters
strpointer to target value

Definition at line 107 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_downcase()

int mrbc_string_downcase ( mrbc_value * str)

downcase myself (ASCII-only version)

Parameters
strpointer to target value
Returns
count number of downcased characters

Definition at line 356 of file c_string.c.

◆ mrbc_string_dup()

mrbc_value mrbc_string_dup ( mrbc_vm * vm,
mrbc_value * s1 )

duplicate string

Parameters
vmpointer to VM.
s1pointer to target value
Returns
new string as s1 + s2

Definition at line 145 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_index()

int mrbc_string_index ( const mrbc_value * src,
const mrbc_value * pattern,
int offset )

locate a substring in a string

Parameters
srcpointer to target string
patternpointer to substring
offsetsearch offset
Returns
position index. or minus value if not found.

Definition at line 239 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_new()

mrbc_value mrbc_string_new ( mrbc_vm * vm,
const void * src,
int len )

constructor

Parameters
vmpointer to VM.
srcsource string or NULL
lensource length
Returns
string object

Definition at line 64 of file c_string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_string_new_alloc()

mrbc_value mrbc_string_new_alloc ( mrbc_vm * vm,
void * buf,
int len )

constructor by allocated buffer

Parameters
vmpointer to VM.
bufpointer to allocated buffer
lenlength
Returns
string object

Definition at line 88 of file c_string.c.

Here is the caller graph for this function:

◆ mrbc_string_strip()

int mrbc_string_strip ( mrbc_value * src,
int mode )

remove the whitespace in myself

Parameters
srcpointer to target value
mode1:left-side, 2:right-side, 3:each
Returns
0 when not removed.

Definition at line 264 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_upcase()

int mrbc_string_upcase ( mrbc_value * str)

upcase myself (ASCII-only version)

Parameters
strpointer to target value
Returns
count number of upcased characters

Definition at line 334 of file c_string.c.

◆ string_slice_parse()

int string_slice_parse ( mrbc_vm * vm,
mrbc_value v[],
int argc,
int target_len,
int * pos,
int * len )
static

Definition at line 961 of file c_string.c.

Here is the call graph for this function:

◆ tr_find_character()

int tr_find_character ( const struct tr_pattern * pat,
int ch )
static

Definition at line 2074 of file c_string.c.

Here is the caller graph for this function:

◆ tr_free_pattern()

void tr_free_pattern ( struct tr_pattern * pat)
static

Definition at line 2009 of file c_string.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tr_get_character()

int tr_get_character ( const struct tr_pattern * pat,
int n_th )
static

Definition at line 2098 of file c_string.c.

Here is the caller graph for this function:

◆ tr_main()

int tr_main ( mrbc_vm * vm,
mrbc_value v[],
int argc )
static

Definition at line 2116 of file c_string.c.

Here is the call graph for this function:

◆ tr_parse_pattern()

struct tr_pattern * tr_parse_pattern ( mrbc_vm * vm,
const mrbc_value * v_pattern,
int flag_reverse_enable )
static

Definition at line 2018 of file c_string.c.

Here is the call graph for this function:
Here is the caller graph for this function: