Split GRegex into GRegex and GMatchInfo. (#419368, Marco Barisione)
[platform/upstream/glib.git] / docs / reference / glib / tmpl / gregex.sgml
index e1577c2..54b6806 100644 (file)
@@ -56,10 +56,10 @@ encountered. This indicates a comment that lasts until after the next
 newline.
 </para>
 <para>
-If you have two threads manipulating the same #GRegex, they must use a
-lock to synchronize their operation, as these functions are not threadsafe.
-Creating and manipulating different #GRegex structures from different
-threads is not a problem.
+Creating and manipulating the same #GRegex structure from different
+threads is not a problem as #GRegex does not modify its internal
+state between creation and destruction, on the other hand #GMatchInfo is
+not threadsafe.
 </para>
 <para>
 The regular expressions low level functionalities are obtained through
@@ -81,7 +81,7 @@ Error codes returned by regular expressions functions.
 </para>
 
 @G_REGEX_ERROR_COMPILE: Compilation of the regular expression in g_regex_new() failed.
-@G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression in g_regex_optimize() failed.
+@G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed.
 @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement string.
 @G_REGEX_ERROR_MATCH: The match process failed.
 @Since: 2.14
@@ -139,6 +139,9 @@ flag they are considered as a raw sequence of bytes.
 parentheses in the pattern. Any opening parenthesis that is not followed
 by "?" behaves as if it were followed by "?:" but named parentheses can
 still be used for capturing (and they acquire numbers in the usual way).
+@G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will
+be used many times, then it may be worth the effort to optimize it to
+improve the speed of matches.
 @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
 be unique. This can be helpful for certain types of pattern when it is known
 that only one instance of the named subpattern can ever be matched.
@@ -204,17 +207,12 @@ It is called for each occurance of the pattern @regex in @string, and it
 should append the replacement to @result.
 </para>
 
-<para>
-Do not call on @regex functions that modify its internal state, such as
-g_regex_match(); if you need it you can create a temporary copy of
-@regex using g_regex_copy().
-</para>
-
-@Param1: a #GRegex.
-@Param2: the string used to perform matches against.
-@Param3: a #GString containing the new string.
-@Param4: user data passed to g_regex_replace_eval().
-@Returns: %FALSE to continue the replacement process, %TRUE to stop it.
+@Param1: the #GRegex passed to g_regex_replace_eval()
+@Param2: the #GMatchInfo generated by the match
+@Param3: the string used to perform matches against
+@Param4: a #GString containing the new string
+@Param5: user data passed to g_regex_replace_eval()
+@Returns: %FALSE to continue the replacement process, %TRUE to stop it
 @Since: 2.14
 
 
@@ -238,42 +236,35 @@ g_regex_match(); if you need it you can create a temporary copy of
 @regex: 
 
 
-<!-- ##### FUNCTION g_regex_optimize ##### -->
+<!-- ##### FUNCTION g_regex_get_pattern ##### -->
 <para>
 
 </para>
 
 @regex: 
-@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_copy ##### -->
+<!-- ##### FUNCTION g_regex_get_string_number ##### -->
 <para>
 
 </para>
 
 @regex: 
+@name: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_get_pattern ##### -->
+<!-- ##### FUNCTION g_regex_escape_string ##### -->
 <para>
 
 </para>
 
-@regex: 
+@string: 
+@length: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_clear ##### -->
-<para>
-
-</para>
-
-@regex: 
-
-
 <!-- ##### FUNCTION g_regex_match_simple ##### -->
 <para>
 
@@ -294,6 +285,7 @@ g_regex_match(); if you need it you can create a temporary copy of
 @regex: 
 @string: 
 @match_options: 
+@match_info: 
 @Returns: 
 
 
@@ -307,11 +299,12 @@ g_regex_match(); if you need it you can create a temporary copy of
 @string_len: 
 @start_position: 
 @match_options: 
+@match_info: 
 @error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_match_next ##### -->
+<!-- ##### FUNCTION g_regex_match_all ##### -->
 <para>
 
 </para>
@@ -319,10 +312,11 @@ g_regex_match(); if you need it you can create a temporary copy of
 @regex: 
 @string: 
 @match_options: 
+@match_info: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_match_next_full ##### -->
+<!-- ##### FUNCTION g_regex_match_all_full ##### -->
 <para>
 
 </para>
@@ -332,247 +326,201 @@ g_regex_match(); if you need it you can create a temporary copy of
 @string_len: 
 @start_position: 
 @match_options: 
+@match_info: 
 @error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_match_all ##### -->
+<!-- ##### FUNCTION g_regex_split_simple ##### -->
 <para>
 
 </para>
 
-@regex
+@pattern
 @string: 
+@compile_options: 
 @match_options: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_match_all_full ##### -->
+<!-- ##### FUNCTION g_regex_split ##### -->
 <para>
 
 </para>
 
 @regex: 
 @string: 
-@string_len: 
-@start_position: 
 @match_options: 
-@error: 
-@Returns: 
-
-
-<!-- ##### FUNCTION g_regex_get_match_count ##### -->
-<para>
-
-</para>
-
-@regex: 
-@Returns: 
-
-
-<!-- ##### FUNCTION g_regex_is_partial_match ##### -->
-<para>
-
-</para>
-
-@regex: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_fetch ##### -->
+<!-- ##### FUNCTION g_regex_split_full ##### -->
 <para>
 
 </para>
 
 @regex: 
-@match_num: 
 @string: 
+@string_len: 
+@start_position: 
+@match_options: 
+@max_tokens: 
+@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_fetch_pos ##### -->
-<para>
-
-</para>
-
-@regex: 
-@match_num: 
-@start_pos: 
-@end_pos: 
-@Returns: 
-
-
-<!-- ##### FUNCTION g_regex_fetch_named ##### -->
+<!-- ##### FUNCTION g_regex_replace ##### -->
 <para>
 
 </para>
 
 @regex: 
-@name: 
 @string: 
+@string_len: 
+@start_position: 
+@replacement: 
+@match_options: 
+@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_fetch_named_pos ##### -->
+<!-- ##### FUNCTION g_regex_replace_literal ##### -->
 <para>
 
 </para>
 
 @regex: 
-@name: 
-@start_pos: 
-@end_pos: 
+@string: 
+@string_len: 
+@start_position: 
+@replacement: 
+@match_options: 
+@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_fetch_all ##### -->
+<!-- ##### FUNCTION g_regex_replace_eval ##### -->
 <para>
 
 </para>
 
 @regex: 
 @string: 
+@string_len: 
+@start_position: 
+@match_options: 
+@eval: 
+@user_data: 
+@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_get_string_number ##### -->
+<!-- ##### STRUCT GMatchInfo ##### -->
 <para>
-
+#GMatchInfo is used to retrieve information about the regular expression match
+which created it.
+This structure is opaque and its fields cannot be accessed directly.
 </para>
 
-@regex: 
-@name: 
-@Returns: 
-
+@Since: 2.14
 
-<!-- ##### FUNCTION g_regex_split_simple ##### -->
+<!-- ##### FUNCTION g_match_info_free ##### -->
 <para>
 
 </para>
 
-@pattern: 
-@string: 
-@compile_options: 
-@match_options: 
-@Returns: 
+@match_info: 
 
 
-<!-- ##### FUNCTION g_regex_split ##### -->
+<!-- ##### FUNCTION g_match_info_next ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@match_options: 
+@match_info: 
+@error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_split_full ##### -->
+<!-- ##### FUNCTION g_match_info_get_match_count ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_len: 
-@start_position: 
-@match_options: 
-@max_tokens: 
-@error: 
+@match_info: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_split_next ##### -->
+<!-- ##### FUNCTION g_match_info_is_partial_match ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@match_options: 
+@match_info: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_split_next_full ##### -->
+<!-- ##### FUNCTION g_match_info_expand_references ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_len: 
-@start_position: 
-@match_options: 
+@match_info: 
+@string_to_expand: 
 @error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_expand_references ##### -->
+<!-- ##### FUNCTION g_match_info_fetch ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_to_expand: 
-@error: 
+@match_info: 
+@match_num: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_replace ##### -->
+<!-- ##### FUNCTION g_match_info_fetch_pos ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_len: 
-@start_position: 
-@replacement: 
-@match_options: 
-@error: 
+@match_info: 
+@match_num: 
+@start_pos: 
+@end_pos: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_replace_literal ##### -->
+<!-- ##### FUNCTION g_match_info_fetch_named ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_len: 
-@start_position: 
-@replacement: 
-@match_options: 
-@error: 
+@match_info: 
+@name: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_replace_eval ##### -->
+<!-- ##### FUNCTION g_match_info_fetch_named_pos ##### -->
 <para>
 
 </para>
 
-@regex: 
-@string: 
-@string_len: 
-@start_position: 
-@match_options: 
-@eval: 
-@user_data: 
-@error: 
+@match_info: 
+@name: 
+@start_pos: 
+@end_pos: 
 @Returns: 
 
 
-<!-- ##### FUNCTION g_regex_escape_string ##### -->
+<!-- ##### FUNCTION g_match_info_fetch_all ##### -->
 <para>
 
 </para>
 
-@string: 
-@length: 
+@match_info: 
 @Returns: