1 /**
2  * @defgroup Helper Helper
3  * @ingroup Elementary
4  *
5  * The validation helper feature.
6  *
7  * @{
8  */
9 
10 struct _Elm_Validate_Content
11 {
12    const char *text;
13    Eina_Tmpstr *signal;
14 };
15 /**
16  * Data for the elm_validator_regexp_helper()
17  */
18 typedef struct _Elm_Validate_Content Elm_Validate_Content;
19 
20 /**
21  * The Regexp validator data.
22  */
23 typedef struct _Elm_Validator_Regexp Elm_Validator_Regexp;
24 
25 /**
26  * @brief Enumeration that defines the regex error codes
27  * @since 1.14
28  */
29 typedef enum
30 {
31    /** Regex maches to the Entrys text. */
32    ELM_REG_NOERROR = 0,
33    /** Failed to match. */
34    ELM_REG_NOMATCH,
35    /** Invalid regular expression. */
36    ELM_REG_BADPAT,
37 } Elm_Regexp_Status;
38 
39 /**
40  * @brief Create a new regex validator.
41  * General designed for validate inputed entry text.
42  *
43  * @param pattern The regex pattern
44  * @param signal The part of signal name, which will be emitted to style
45  * @return The regex validator
46  *
47  * @see elm_validator_regexp_free()
48  * @see elm_validator_regexp_status_get()
49  * @see elm_validator_regexp_helper()
50  *
51  * @since 1.14
52  */
53 EAPI Elm_Validator_Regexp *
54 elm_validator_regexp_new(const char *pattern, const char *signal) EINA_ARG_NONNULL(1);
55 
56 /**
57  * @brief Delete the existing regex validator.
58  *
59  * @param validator The given validator
60  *
61  * @see elm_validator_regexp_new()
62  *
63  * @since 1.14
64  */
65 EAPI void
66 elm_validator_regexp_free(Elm_Validator_Regexp *validator) EINA_ARG_NONNULL(1);
67 
68 /**
69  * @brief Get the validation status.
70  *
71  * @param validator The given validator
72  *
73  * @note All return value see here: http://www.gnu.org/software/libc/manual/html_node/Regular-Expressions.html
74  *
75  * @since 1.14
76  */
77 EAPI Elm_Regexp_Status
78 elm_validator_regexp_status_get(Elm_Validator_Regexp *validator) EINA_ARG_NONNULL(1);
79 
80 #if defined(EFL_BETA_API_SUPPORT)
81 /**
82  * @brief The regex validator. Used as callback to validate event.
83  *
84  * Example:
85  * @code
86  * extern Evas_Object *parent;
87  * Evas_Object *entry;
88  * Elm_Validator_Regexp *re;
89  *
90  * //add validator
91  * entry = elm_entry_add(parent);
92  * re = elm_validator_regexp_new("^[0-9]*$", NULL);
93  * efl_event_callback_add(entry, ELM_ENTRY_EVENT_VALIDATE, elm_validator_regexp_helper, re);
94  *
95  * //delete validator
96  * efl_event_callback_del(entry, ELM_ENTRY_EVENT_VALIDATE, elm_validator_regexp_helper, re);
97  * @endcode
98  *
99  * @see elm_validator_regexp_new()
100  * @since 1.14
101  */
102 EAPI void
103 elm_validator_regexp_helper(void *data, const Efl_Event *event);
104 #endif
105 
106 /**
107  * @}
108  */
109