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

mruby/c String class More...

#include "mrubyc.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 (struct VM *vm, const void *src, int len)
mrbc_value mrbc_string_new_alloc (struct 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 (struct VM *vm, mrbc_value *s1)
mrbc_value mrbc_string_add (struct 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 void tr_free_pattern (struct tr_pattern *pat)
static struct tr_patterntr_parse_pattern (struct 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 (struct VM *vm, mrbc_value v[], int argc)

Detailed Description

mruby/c String class

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

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 42 of file c_string.c.

Here is the caller graph for this function:

◆ mrbc_string_add()

mrbc_value mrbc_string_add ( struct 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 188 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 210 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 240 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 334 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 140 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 129 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

Parameters
strpointer to target value
Returns
count number of downcased characters

Definition at line 385 of file c_string.c.

◆ mrbc_string_dup()

mrbc_value mrbc_string_dup ( struct VM * vm,
mrbc_value * s1 )

duplicate string

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

Definition at line 167 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 269 of file c_string.c.

Here is the call graph for this function:

◆ mrbc_string_new()

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

constructor

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

Definition at line 62 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 ( struct 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 105 of file c_string.c.

◆ 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 294 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

Parameters
strpointer to target value
Returns
count number of upcased characters

Definition at line 363 of file c_string.c.

◆ tr_find_character()

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

Definition at line 1200 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 1131 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 1224 of file c_string.c.

Here is the caller graph for this function:

◆ tr_main()

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

Definition at line 1242 of file c_string.c.

Here is the call graph for this function:

◆ tr_parse_pattern()

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

Definition at line 1140 of file c_string.c.

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