-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These modules are inefficient and should not be used by Rust programs except for compatibility with GLib.Regex based APIs. All methods are implemented except for g_regex_replace_eval
- Loading branch information
1 parent
203c957
commit 03bce03
Showing
8 changed files
with
767 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// This file was generated by gir (https://github.com/gtk-rs/gir) | ||
// from gir-files (https://github.com/gtk-rs/gir-files) | ||
// DO NOT EDIT | ||
|
||
use crate::{translate::*, Error, Regex}; | ||
|
||
crate::wrapper! { | ||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct MatchInfo(Shared<ffi::GMatchInfo>); | ||
|
||
match fn { | ||
ref => |ptr| ffi::g_match_info_ref(ptr), | ||
unref => |ptr| ffi::g_match_info_unref(ptr), | ||
type_ => || ffi::g_match_info_get_type(), | ||
} | ||
} | ||
|
||
impl MatchInfo { | ||
#[doc(alias = "g_match_info_fetch")] | ||
pub fn fetch(&self, match_num: i32) -> Option<crate::GString> { | ||
unsafe { from_glib_full(ffi::g_match_info_fetch(self.to_glib_none().0, match_num)) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_fetch_all")] | ||
pub fn fetch_all(&self) -> Vec<crate::GString> { | ||
unsafe { | ||
FromGlibPtrContainer::from_glib_full(ffi::g_match_info_fetch_all(self.to_glib_none().0)) | ||
} | ||
} | ||
|
||
#[doc(alias = "g_match_info_fetch_pos")] | ||
pub fn fetch_pos(&self, match_num: i32) -> Option<(i32, i32)> { | ||
unsafe { | ||
let mut start_pos = std::mem::MaybeUninit::uninit(); | ||
let mut end_pos = std::mem::MaybeUninit::uninit(); | ||
let ret = from_glib(ffi::g_match_info_fetch_pos( | ||
self.to_glib_none().0, | ||
match_num, | ||
start_pos.as_mut_ptr(), | ||
end_pos.as_mut_ptr(), | ||
)); | ||
if ret { | ||
Some((start_pos.assume_init(), end_pos.assume_init())) | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
#[doc(alias = "g_match_info_get_match_count")] | ||
#[doc(alias = "get_match_count")] | ||
pub fn match_count(&self) -> i32 { | ||
unsafe { ffi::g_match_info_get_match_count(self.to_glib_none().0) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_get_regex")] | ||
#[doc(alias = "get_regex")] | ||
pub fn regex(&self) -> Regex { | ||
unsafe { from_glib_none(ffi::g_match_info_get_regex(self.to_glib_none().0)) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_get_string")] | ||
#[doc(alias = "get_string")] | ||
pub fn string(&self) -> crate::GString { | ||
unsafe { from_glib_none(ffi::g_match_info_get_string(self.to_glib_none().0)) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_is_partial_match")] | ||
pub fn is_partial_match(&self) -> bool { | ||
unsafe { from_glib(ffi::g_match_info_is_partial_match(self.to_glib_none().0)) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_matches")] | ||
pub fn matches(&self) -> bool { | ||
unsafe { from_glib(ffi::g_match_info_matches(self.to_glib_none().0)) } | ||
} | ||
|
||
#[doc(alias = "g_match_info_next")] | ||
pub fn next(&self) -> Result<(), crate::Error> { | ||
unsafe { | ||
let mut error = std::ptr::null_mut(); | ||
let is_ok = ffi::g_match_info_next(self.to_glib_none().0, &mut error); | ||
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null()); | ||
if error.is_null() { | ||
Ok(()) | ||
} else { | ||
Err(from_glib_full(error)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.