From 7f9b6dd18ffc51ffc7c3b56f63bf7347552dd721 Mon Sep 17 00:00:00 2001 From: "Ralph Desir(Mav7)" Date: Sun, 28 Aug 2016 03:19:48 -0400 Subject: [PATCH] updated doc for string.h --- docs/api/headers/mruby_2Fstring.h.html | 1146 ++++++++++++++++++++++-- 1 file changed, 1060 insertions(+), 86 deletions(-) diff --git a/docs/api/headers/mruby_2Fstring.h.html b/docs/api/headers/mruby_2Fstring.h.html index 15fefa2..357537a 100644 --- a/docs/api/headers/mruby_2Fstring.h.html +++ b/docs/api/headers/mruby_2Fstring.h.html @@ -129,7 +129,8 @@

-
+

Appends self to other.

+
@@ -288,7 +289,8 @@

-
+

Returns the length of the Ruby string.

+
@@ -323,7 +325,7 @@

-

Returns a symbol from a passed in string.

+

Returns a symbol from a passed in Ruby string.

@@ -674,6 +676,11 @@

Define Summary

+
#define MRB_STR_NO_UTF + +
+
+
#define MRB_STR_EMBED
@@ -744,69 +751,118 @@

+
+
+

Appends self to other. Returns self as a concatnated string.

-
+

Example:

- -
-

- mrb_value mrb_str_plus(mrb_state* , mrb_value , mrb_value ) +
int
+main(int argc,
+     char **argv)
+{
+  // Variable declarations.
+  mrb_value str1;
+  mrb_value str2;
 
-  
-

-
-
-

Adds two strings together.

+ mrb_state *mrb = mrb_open(); + if (!mrb) + { + // handle error + } + // Creates new Ruby strings. + str1 = mrb_str_new_cstr(mrb, "abc"); + str2 = mrb_str_new_cstr(mrb, "def"); -
-
-
- + // Concatnates str2 to str1. + mrb_str_concat(mrb, str1, str2); -
+ // Prints new Concatnated Ruby string. + mrb_p(mrb, str1); + mrb_close(mrb); + return 0; +
-
+

}

- -
-

- mrb_value mrb_ptr_to_str(mrb_state * , void* ) +

Result:

- -

-
-
-

Converts pointer into a Ruby string.

+
=> "abcdef"
+
+

Parameters:

+
    - +
  • + + mrb + + + (mrb_state) + + + + — +

    The current mruby state.

    - - + +
  • + +
  • + + self + + + (mrb_value) + + + + — +

    String to concatenate.

    - + +
  • -
    -

    - mrb_value mrb_obj_as_string(mrb_state * mrb, mrb_value obj) - +
  • + + other + + + (mrb_value) + + + + — +

    String to append to self.

    +
    + +
  • -

    -
    -
    -

    Returns an object as a Ruby string.

    - +
-
+

Returns:

+
    + +
  • + + + (mrb_value) + + + + — +

    Returns a new String appending other to self.

    -
    + +
  • +
@@ -815,42 +871,130 @@

-

- mrb_value mrb_str_resize(mrb_state * mrb, mrb_value str, mrb_int len) +

+ mrb_value mrb_str_plus(mrb_state* , mrb_value , mrb_value )

-

Resizes the string's length.

+

Adds two strings together.

+

Example:

-
-
-
- +
int
+main(int argc,
+     char **argv)
+{
+  // Variable declarations.
+  mrb_value a;
+  mrb_value b;
+  mrb_value c;
 
-
+ mrb_state *mrb = mrb_open(); + if (!mrb) + { + // handle error + } + // Creates two Ruby strings from the passed in C strings. + a = mrb_str_new_cstr(mrb, "abc"); + b = mrb_str_new_cstr(mrb, "def"); -
+ // Prints both C strings. + mrb_p(mrb, a); + mrb_p(mrb, b); - -
-

- mrb_value mrb_str_substr(mrb_state * mrb, mrb_value str, mrb_int beg, mrb_int len) + // Concatnates both Ruby strings. + c = mrb_str_plus(mrb, a, b); - -

-
-
-

Returns a sub string.

+ // Prints new Concatnated Ruby string. + mrb_p(mrb, c); + + mrb_close(mrb); + return 0; +
+ +

}

+ +

Result:

+ +
=> "abc"  # First string
+=> "def"  # Second string
+=> "abcdef" # First & Second concatnated.
+
+

Parameters:

+
    + +
  • + + mrb + + + (mrb_state) + + + + — +

    The current mruby state.

    +
    + +
  • + +
  • + + a + + + (mrb_value) + + + + — +

    First string to concatenate.

    +
    + +
  • + +
  • + + b + + + (mrb_value) + + + + — +

    Second string to concatenate.

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (mrb_value) + + + + — +

    Returns a new String containing a concatenated to b.

    +
    + +
  • +
@@ -859,53 +1003,568 @@

-

- mrb_value mrb_string_type(mrb_state * mrb, mrb_value str) +

+ mrb_value mrb_ptr_to_str(mrb_state * , void* )

-

Returns a Ruby string type.

+

Converts pointer into a Ruby string.

+

Parameters:

+
    - +
  • + + mrb + + + (mrb_state) + + + + — +

    The current mruby state.

    - - + +
  • + +
  • + + p + + + (void*) + + + + — +

    The pointer to convert to Ruby string.

    - + +
  • -
    -

    - mrb_value mrb_check_string_type(mrb_state * mrb, mrb_value str) +

+

Returns:

+
    -

- +
  • + + + (mrb_value) + + + + — +

    Returns a new Ruby String.

    - + +
  • -
    -

    - mrb_value mrb_str_buf_new(mrb_state * mrb, size_t capa) + + +

    - -

    -

    - mrb_int mrb_string_value_len(mrb_state * mrb, mrb_value str) +

    + mrb_value mrb_obj_as_string(mrb_state * mrb, mrb_value obj)

    +
    +
    +

    Returns an object as a Ruby string.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + obj + + + (mrb_value) + + + + — +

      An object to return as a Ruby string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      An object as a Ruby string.

      +
      + +
    • + +
    + +
    + + +
    + + +
    +

    + mrb_value mrb_str_resize(mrb_state * mrb, mrb_value str, mrb_int len) + + +

    +
    +
    +

    Resizes the string's length. Returns the amount of characters +in the specified by len.

    + +

    Example:

    + +
    int
    +main(int argc,
    +     char **argv)
    +{
    +    // Variable declaration.
    +    mrb_value str;
    +
    +    mrb_state *mrb = mrb_open();
    +    if (!mrb)
    +    {
    +       // handle error
    +    }
    +    // Creates a new string.
    +    str = mrb_str_new_cstr(mrb, "Hello, world!");
    +    // Returns 5 characters of
    +    mrb_str_resize(mrb, str, 5);
    +    mrb_p(mrb, str);
    +
    +    mrb_close(mrb);
    +    return 0;
    + }
    +
    + +

    Result:

    + +
    => "Hello"
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      The Ruby string to resize.

      +
      + +
    • + +
    • + + len + + + (mrb_value) + + + + — +

      The length.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      An object as a Ruby string.

      +
      + +
    • + +
    + +
    + + +
    + + +
    +

    + mrb_value mrb_str_substr(mrb_state * mrb, mrb_value str, mrb_int beg, mrb_int len) + + +

    +
    +
    +

    Returns a sub string.

    + +

    Example:

    + +
    int
    +main(int argc,
    +char const **argv)
    +{
    +  // Variable declarations.
    +  mrb_value str1;
    +  mrb_value str2;
    +
    +  mrb_state *mrb = mrb_open();
    +  if (!mrb)
    +  {
    +    // handle error
    +  }
    +  // Creates new string.
    +  str1 = mrb_str_new_cstr(mrb, "Hello, world!");
    +  // Returns a sub-string within the range of 0..2
    +  str2 = mrb_str_substr(mrb, str1, 0, 2);
    +
    +  // Prints sub-string.
    +  mrb_p(mrb, str2);
    +
    +  mrb_close(mrb);
    +  return 0;
    +}
    +
    + +

    Result:

    + +
    => "He"
    +
    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    • + + beg + + + (mrb_int) + + + + — +

      The beginning point of the sub-string.

      +
      + +
    • + +
    • + + len + + + (mrb_int) + + + + — +

      The end point of the sub-string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      An object as a Ruby sub-string.

      +
      + +
    • + +
    + +
    + + +
    + + +
    +

    + mrb_value mrb_string_type(mrb_state * mrb, mrb_value str) + + +

    +
    +
    +

    Returns a Ruby string type.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      A Ruby string.

      +
      + +
    • + +
    + +
    + + +
    + + +
    +

    + mrb_value mrb_check_string_type(mrb_state * mrb, mrb_value str) + + +

    + +
    + + +
    +

    + mrb_value mrb_str_buf_new(mrb_state * mrb, size_t capa) + + +

    + +
    + + +
    +

    + mrb_int mrb_string_value_len(mrb_state * mrb, mrb_value str) + + +

    +
    +
    +

    Returns the length of the Ruby string.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_int) + + + + — +

      The length of the passed in Ruby string.

      +
      + +
    • + +
    + +
    +
    @@ -921,10 +1580,61 @@

    Duplicates a string object.

    -

    + + +
    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      Duplicated Ruby string.

      -
      + +
    • +
    @@ -940,13 +1650,64 @@

    -

    Returns a symbol from a passed in string.

    +

    Returns a symbol from a passed in Ruby string.

    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + self + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      A symbol.

      +
      + +
    • +
    @@ -1010,7 +1771,73 @@

    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str1 + + + (mrb_value) + + + + — +

      Ruby string to compare.

      +
      + +
    • + +
    • + + str2 + + + (mrb_value) + + + + — +

      Ruby string to compare.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      boolean value.

      +
      + +
    • +
    @@ -1032,7 +1859,88 @@

    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    • + + ptr + + + (const char *) + + + + — +

      A C string.

      +
      + +
    • + +
    • + + len + + + (size_t) + + + + — +

      length of C string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      A Ruby string.

      +
      + +
    • +

    See Also:

      @@ -1061,7 +1969,73 @@

    +

    Parameters:

    +
      + +
    • + + mrb + + + (mrb_state) + + + + — +

      The current mruby state.

      +
      + +
    • + +
    • + + str + + + (mrb_value) + + + + — +

      Ruby string.

      +
      + +
    • + +
    • + + ptr + + + (const char *) + + + + — +

      A C string.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (mrb_value) + + + + — +

      A Ruby string.

      +
      + +
    • +

    See Also:

      @@ -1217,9 +2191,9 @@